forked from openlp/openlp
Fixes for pycodestyle
This commit is contained in:
parent
a49d8068d8
commit
318e90f893
@ -115,7 +115,7 @@ def display_thumbnails(request, controller_name, log, dimensions, file_name, sli
|
|||||||
height = -1
|
height = -1
|
||||||
image = None
|
image = None
|
||||||
if dimensions:
|
if dimensions:
|
||||||
match = re.search('(\d+)x(\d+)', dimensions)
|
match = re.search(r'(\d+)x(\d+)', dimensions)
|
||||||
if match:
|
if match:
|
||||||
# let's make sure that the dimensions are within reason
|
# let's make sure that the dimensions are within reason
|
||||||
width = sorted([10, int(match.group(1)), 1000])[1]
|
width = sorted([10, int(match.group(1)), 1000])[1]
|
||||||
|
@ -55,7 +55,7 @@ class ApiTab(SettingsTab):
|
|||||||
self.address_label.setObjectName('address_label')
|
self.address_label.setObjectName('address_label')
|
||||||
self.address_edit = QtWidgets.QLineEdit(self.server_settings_group_box)
|
self.address_edit = QtWidgets.QLineEdit(self.server_settings_group_box)
|
||||||
self.address_edit.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
|
self.address_edit.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
|
||||||
self.address_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'),
|
self.address_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'),
|
||||||
self))
|
self))
|
||||||
self.address_edit.setObjectName('address_edit')
|
self.address_edit.setObjectName('address_edit')
|
||||||
self.server_settings_layout.addRow(self.address_label, self.address_edit)
|
self.server_settings_layout.addRow(self.address_label, self.address_edit)
|
||||||
|
@ -415,7 +415,7 @@ def expand_chords(text):
|
|||||||
chords_on_prev_line = True
|
chords_on_prev_line = True
|
||||||
# Matches a chord, a tail, a remainder and a line end. See expand_and_align_chords_in_line() for more info.
|
# Matches a chord, a tail, a remainder and a line end. See expand_and_align_chords_in_line() for more info.
|
||||||
new_line += re.sub(r'\[(.*?)\]([\u0080-\uFFFF,\w]*)'
|
new_line += re.sub(r'\[(.*?)\]([\u0080-\uFFFF,\w]*)'
|
||||||
'([\u0080-\uFFFF,\w,\s,\.,\,,\!,\?,\;,\:,\|,\",\',\-,\_]*)(\Z)?',
|
r'([\u0080-\uFFFF,\w,\s,\.,\,,\!,\?,\;,\:,\|,\",\',\-,\_]*)(\Z)?',
|
||||||
expand_and_align_chords_in_line, line)
|
expand_and_align_chords_in_line, line)
|
||||||
new_line += '</span>'
|
new_line += '</span>'
|
||||||
expanded_text_lines.append(new_line)
|
expanded_text_lines.append(new_line)
|
||||||
|
@ -338,7 +338,7 @@ class PJLinkCommands(object):
|
|||||||
# Due to stupid projectors not following standards (Optoma, BenQ comes to mind),
|
# Due to stupid projectors not following standards (Optoma, BenQ comes to mind),
|
||||||
# AND the different responses that can be received, the semi-permanent way to
|
# AND the different responses that can be received, the semi-permanent way to
|
||||||
# fix the class reply is to just remove all non-digit characters.
|
# fix the class reply is to just remove all non-digit characters.
|
||||||
chk = re.findall('\d', data)
|
chk = re.findall(r'\d', data)
|
||||||
if len(chk) < 1:
|
if len(chk) < 1:
|
||||||
log.error('({ip}) No numbers found in class version reply "{data}" - '
|
log.error('({ip}) No numbers found in class version reply "{data}" - '
|
||||||
'defaulting to class "1"'.format(ip=self.entry.name, data=data))
|
'defaulting to class "1"'.format(ip=self.entry.name, data=data))
|
||||||
|
@ -80,7 +80,7 @@ def get_media_players():
|
|||||||
"""
|
"""
|
||||||
log.debug('get_media_players')
|
log.debug('get_media_players')
|
||||||
saved_players = Settings().value('media/players')
|
saved_players = Settings().value('media/players')
|
||||||
reg_ex = QtCore.QRegExp(".*\[(.*)\].*")
|
reg_ex = QtCore.QRegExp(r'.*\[(.*)\].*')
|
||||||
if Settings().value('media/override player') == QtCore.Qt.Checked:
|
if Settings().value('media/override player') == QtCore.Qt.Checked:
|
||||||
if reg_ex.exactMatch(saved_players):
|
if reg_ex.exactMatch(saved_players):
|
||||||
overridden_player = '{text}'.format(text=reg_ex.cap(1))
|
overridden_player = '{text}'.format(text=reg_ex.cap(1))
|
||||||
|
@ -183,7 +183,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Validate a book.
|
Validate a book.
|
||||||
"""
|
"""
|
||||||
book_regex = re.compile('[\d]*[^\d]+$')
|
book_regex = re.compile(r'[\d]*[^\d]+$')
|
||||||
if not new_book_name:
|
if not new_book_name:
|
||||||
self.book_name_edit[abbreviation].setFocus()
|
self.book_name_edit[abbreviation].setFocus()
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
|
@ -217,7 +217,7 @@ def update_reference_separators():
|
|||||||
# add various Unicode alternatives
|
# add various Unicode alternatives
|
||||||
source_string = source_string.replace('-', '(?:[-\u00AD\u2010\u2011\u2012\u2014\u2014\u2212\uFE63\uFF0D])')
|
source_string = source_string.replace('-', '(?:[-\u00AD\u2010\u2011\u2012\u2014\u2014\u2212\uFE63\uFF0D])')
|
||||||
source_string = source_string.replace(',', '(?:[,\u201A])')
|
source_string = source_string.replace(',', '(?:[,\u201A])')
|
||||||
REFERENCE_SEPARATORS['sep_{role}'.format(role=role)] = '\s*(?:{source})\s*'.format(source=source_string)
|
REFERENCE_SEPARATORS['sep_{role}'.format(role=role)] = r'\s*(?:{source})\s*'.format(source=source_string)
|
||||||
REFERENCE_SEPARATORS['sep_{role}_default'.format(role=role)] = default_separators[index]
|
REFERENCE_SEPARATORS['sep_{role}_default'.format(role=role)] = default_separators[index]
|
||||||
# verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
|
# verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
|
||||||
range_regex = '(?:(?P<from_chapter>[0-9]+){sep_v})?' \
|
range_regex = '(?:(?P<from_chapter>[0-9]+){sep_v})?' \
|
||||||
|
@ -41,7 +41,7 @@ from openlp.plugins.bibles.lib import DisplayStyle, LayoutStyle, VerseReferenceL
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
VALID_TEXT_SEARCH = re.compile('\w\w\w')
|
VALID_TEXT_SEARCH = re.compile(r'\w\w\w')
|
||||||
|
|
||||||
|
|
||||||
def get_reference_separators():
|
def get_reference_separators():
|
||||||
|
@ -210,7 +210,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
|
|||||||
# detect if we're dealing with a DVD or CD, so we use different loading approaches depending on the OS.
|
# detect if we're dealing with a DVD or CD, so we use different loading approaches depending on the OS.
|
||||||
if is_win():
|
if is_win():
|
||||||
# If the given path is in the format "D:\" or "D:", prefix it with "/" to make VLC happy
|
# If the given path is in the format "D:\" or "D:", prefix it with "/" to make VLC happy
|
||||||
pattern = re.compile('^\w:\\\\*$')
|
pattern = re.compile(r'^\w:\\\\*$')
|
||||||
if pattern.match(path):
|
if pattern.match(path):
|
||||||
path = '/' + path
|
path = '/' + path
|
||||||
self.vlc_media = self.vlc_instance.media_new_location('dvd://' + path)
|
self.vlc_media = self.vlc_instance.media_new_location('dvd://' + path)
|
||||||
|
@ -105,7 +105,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
self.topics_list_view.setSortingEnabled(False)
|
self.topics_list_view.setSortingEnabled(False)
|
||||||
self.topics_list_view.setAlternatingRowColors(True)
|
self.topics_list_view.setAlternatingRowColors(True)
|
||||||
self.audio_list_widget.setAlternatingRowColors(True)
|
self.audio_list_widget.setAlternatingRowColors(True)
|
||||||
self.find_verse_split = re.compile('---\[\]---\n')
|
self.find_verse_split = re.compile(r'---\[\]---\n')
|
||||||
self.whitespace = re.compile(r'\W+')
|
self.whitespace = re.compile(r'\W+')
|
||||||
self.find_tags = re.compile(r'\{/?\w+\}')
|
self.find_tags = re.compile(r'\{/?\w+\}')
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
multiple.append(verse_tag)
|
multiple.append(verse_tag)
|
||||||
self.song.lyrics = str(sxml.extract_xml(), 'utf-8')
|
self.song.lyrics = str(sxml.extract_xml(), 'utf-8')
|
||||||
for verse in multiple:
|
for verse in multiple:
|
||||||
self.song.verse_order = re.sub('([' + verse.upper() + verse.lower() + '])(\W|$)',
|
self.song.verse_order = re.sub(r'([' + verse.upper() + verse.lower() + r'])(\W|$)',
|
||||||
r'\g<1>1\2', self.song.verse_order)
|
r'\g<1>1\2', self.song.verse_order)
|
||||||
except:
|
except:
|
||||||
log.exception('Problem processing song Lyrics \n{xml}'.format(xml=sxml.dump_xml()))
|
log.exception('Problem processing song Lyrics \n{xml}'.format(xml=sxml.dump_xml()))
|
||||||
|
@ -557,7 +557,7 @@ def transpose_lyrics(lyrics, transpose_value):
|
|||||||
:return: The transposed lyrics
|
:return: The transposed lyrics
|
||||||
"""
|
"""
|
||||||
# Split text by verse delimiter - both normal and optional
|
# Split text by verse delimiter - both normal and optional
|
||||||
verse_list = re.split('(---\[.+?:.+?\]---|\[---\])', lyrics)
|
verse_list = re.split(r'(---\[.+?:.+?\]---|\[---\])', lyrics)
|
||||||
transposed_lyrics = ''
|
transposed_lyrics = ''
|
||||||
notation = Settings().value('songs/chord notation')
|
notation = Settings().value('songs/chord notation')
|
||||||
for verse in verse_list:
|
for verse in verse_list:
|
||||||
@ -580,7 +580,7 @@ def transpose_verse(verse_text, transpose_value, notation):
|
|||||||
if '[' not in verse_text:
|
if '[' not in verse_text:
|
||||||
return verse_text
|
return verse_text
|
||||||
# Split the lyrics based on chord tags
|
# Split the lyrics based on chord tags
|
||||||
lyric_list = re.split('(\[|\]|/)', verse_text)
|
lyric_list = re.split(r'(\[|\]|/)', verse_text)
|
||||||
transposed_lyrics = ''
|
transposed_lyrics = ''
|
||||||
in_tag = False
|
in_tag = False
|
||||||
for word in lyric_list:
|
for word in lyric_list:
|
||||||
|
@ -37,7 +37,7 @@ class EasySlidesImport(SongImport):
|
|||||||
Import songs exported from EasySlides
|
Import songs exported from EasySlides
|
||||||
|
|
||||||
The format example is here:
|
The format example is here:
|
||||||
http://wiki.openlp.org/Development:EasySlides\_-_Song_Data_Format
|
http://wiki.openlp.org/Development:EasySlides_-_Song_Data_Format
|
||||||
"""
|
"""
|
||||||
def __init__(self, manager, **kwargs):
|
def __init__(self, manager, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -210,7 +210,7 @@ class EasySlidesImport(SongImport):
|
|||||||
vn = '1'
|
vn = '1'
|
||||||
# have we got any digits?
|
# have we got any digits?
|
||||||
# If so, versenumber is everything from the digits to the end
|
# If so, versenumber is everything from the digits to the end
|
||||||
match = re.match('(.*)(\d+.*)', marker)
|
match = re.match(r'(.*)(\d+.*)', marker)
|
||||||
if match:
|
if match:
|
||||||
marker = match.group(1).strip()
|
marker = match.group(1).strip()
|
||||||
vn = match.group(2)
|
vn = match.group(2)
|
||||||
|
@ -273,15 +273,15 @@ class FoilPresenter(object):
|
|||||||
elif copyright.find('C,)') != -1:
|
elif copyright.find('C,)') != -1:
|
||||||
temp = copyright.partition('C,)')
|
temp = copyright.partition('C,)')
|
||||||
copyright = temp[0]
|
copyright = temp[0]
|
||||||
copyright = re.compile('\\n').sub(' ', copyright)
|
copyright = re.compile(r'\\n').sub(' ', copyright)
|
||||||
copyright = re.compile('\(.*\)').sub('', copyright)
|
copyright = re.compile(r'\(.*\)').sub('', copyright)
|
||||||
if copyright.find('Rechte') != -1:
|
if copyright.find('Rechte') != -1:
|
||||||
temp = copyright.partition('Rechte')
|
temp = copyright.partition('Rechte')
|
||||||
copyright = temp[0]
|
copyright = temp[0]
|
||||||
markers = ['Text +u\.?n?d? +Melodie[\w\,\. ]*:',
|
markers = [r'Text +u\.?n?d? +Melodie[\w\,\. ]*:',
|
||||||
'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz',
|
r'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz',
|
||||||
'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz',
|
r'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz',
|
||||||
'Weise', '[dD]eutsch', '[dD]t[\.\:]', 'Englisch',
|
'Weise', '[dD]eutsch', r'[dD]t[\.\:]', 'Englisch',
|
||||||
'[oO]riginal', 'Bearbeitung', '[R|r]efrain']
|
'[oO]riginal', 'Bearbeitung', '[R|r]efrain']
|
||||||
for marker in markers:
|
for marker in markers:
|
||||||
copyright = re.compile(marker).sub('<marker>', copyright, re.U)
|
copyright = re.compile(marker).sub('<marker>', copyright, re.U)
|
||||||
@ -301,17 +301,17 @@ class FoilPresenter(object):
|
|||||||
break
|
break
|
||||||
author_temp = []
|
author_temp = []
|
||||||
for author in strings:
|
for author in strings:
|
||||||
temp = re.split(',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author)
|
temp = re.split(r',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author)
|
||||||
for tempx in temp:
|
for tempx in temp:
|
||||||
author_temp.append(tempx)
|
author_temp.append(tempx)
|
||||||
for author in author_temp:
|
for author in author_temp:
|
||||||
regex = '^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$'
|
regex = r'^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$'
|
||||||
author = re.compile(regex).sub('', author)
|
author = re.compile(regex).sub('', author)
|
||||||
author = re.compile('[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', author)
|
author = re.compile(r'[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', author)
|
||||||
author = re.compile('[N|n]ach.*$').sub('', author)
|
author = re.compile(r'[N|n]ach.*$').sub('', author)
|
||||||
author = author.strip()
|
author = author.strip()
|
||||||
if re.search('\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U):
|
if re.search(r'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U):
|
||||||
temp = re.split('\s[a|u]nd\s|\s&\s', author)
|
temp = re.split(r'\s[a|u]nd\s|\s&\s', author)
|
||||||
for tempx in temp:
|
for tempx in temp:
|
||||||
tempx = tempx.strip()
|
tempx = tempx.strip()
|
||||||
authors.append(tempx)
|
authors.append(tempx)
|
||||||
|
@ -80,7 +80,7 @@ class LyrixImport(SongImport):
|
|||||||
continue
|
continue
|
||||||
# Detect and get CCLI number
|
# Detect and get CCLI number
|
||||||
if line.lower().startswith('ccli'):
|
if line.lower().startswith('ccli'):
|
||||||
ccli = re.findall('\d+', line)[0]
|
ccli = re.findall(r'\d+', line)[0]
|
||||||
try:
|
try:
|
||||||
# If the CCLI was found, we are near the end
|
# If the CCLI was found, we are near the end
|
||||||
# Find author
|
# Find author
|
||||||
|
@ -156,7 +156,7 @@ class OpenSongImport(SongImport):
|
|||||||
ustring = str(root.__getattr__(attr))
|
ustring = str(root.__getattr__(attr))
|
||||||
if isinstance(fn_or_string, str):
|
if isinstance(fn_or_string, str):
|
||||||
if attr in ['ccli']:
|
if attr in ['ccli']:
|
||||||
ustring = ''.join(re.findall('\d+', ustring))
|
ustring = ''.join(re.findall(r'\d+', ustring))
|
||||||
if ustring:
|
if ustring:
|
||||||
setattr(self, fn_or_string, int(ustring))
|
setattr(self, fn_or_string, int(ustring))
|
||||||
else:
|
else:
|
||||||
@ -231,7 +231,7 @@ class OpenSongImport(SongImport):
|
|||||||
content = this_line[1:right_bracket].lower()
|
content = this_line[1:right_bracket].lower()
|
||||||
# have we got any digits? If so, verse number is everything from the digits to the end (openlp does not
|
# have we got any digits? If so, verse number is everything from the digits to the end (openlp does not
|
||||||
# have concept of part verses, so just ignore any non integers on the end (including floats))
|
# have concept of part verses, so just ignore any non integers on the end (including floats))
|
||||||
match = re.match('(\D*)(\d+)', content)
|
match = re.match(r'(\D*)(\d+)', content)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
verse_tag = match.group(1)
|
verse_tag = match.group(1)
|
||||||
verse_num = match.group(2)
|
verse_num = match.group(2)
|
||||||
@ -303,7 +303,7 @@ class OpenSongImport(SongImport):
|
|||||||
# whitespace.
|
# whitespace.
|
||||||
order = order.lower().split()
|
order = order.lower().split()
|
||||||
for verse_def in order:
|
for verse_def in order:
|
||||||
match = re.match('(\D*)(\d+.*)', verse_def)
|
match = re.match(r'(\D*)(\d+.*)', verse_def)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
verse_tag = match.group(1)
|
verse_tag = match.group(1)
|
||||||
verse_num = match.group(2)
|
verse_num = match.group(2)
|
||||||
|
@ -122,7 +122,7 @@ class OPSProImport(SongImport):
|
|||||||
# Try to split lyrics based on various rules
|
# Try to split lyrics based on various rules
|
||||||
if lyrics:
|
if lyrics:
|
||||||
lyrics_text = lyrics.Lyrics
|
lyrics_text = lyrics.Lyrics
|
||||||
verses = re.split('\r\n\s*?\r\n', lyrics_text)
|
verses = re.split(r'\r\n\s*?\r\n', lyrics_text)
|
||||||
verse_tag_defs = {}
|
verse_tag_defs = {}
|
||||||
verse_tag_texts = {}
|
verse_tag_texts = {}
|
||||||
for verse_text in verses:
|
for verse_text in verses:
|
||||||
@ -130,13 +130,13 @@ class OPSProImport(SongImport):
|
|||||||
continue
|
continue
|
||||||
verse_def = 'v'
|
verse_def = 'v'
|
||||||
# Detect verse number
|
# Detect verse number
|
||||||
verse_number = re.match('^(\d+)\r\n', verse_text)
|
verse_number = re.match(r'^(\d+)\r\n', verse_text)
|
||||||
if verse_number:
|
if verse_number:
|
||||||
verse_text = re.sub('^\d+\r\n', '', verse_text)
|
verse_text = re.sub(r'^\d+\r\n', '', verse_text)
|
||||||
verse_def = 'v' + verse_number.group(1)
|
verse_def = 'v' + verse_number.group(1)
|
||||||
# Detect verse tags
|
# Detect verse tags
|
||||||
elif re.match('^.+?\:\r\n', verse_text):
|
elif re.match(r'^.+?\:\r\n', verse_text):
|
||||||
tag_match = re.match('^(.+?)\:\r\n(.*)', verse_text, flags=re.DOTALL)
|
tag_match = re.match(r'^(.+?)\:\r\n(.*)', verse_text, flags=re.DOTALL)
|
||||||
tag = tag_match.group(1).lower()
|
tag = tag_match.group(1).lower()
|
||||||
tag = tag.split(' ')[0]
|
tag = tag.split(' ')[0]
|
||||||
verse_text = tag_match.group(2)
|
verse_text = tag_match.group(2)
|
||||||
@ -147,25 +147,25 @@ class OPSProImport(SongImport):
|
|||||||
verse_tag_defs[tag] = verse_def
|
verse_tag_defs[tag] = verse_def
|
||||||
verse_tag_texts[tag] = verse_text
|
verse_tag_texts[tag] = verse_text
|
||||||
# Detect tag reference
|
# Detect tag reference
|
||||||
elif re.match('^\(.*?\)$', verse_text):
|
elif re.match(r'^\(.*?\)$', verse_text):
|
||||||
tag_match = re.match('^\((.*?)\)$', verse_text)
|
tag_match = re.match(r'^\((.*?)\)$', verse_text)
|
||||||
tag = tag_match.group(1).lower()
|
tag = tag_match.group(1).lower()
|
||||||
if tag in verse_tag_defs:
|
if tag in verse_tag_defs:
|
||||||
verse_text = verse_tag_texts[tag]
|
verse_text = verse_tag_texts[tag]
|
||||||
verse_def = verse_tag_defs[tag]
|
verse_def = verse_tag_defs[tag]
|
||||||
# Detect end tag
|
# Detect end tag
|
||||||
elif re.match('^\[slot\]\r\n', verse_text, re.IGNORECASE):
|
elif re.match(r'^\[slot\]\r\n', verse_text, re.IGNORECASE):
|
||||||
verse_def = 'e'
|
verse_def = 'e'
|
||||||
verse_text = re.sub('^\[slot\]\r\n', '', verse_text, flags=re.IGNORECASE)
|
verse_text = re.sub(r'^\[slot\]\r\n', '', verse_text, flags=re.IGNORECASE)
|
||||||
# Replace the join tag with line breaks
|
# Replace the join tag with line breaks
|
||||||
verse_text = verse_text.replace('[join]', '')
|
verse_text = verse_text.replace('[join]', '')
|
||||||
# Replace the split tag with line breaks and an optional split
|
# Replace the split tag with line breaks and an optional split
|
||||||
verse_text = re.sub('\[splits?\]', '\r\n[---]', verse_text)
|
verse_text = re.sub(r'\[splits?\]', '\r\n[---]', verse_text)
|
||||||
# Handle translations
|
# Handle translations
|
||||||
if lyrics.IsDualLanguage:
|
if lyrics.IsDualLanguage:
|
||||||
verse_text = self.handle_translation(verse_text)
|
verse_text = self.handle_translation(verse_text)
|
||||||
# Remove comments
|
# Remove comments
|
||||||
verse_text = re.sub('\(.*?\)\r\n', '', verse_text, flags=re.IGNORECASE)
|
verse_text = re.sub(r'\(.*?\)\r\n', '', verse_text, flags=re.IGNORECASE)
|
||||||
self.add_verse(verse_text, verse_def)
|
self.add_verse(verse_text, verse_def)
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class PresentationManagerImport(SongImport):
|
|||||||
encoding = get_file_encoding(file_path)['encoding']
|
encoding = get_file_encoding(file_path)['encoding']
|
||||||
# Open file with detected encoding and remove encoding declaration
|
# Open file with detected encoding and remove encoding declaration
|
||||||
text = file_path.read_text(encoding=encoding)
|
text = file_path.read_text(encoding=encoding)
|
||||||
text = re.sub('.+\?>\n', '', text)
|
text = re.sub(r'.+\?>\n', '', text)
|
||||||
try:
|
try:
|
||||||
tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
|
tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -333,7 +333,7 @@ class SongsOfFellowshipImport(OpenOfficeImport):
|
|||||||
There is a complicated word "One", which is sometimes lower and
|
There is a complicated word "One", which is sometimes lower and
|
||||||
sometimes upper depending on context. Never mind, keep it lower.
|
sometimes upper depending on context. Never mind, keep it lower.
|
||||||
"""
|
"""
|
||||||
text_arr = re.split('(\W+)', text)
|
text_arr = re.split(r'(\W+)', text)
|
||||||
text_arr[0] = text_arr[0].capitalize()
|
text_arr[0] = text_arr[0].capitalize()
|
||||||
for i in range(1, len(text_arr)):
|
for i in range(1, len(text_arr)):
|
||||||
# Do not translate these. Fixed strings in SOF song file
|
# Do not translate these. Fixed strings in SOF song file
|
||||||
|
@ -142,7 +142,7 @@ class WorshipAssistantImport(SongImport):
|
|||||||
# drop the square brackets
|
# drop the square brackets
|
||||||
right_bracket = line.find(']')
|
right_bracket = line.find(']')
|
||||||
content = line[1:right_bracket].lower()
|
content = line[1:right_bracket].lower()
|
||||||
match = re.match('(\D*)(\d+)', content)
|
match = re.match(r'(\D*)(\d+)', content)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
verse_tag = match.group(1)
|
verse_tag = match.group(1)
|
||||||
verse_num = match.group(2)
|
verse_num = match.group(2)
|
||||||
|
@ -124,7 +124,7 @@ def get_merge_info(url):
|
|||||||
script_tag = soup.find('script', attrs={"id": "codereview-script"})
|
script_tag = soup.find('script', attrs={"id": "codereview-script"})
|
||||||
content = script_tag.contents[0]
|
content = script_tag.contents[0]
|
||||||
start_pos = content.find('source_revid') + 16
|
start_pos = content.find('source_revid') + 16
|
||||||
pattern = re.compile('.*\w-\d\d\d\d\d+')
|
pattern = re.compile(r'.*\w-\d\d\d\d\d+')
|
||||||
match = pattern.match(content[start_pos:])
|
match = pattern.match(content[start_pos:])
|
||||||
merge_info['author_email'] = match.group()[:-15]
|
merge_info['author_email'] = match.group()[:-15]
|
||||||
# Launchpad doesn't supply the author's true name, so we'll just grab whatever they use for display on LP
|
# Launchpad doesn't supply the author's true name, so we'll just grab whatever they use for display on LP
|
||||||
|
@ -15,5 +15,10 @@ ignore = E402
|
|||||||
[pycodestyle]
|
[pycodestyle]
|
||||||
exclude = resources.py,vlc.py
|
exclude = resources.py,vlc.py
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
ignore = E402
|
# Ignoring:
|
||||||
|
# E402...
|
||||||
|
# E722 do not use bare 'except'
|
||||||
|
# W503 line break before binary operator
|
||||||
|
# W504 line break after binary operator
|
||||||
|
ignore = E402,E722,W503,W504
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class TestApiTab(TestCase, TestMixin):
|
|||||||
ip_address = self.form.get_ip_address(ZERO_URL)
|
ip_address = self.form.get_ip_address(ZERO_URL)
|
||||||
|
|
||||||
# THEN: the default ip address will be returned
|
# THEN: the default ip address will be returned
|
||||||
assert re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address), \
|
assert re.match(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address), \
|
||||||
'The return value should be a valid ip address'
|
'The return value should be a valid ip address'
|
||||||
assert ip_address in ip4_list, 'The return address should be in the list of local IP addresses'
|
assert ip_address in ip4_list, 'The return address should be in the list of local IP addresses'
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ class TestInit(TestCase, TestMixin):
|
|||||||
Test the clean_filename() function
|
Test the clean_filename() function
|
||||||
"""
|
"""
|
||||||
# GIVEN: A invalid file name and the valid file name.
|
# GIVEN: A invalid file name and the valid file name.
|
||||||
invalid_name = 'A_file_with_invalid_characters_[\\/:\*\?"<>\|\+\[\]%].py'
|
invalid_name = 'A_file_with_invalid_characters_[\\/:\*\?"<>\|\+\[\]%].py' # nopep8
|
||||||
wanted_name = 'A_file_with_invalid_characters______________________.py'
|
wanted_name = 'A_file_with_invalid_characters______________________.py'
|
||||||
|
|
||||||
# WHEN: Clean the name.
|
# WHEN: Clean the name.
|
||||||
|
@ -99,7 +99,7 @@ class TestStartFileRenameForm(TestCase, TestMixin):
|
|||||||
# GIVEN: QLineEdit with a validator set with illegal file name characters.
|
# GIVEN: QLineEdit with a validator set with illegal file name characters.
|
||||||
|
|
||||||
# WHEN: 'Typing' a string containing invalid file characters.
|
# WHEN: 'Typing' a string containing invalid file characters.
|
||||||
QtTest.QTest.keyClicks(self.form.file_name_edit, 'I/n\\v?a*l|i<d> \F[i\l]e" :N+a%me')
|
QtTest.QTest.keyClicks(self.form.file_name_edit, r'I/n\\v?a*l|i<d> \F[i\l]e" :N+a%me')
|
||||||
|
|
||||||
# THEN: The text in the QLineEdit should be the same as the input string with the invalid characters filtered
|
# THEN: The text in the QLineEdit should be the same as the input string with the invalid characters filtered
|
||||||
# out.
|
# out.
|
||||||
|
Loading…
Reference in New Issue
Block a user