From 1a668caa50427636ae87e65ffd368cb8ebad2d29 Mon Sep 17 00:00:00 2001 From: Patrick Hoffmann Date: Wed, 18 Apr 2018 22:40:35 +0200 Subject: [PATCH 1/4] fixed W605 invalid escape sequence put 'r' in front of regexp strings like described in: https://github.com/PyCQA/pycodestyle/commit/13d2bd200911850dacde31665235122d85290265 --- voctocore/lib/sources/decklinkavsource.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/voctocore/lib/sources/decklinkavsource.py b/voctocore/lib/sources/decklinkavsource.py index 7a1303bc..bfd326a8 100644 --- a/voctocore/lib/sources/decklinkavsource.py +++ b/voctocore/lib/sources/decklinkavsource.py @@ -8,6 +8,7 @@ class DeckLinkAVSource(AVSource): + def __init__(self, name, outputs=None, has_audio=True, has_video=True): self.log = logging.getLogger('DecklinkAVSource[{}]'.format(name)) super().__init__(name, outputs, has_audio, has_video) @@ -94,7 +95,7 @@ def _parse_audiostream_map(self, config_section): for key in Config[config_section]: value = Config.get(config_section, key) - m = re.match('audiostream\[(\d+)\]', key) + m = re.match(r'audiostream\[(\d+)\]', key) if m: audiostream = int(m.group(1)) audiostream_map[audiostream] = value @@ -102,7 +103,7 @@ def _parse_audiostream_map(self, config_section): return audiostream_map def _parse_audiostream_mapping(self, mapping): - m = re.match('(\d+)\+(\d+)', mapping) + m = re.match(r'(\d+)\+(\d+)', mapping) if m: return (int(m.group(1)), int(m.group(2)),) else: From f0e7b4f6b0fb9d4fbdfebb29a150b43644f17e97 Mon Sep 17 00:00:00 2001 From: Patrick Hoffmann Date: Wed, 18 Apr 2018 22:47:07 +0200 Subject: [PATCH 2/4] fixed W504 line break after binary operator Removed by using '\' for line breaks Note by the way: I'm currently not familiar with the consequences of mixing binary and logical operators in python conditions. But I will investigate this case ;) --- voctocore/voctocore.py | 4 ++-- voctogui/lib/videodisplay.py | 4 ++-- voctogui/voctogui.py | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/voctocore/voctocore.py b/voctocore/voctocore.py index f80905a6..fe59bb2b 100755 --- a/voctocore/voctocore.py +++ b/voctocore/voctocore.py @@ -70,8 +70,8 @@ def main(): args.parse() from lib.args import Args - docolor = (Args.color == 'always') or (Args.color == 'auto' and - sys.stderr.isatty()) + docolor = (Args.color == 'always') \ + or (Args.color == 'auto' and sys.stderr.isatty()) handler = LogHandler(docolor, Args.timestamp) logging.root.addHandler(handler) diff --git a/voctogui/lib/videodisplay.py b/voctogui/lib/videodisplay.py index 0714f80c..36eba206 100644 --- a/voctogui/lib/videodisplay.py +++ b/voctogui/lib/videodisplay.py @@ -21,8 +21,8 @@ def __init__(self, drawing_area, port, width=None, height=None, else: previewcaps = Config.get('mix', 'videocaps') - use_previews = (Config.getboolean('previews', 'enabled') and - Config.getboolean('previews', 'use')) + use_previews = Config.getboolean('previews', 'enabled') \ + and Config.getboolean('previews', 'use') # Preview-Ports are Raw-Ports + 1000 if use_previews: diff --git a/voctogui/voctogui.py b/voctogui/voctogui.py index f20889a8..4f23fbb0 100755 --- a/voctogui/voctogui.py +++ b/voctogui/voctogui.py @@ -34,6 +34,7 @@ # main class class Voctogui(object): + def __init__(self): self.log = logging.getLogger('Voctogui') from lib.args import Args @@ -123,8 +124,8 @@ def main(): args.parse() from lib.args import Args - docolor = (Args.color == 'always') or (Args.color == 'auto' and - sys.stderr.isatty()) + docolor = (Args.color == 'always') \ + or (Args.color == 'auto' and sys.stderr.isatty()) from lib.loghandler import LogHandler handler = LogHandler(docolor, Args.timestamp) @@ -165,8 +166,8 @@ def main(): # The list-comparison is not complete # (one could use a local hostname or the local system ip), # but it's only here to warn that one might be making a mistake - use_previews = (Config.getboolean('previews', 'enabled') and - Config.getboolean('previews', 'use')) + use_previews = Config.getboolean('previews', 'enabled') \ + and Config.getboolean('previews', 'use') looks_like_localhost = Config.get('server', 'host') in ['::1', '127.0.0.1', 'localhost'] From 78c67359f3f7ff7b5d26ffa35f2e746d106bd473 Mon Sep 17 00:00:00 2001 From: Patrick Hoffmann Date: Wed, 18 Apr 2018 22:55:58 +0200 Subject: [PATCH 3/4] fixed W605 invalid escape sequence (within stings) used double backslash to encode backslash REVIEW: I'm not really sure about this one! Currently not able to test. --- voctocore/tests/helper/voctomix_test.py | 2 +- voctogui/lib/connection.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/voctocore/tests/helper/voctomix_test.py b/voctocore/tests/helper/voctomix_test.py index e19a865e..077f3ad3 100644 --- a/voctocore/tests/helper/voctomix_test.py +++ b/voctocore/tests/helper/voctomix_test.py @@ -22,7 +22,7 @@ def setUp(self): lib.config.Config.resetToDefaults() def assertContainsIgnoringWhitespace(self, text, search): - regex = search.replace(" ", "\s*") + regex = search.replace(" ", "\\s*") try: self.assertRegex(text, regex) diff --git a/voctogui/lib/connection.py b/voctogui/lib/connection.py index 86830787..da1219ec 100644 --- a/voctogui/lib/connection.py +++ b/voctogui/lib/connection.py @@ -17,7 +17,7 @@ def establish(host): log.info('establishing Connection to %s', host) conn = socket.create_connection((host, port)) - log.debug('Connection successful \o/') + log.debug('Connection successful \\o/') ip = conn.getpeername()[0] log.debug('Remote-IP is %s', ip) From 2e7e4fdca29c355a4449efdadcc6ee7955fec0fb Mon Sep 17 00:00:00 2001 From: Patrick Hoffmann Date: Mon, 23 Apr 2018 08:54:52 +0200 Subject: [PATCH 4/4] fixup: fixed W605 invalid escape sequence (within stings) use raw string notation to express escape sequences --- voctocore/tests/helper/voctomix_test.py | 2 +- voctogui/lib/connection.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/voctocore/tests/helper/voctomix_test.py b/voctocore/tests/helper/voctomix_test.py index 077f3ad3..29d97aa8 100644 --- a/voctocore/tests/helper/voctomix_test.py +++ b/voctocore/tests/helper/voctomix_test.py @@ -22,7 +22,7 @@ def setUp(self): lib.config.Config.resetToDefaults() def assertContainsIgnoringWhitespace(self, text, search): - regex = search.replace(" ", "\\s*") + regex = search.replace(" ", r"\s*") try: self.assertRegex(text, regex) diff --git a/voctogui/lib/connection.py b/voctogui/lib/connection.py index da1219ec..caddbe2c 100644 --- a/voctogui/lib/connection.py +++ b/voctogui/lib/connection.py @@ -17,7 +17,7 @@ def establish(host): log.info('establishing Connection to %s', host) conn = socket.create_connection((host, port)) - log.debug('Connection successful \\o/') + log.debug(r'Connection successful \o/') ip = conn.getpeername()[0] log.debug('Remote-IP is %s', ip)