Fix pep8 and pylint errors detected by new version.

bzr-revno: 2822
This commit is contained in:
Tomas Groth 2018-07-07 08:45:39 +02:00
commit 9c0f8d73e1
31 changed files with 67 additions and 62 deletions

View File

@ -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]

View File

@ -39,7 +39,7 @@ log = logging.getLogger(__name__)
def _route_to_regex(route): def _route_to_regex(route):
""" r"""
Convert a route to a regular expression Convert a route to a regular expression
For example: For example:

View File

@ -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)

View File

@ -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)

View File

@ -19,7 +19,7 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
""" r"""
This module is responsible for generating the HTML for :class:`~openlp.core.ui.maindisplay`. The ``build_html`` function This module is responsible for generating the HTML for :class:`~openlp.core.ui.maindisplay`. The ``build_html`` function
is the function which has to be called from outside. The generated and returned HTML will look similar to this:: is the function which has to be called from outside. The generated and returned HTML will look similar to this::
@ -416,7 +416,7 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, Vertic
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
HTML_SRC = Template(""" HTML_SRC = Template(r"""
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>

View File

@ -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))

View File

@ -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))

View File

@ -1126,7 +1126,7 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
# done by the thread holding the lock. If it is a "start" slide, we must wait for the lock, but only for 0.2 # done by the thread holding the lock. If it is a "start" slide, we must wait for the lock, but only for 0.2
# seconds, since we don't want to cause a deadlock # seconds, since we don't want to cause a deadlock
timeout = 0.2 if start else -1 timeout = 0.2 if start else -1
if not self.slide_selected_lock.acquire(start, timeout): if not self.slide_selected_lock.acquire(start, timeout): # pylint: disable=too-many-function-args
if start: if start:
self.log_debug('Could not get lock in slide_selected after waiting %f, skip to avoid deadlock.' self.log_debug('Could not get lock in slide_selected after waiting %f, skip to avoid deadlock.'
% timeout) % timeout)

View File

@ -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(

View File

@ -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})?' \
@ -255,7 +255,7 @@ def get_reference_match(match_type):
def parse_reference(reference, bible, language_selection, book_ref_id=False): def parse_reference(reference, bible, language_selection, book_ref_id=False):
""" r"""
This is the next generation über-awesome function that takes a person's typed in string and converts it to a list This is the next generation über-awesome function that takes a person's typed in string and converts it to a list
of references to be queried from the Bible database files. of references to be queried from the Bible database files.

View File

@ -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():

View File

@ -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)

View File

@ -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()))

View File

@ -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:

View File

@ -73,7 +73,7 @@ class DreamBeamImport(SongImport):
Valid extensions for a DreamBeam song file are: Valid extensions for a DreamBeam song file are:
* \*.xml * .xml
""" """
def do_import(self): def do_import(self):

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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()

View File

@ -70,7 +70,7 @@ class PowerSongImport(SongImport):
""" """
Checks if source is a PowerSong 1.0 folder: Checks if source is a PowerSong 1.0 folder:
* is a directory * is a directory
* contains at least one \*.song file * contains at least one * .song file
:param openlp.core.common.path.Path import_source: Should be a Path object that fulfills the above criteria :param openlp.core.common.path.Path import_source: Should be a Path object that fulfills the above criteria
:return: If the source is valid :return: If the source is valid

View File

@ -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:

View File

@ -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

View 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)

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -238,8 +238,8 @@ 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'
wanted_name = 'A_file_with_invalid_characters______________________.py' wanted_name = 'A_file_with_invalid_characters________________.py'
# WHEN: Clean the name. # WHEN: Clean the name.
result = clean_filename(invalid_name) result = clean_filename(invalid_name)

View File

@ -12,7 +12,7 @@ from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_
from openlp.core.lib.theme import HorizontalType, VerticalType from openlp.core.lib.theme import HorizontalType, VerticalType
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
HTML = """ HTML = r"""
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -121,7 +121,7 @@ HTML = """
} }
function show_text(new_text){ function show_text(new_text){
var match = /-webkit-text-fill-color:[^;"]+/gi; var match = /-webkit-text-fill-color:[^;\"]+/gi;
if(timer != null) if(timer != null)
clearTimeout(timer); clearTimeout(timer);
/* /*

View File

@ -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.

View File

@ -68,7 +68,7 @@ class TestPylint(TestCase):
# WHEN: Running pylint # WHEN: Running pylint
(pylint_stdout, pylint_stderr) = \ (pylint_stdout, pylint_stderr) = \
lint.py_run('openlp --errors-only --disable={disabled} --enable={enabled} ' lint.py_run('openlp --errors-only -j 4 --disable={disabled} --enable={enabled} '
'--reports=no --output-format=parseable'.format(disabled=disabled_checks, '--reports=no --output-format=parseable'.format(disabled=disabled_checks,
enabled=enabled_checks), enabled=enabled_checks),
**pylint_kwargs) **pylint_kwargs)
@ -88,7 +88,7 @@ class TestPylint(TestCase):
filtered_output = '' filtered_output = ''
for line in pylint_output.splitlines(): for line in pylint_output.splitlines():
# Filter out module info lines # Filter out module info lines
if line.startswith('**'): if '***' in line:
continue continue
# Filter out undefined-variable error releated to WindowsError # Filter out undefined-variable error releated to WindowsError
elif 'undefined-variable' in line and 'WindowsError' in line: elif 'undefined-variable' in line and 'WindowsError' in line: