forked from openlp/openlp
Uppercase names for static variables.
This commit is contained in:
parent
36f7e03dc0
commit
75ae9065d0
@ -378,10 +378,10 @@ class StripRtf():
|
|||||||
Thanks to Markus Jarderot (MizardX) for this code, used by permission.
|
Thanks to Markus Jarderot (MizardX) for this code, used by permission.
|
||||||
http://stackoverflow.com/questions/188545
|
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)
|
r"([0-9a-f]{2})|\\([^a-z])|([{}])|[\r\n]+|(.)", re.I)
|
||||||
# Control words which specify a "destination" to be ignored.
|
# Control words which specify a "destination" to be ignored.
|
||||||
destinations = frozenset((
|
DESTINATIONS = frozenset((
|
||||||
u'aftncn', u'aftnsep', u'aftnsepc', u'annotation', u'atnauthor',
|
u'aftncn', u'aftnsep', u'aftnsepc', u'annotation', u'atnauthor',
|
||||||
u'atndate', u'atnicn', u'atnid', u'atnparent', u'atnref', u'atntime',
|
u'atndate', u'atnicn', u'atnid', u'atnparent', u'atnref', u'atntime',
|
||||||
u'atrfend', u'atrfstart', u'author', u'background', u'bkmkend',
|
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'writereservhash', u'xe', u'xform', u'xmlattrname', u'xmlattrvalue',
|
||||||
u'xmlclose', u'xmlname', u'xmlnstbl', u'xmlopen'))
|
u'xmlclose', u'xmlname', u'xmlnstbl', u'xmlopen'))
|
||||||
# Translation of some special characters.
|
# Translation of some special characters.
|
||||||
specialchars = {
|
SPECIALCHARS = {
|
||||||
u'par': u'\n',
|
u'par': u'\n',
|
||||||
u'sect': u'\n\n',
|
u'sect': u'\n\n',
|
||||||
u'page': u'\n\n',
|
u'page': u'\n\n',
|
||||||
@ -454,7 +454,7 @@ class StripRtf():
|
|||||||
u'rquote': u'\u2019',
|
u'rquote': u'\u2019',
|
||||||
u'ldblquote': u'\u201C',
|
u'ldblquote': u'\u201C',
|
||||||
u'rdblquote': u'\u201D'}
|
u'rdblquote': u'\u201D'}
|
||||||
charset_mapping = {
|
CHARSET_MAPPING = {
|
||||||
u'fcharset0': u'cp1252',
|
u'fcharset0': u'cp1252',
|
||||||
u'fcharset1': None,
|
u'fcharset1': None,
|
||||||
u'fcharset2': None,
|
u'fcharset2': None,
|
||||||
@ -492,7 +492,7 @@ class StripRtf():
|
|||||||
curskip = 0
|
curskip = 0
|
||||||
# Output buffer.
|
# Output buffer.
|
||||||
out = []
|
out = []
|
||||||
for match in self.pattern.finditer(text):
|
for match in self.PATTERN.finditer(text):
|
||||||
word, arg, hex, char, brace, tchar = match.groups()
|
word, arg, hex, char, brace, tchar = match.groups()
|
||||||
if brace:
|
if brace:
|
||||||
curskip = 0
|
curskip = 0
|
||||||
@ -516,10 +516,10 @@ class StripRtf():
|
|||||||
# \command
|
# \command
|
||||||
elif word:
|
elif word:
|
||||||
curskip = 0
|
curskip = 0
|
||||||
if word in self.destinations:
|
if word in self.DESTINATIONS:
|
||||||
ignorable = True
|
ignorable = True
|
||||||
elif word in self.specialchars:
|
elif word in self.SPECIALCHARS:
|
||||||
out.append(self.specialchars[word])
|
out.append(self.SPECIALCHARS[word])
|
||||||
elif word == u'uc':
|
elif word == u'uc':
|
||||||
ucskip = int(arg)
|
ucskip = int(arg)
|
||||||
elif word == u' ':
|
elif word == u' ':
|
||||||
@ -540,23 +540,21 @@ class StripRtf():
|
|||||||
encoding = default_encoding
|
encoding = default_encoding
|
||||||
elif word == u'ansicpg':
|
elif word == u'ansicpg':
|
||||||
if font == u'':
|
if font == u'':
|
||||||
print "JEEEPASOIDFIJAD"
|
|
||||||
if inside_font_table or font == u'':
|
if inside_font_table or font == u'':
|
||||||
font_table[font] = 'cp' + arg
|
font_table[font] = 'cp' + arg
|
||||||
elif word == u'fcharset':
|
elif word == u'fcharset':
|
||||||
charset_reference = word + arg
|
charset_reference = word + arg
|
||||||
if charset_reference in self.charset_mapping:
|
if charset_reference in self.CHARSET_MAPPING:
|
||||||
charset = self.charset_mapping[charset_reference]
|
charset = self.CHARSET_MAPPING[charset_reference]
|
||||||
if not charset:
|
if not charset:
|
||||||
charset = default_encoding
|
charset = default_encoding
|
||||||
else:
|
else:
|
||||||
log.error(u"Charset '%s' not in charset_mapping "
|
log.error(u"Charset '%s' not in CHARSET_MAPPING "
|
||||||
u"dictionary in "
|
u"dictionary in "
|
||||||
u"openlp/plugins/songs/lib/__init__.py"
|
u"openlp/plugins/songs/lib/__init__.py"
|
||||||
% charset_reference)
|
% charset_reference)
|
||||||
charset = default_encoding
|
charset = default_encoding
|
||||||
if font == u'':
|
if font == u'':
|
||||||
print "JEEEPASOIDFIadsfJAD"
|
|
||||||
if inside_font_table or font == u'':
|
if inside_font_table or font == u'':
|
||||||
font_table[font] = charset
|
font_table[font] = charset
|
||||||
# \'xx
|
# \'xx
|
||||||
|
@ -42,7 +42,7 @@ class SundayPlusImport(SongImport):
|
|||||||
The format examples can be found attached to bug report at
|
The format examples can be found attached to bug report at
|
||||||
<http://support.openlp.org/issues/395>
|
<http://support.openlp.org/issues/395>
|
||||||
"""
|
"""
|
||||||
hotkeyToVerseType = {
|
HOTKEYTOVERSETYPE = {
|
||||||
u'1': u'v1',
|
u'1': u'v1',
|
||||||
u'2': u'v2',
|
u'2': u'v2',
|
||||||
u'3': u'v3',
|
u'3': u'v3',
|
||||||
@ -147,8 +147,8 @@ class SundayPlusImport(SongImport):
|
|||||||
# Hotkey always appears after MARKER_NAME, so it
|
# Hotkey always appears after MARKER_NAME, so it
|
||||||
# effectively overrides MARKER_NAME, if present.
|
# effectively overrides MARKER_NAME, if present.
|
||||||
if len(value) and \
|
if len(value) and \
|
||||||
value in self.hotkeyToVerseType.keys():
|
value in self.HOTKEYTOVERSETYPE.keys():
|
||||||
verse_type = self.hotkeyToVerseType[value]
|
verse_type = self.HOTKEYTOVERSETYPE[value]
|
||||||
if name == 'rtf':
|
if name == 'rtf':
|
||||||
value = self.unescape(value)
|
value = self.unescape(value)
|
||||||
verse = self.rtf.strip_rtf(value, self.encoding)
|
verse = self.rtf.strip_rtf(value, self.encoding)
|
||||||
|
Loading…
Reference in New Issue
Block a user