From b699f98cbbaf87ab3f356e9bf653a14353960e37 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 15 Sep 2010 12:51:02 +0000 Subject: [PATCH] minor refactoring --- lib/core/common.py | 79 +++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index de85273c7..865101f8a 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -77,6 +77,46 @@ from lib.core.settings import SQLITE_ALIASES from lib.core.settings import ACCESS_ALIASES from lib.core.settings import FIREBIRD_ALIASES + +class UnicodeRawConfigParser(RawConfigParser): + def write(self, fp): + """ + Write an .ini-format representation of the configuration state. + """ + + if self._defaults: + fp.write("[%s]\n" % DEFAULTSECT) + + for (key, value) in self._defaults.items(): + fp.write("%s = %s\n" % (key, getUnicode(value).replace('\n', '\n\t'))) + + fp.write("\n") + + for section in self._sections: + fp.write("[%s]\n" % section) + + for (key, value) in self._sections[section].items(): + if key != "__name__": + if value is None: + fp.write("%s\n" % (key)) + else: + fp.write("%s = %s\n" % (key, getUnicode(value).replace('\n', '\n\t'))) + + fp.write("\n") + + +class DynamicContentItem: + """ + Represents line in content page with dynamic properties (candidate for removal prior detection phase) + """ + + def __init__(self, lineNumber, pageTotal, lineContentBefore, lineContentAfter): + self.lineNumber = lineNumber + self.pageTotal = pageTotal + self.lineContentBefore = lineContentBefore + self.lineContentAfter = lineContentAfter + + def paramToDict(place, parameters=None): """ Split the parameters into names and values, check if these parameters @@ -1469,42 +1509,3 @@ def smokeTest(): infoMsg += "FAILED" logger.error(infoMsg) return retVal - - -class UnicodeRawConfigParser(RawConfigParser): - def write(self, fp): - """ - Write an .ini-format representation of the configuration state. - """ - - if self._defaults: - fp.write("[%s]\n" % DEFAULTSECT) - - for (key, value) in self._defaults.items(): - fp.write("%s = %s\n" % (key, getUnicode(value).replace('\n', '\n\t'))) - - fp.write("\n") - - for section in self._sections: - fp.write("[%s]\n" % section) - - for (key, value) in self._sections[section].items(): - if key != "__name__": - if value is None: - fp.write("%s\n" % (key)) - else: - fp.write("%s = %s\n" % (key, getUnicode(value).replace('\n', '\n\t'))) - - fp.write("\n") - - -class DynamicContentItem: - """ - Represents line in content page with dynamic properties (candidate for removal prior detection phase) - """ - - def __init__(self, lineNumber, pageTotal, lineContentBefore, lineContentAfter): - self.lineNumber = lineNumber - self.pageTotal = pageTotal - self.lineContentBefore = lineContentBefore - self.lineContentAfter = lineContentAfter