From 92435561f65da83fb7c75dfe4845c6aafd91e12d Mon Sep 17 00:00:00 2001 From: Murray Fordyce Date: Mon, 3 Oct 2022 14:21:21 -0500 Subject: [PATCH] Prevent colon confusion in output parsing By use a magic string that shouldn't appear in code, we make parsing easier. Really we should use a parser or something; but, this is an easy enough fix. Fixes #20 --- pycodestyle_magic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pycodestyle_magic.py b/pycodestyle_magic.py index 06cd812..f4a4935 100644 --- a/pycodestyle_magic.py +++ b/pycodestyle_magic.py @@ -162,7 +162,8 @@ def pycodestyle(line, cell, auto=False): f.close() # now we can check the file by name. # we might be able to use 'stdin', have to check implementation - format = '%(row)d:%(col)d: %(code)s %(text)s' + format_divider = 'FORMAT_DIVIDER' + format = format_divider+'%(row)d'+format_divider+'%(col)d'+format_divider+' %(code)s %(text)s' pycodestyle = pycodestyle_module.StyleGuide(format=format) # check the filename pcs_result = pycodestyle.check_files(paths=[f.name]) @@ -171,8 +172,7 @@ def pycodestyle(line, cell, auto=False): for line in stdout: #logger.info(line) - # on windows drive path also contains : - line, col, error = line.split(':')[-4:] + line, col, error = line.split(format_divider,4)[1:] # do not subtract 1 for line for %%pycodestyle, inc pre py3.6 string if auto: add = -1