From 75ae9065d00f6c336bbb21acfba205e10d38d508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 25 Jun 2012 01:59:28 +0300 Subject: [PATCH] Uppercase names for static variables. --- openlp/plugins/songs/lib/__init__.py | 24 +++++++++----------- openlp/plugins/songs/lib/sundayplusimport.py | 6 ++--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index c7f7ea6b7..400817aad 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -378,10 +378,10 @@ class StripRtf(): Thanks to Markus Jarderot (MizardX) for this code, used by permission. http://stackoverflow.com/questions/188545 """ - pattern = re.compile(r"\\([a-z]{1,32})(-?\d{1,10})?[ ]?|\\'" + PATTERN = re.compile(r"\\([a-z]{1,32})(-?\d{1,10})?[ ]?|\\'" r"([0-9a-f]{2})|\\([^a-z])|([{}])|[\r\n]+|(.)", re.I) # Control words which specify a "destination" to be ignored. - destinations = frozenset(( + DESTINATIONS = frozenset(( u'aftncn', u'aftnsep', u'aftnsepc', u'annotation', u'atnauthor', u'atndate', u'atnicn', u'atnid', u'atnparent', u'atnref', u'atntime', u'atrfend', u'atrfstart', u'author', u'background', u'bkmkend', @@ -438,7 +438,7 @@ class StripRtf(): u'writereservhash', u'xe', u'xform', u'xmlattrname', u'xmlattrvalue', u'xmlclose', u'xmlname', u'xmlnstbl', u'xmlopen')) # Translation of some special characters. - specialchars = { + SPECIALCHARS = { u'par': u'\n', u'sect': u'\n\n', u'page': u'\n\n', @@ -454,7 +454,7 @@ class StripRtf(): u'rquote': u'\u2019', u'ldblquote': u'\u201C', u'rdblquote': u'\u201D'} - charset_mapping = { + CHARSET_MAPPING = { u'fcharset0': u'cp1252', u'fcharset1': None, u'fcharset2': None, @@ -492,7 +492,7 @@ class StripRtf(): curskip = 0 # Output buffer. out = [] - for match in self.pattern.finditer(text): + for match in self.PATTERN.finditer(text): word, arg, hex, char, brace, tchar = match.groups() if brace: curskip = 0 @@ -516,10 +516,10 @@ class StripRtf(): # \command elif word: curskip = 0 - if word in self.destinations: + if word in self.DESTINATIONS: ignorable = True - elif word in self.specialchars: - out.append(self.specialchars[word]) + elif word in self.SPECIALCHARS: + out.append(self.SPECIALCHARS[word]) elif word == u'uc': ucskip = int(arg) elif word == u' ': @@ -540,23 +540,21 @@ class StripRtf(): encoding = default_encoding elif word == u'ansicpg': if font == u'': - print "JEEEPASOIDFIJAD" if inside_font_table or font == u'': font_table[font] = 'cp' + arg elif word == u'fcharset': charset_reference = word + arg - if charset_reference in self.charset_mapping: - charset = self.charset_mapping[charset_reference] + if charset_reference in self.CHARSET_MAPPING: + charset = self.CHARSET_MAPPING[charset_reference] if not charset: charset = default_encoding else: - log.error(u"Charset '%s' not in charset_mapping " + log.error(u"Charset '%s' not in CHARSET_MAPPING " u"dictionary in " u"openlp/plugins/songs/lib/__init__.py" % charset_reference) charset = default_encoding if font == u'': - print "JEEEPASOIDFIadsfJAD" if inside_font_table or font == u'': font_table[font] = charset # \'xx diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index ab37bd0d2..cc36896e9 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -42,7 +42,7 @@ class SundayPlusImport(SongImport): The format examples can be found attached to bug report at """ - hotkeyToVerseType = { + HOTKEYTOVERSETYPE = { u'1': u'v1', u'2': u'v2', u'3': u'v3', @@ -147,8 +147,8 @@ class SundayPlusImport(SongImport): # Hotkey always appears after MARKER_NAME, so it # effectively overrides MARKER_NAME, if present. if len(value) and \ - value in self.hotkeyToVerseType.keys(): - verse_type = self.hotkeyToVerseType[value] + value in self.HOTKEYTOVERSETYPE.keys(): + verse_type = self.HOTKEYTOVERSETYPE[value] if name == 'rtf': value = self.unescape(value) verse = self.rtf.strip_rtf(value, self.encoding)