From e3f0bb768fbbf0ff65a478f0cb70848615fa6854 Mon Sep 17 00:00:00 2001 From: Michal Ambroz <723625+xambroz@users.noreply.github.com> Date: Fri, 15 Dec 2023 00:33:34 +0100 Subject: [PATCH] raw strings for regex Without fix the python 3.12 is throwing this error: $ python3 pdf-parser.py --version /home/mambroz/rpmbuild/BUILD/DidierStevensSuite-41b01df75c8bb332f37d2e9eb4c8279583164d0e/pdf-parser.py:1150: SyntaxWarning: invalid escape sequence '\s' print(' oPDF.stream(%d, %d, %s, %s)' % (objectId, object.version, repr(object.Stream(False, options.overridingfilters).rstrip()), repr(re.sub('/Length\s+\d+', '/Length %d', FormatOutput(dataPrecedingStream, True)).strip()))) /home/mambroz/rpmbuild/BUILD/DidierStevensSuite-41b01df75c8bb332f37d2e9eb4c8279583164d0e/pdf-parser.py:1161: SyntaxWarning: invalid escape sequence '\s' print(' oPDF.stream(%d, %d, %s, %s)' % (objectId, object.version, repr(object.Stream(False, options.overridingfilters).rstrip()), repr(re.sub('/Length\s+\d+', '/Length %d', FormatOutput(dataPrecedingStream, True)).strip()))) /home/mambroz/rpmbuild/BUILD/DidierStevensSuite-41b01df75c8bb332f37d2e9eb4c8279583164d0e/pdf-parser.py:1607: SyntaxWarning: invalid escape sequence '\d' if re.match('PDF-\d\.\d', comment): This program has not been tested with this version of Python (3.12.0) Should you encounter problems, please use Python version 3.11.1 pdf-parser.py 0.7.8 --- pdf-parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdf-parser.py b/pdf-parser.py index 1135c6a..f4b2405 100644 --- a/pdf-parser.py +++ b/pdf-parser.py @@ -1147,7 +1147,7 @@ def PrintGenerateObject(object, options, newId=None): if options.filter: decompressed = object.Stream(True, options.overridingfilters) if decompressed == 'No filters' or decompressed.startswith('Unsupported filter: '): - print(' oPDF.stream(%d, %d, %s, %s)' % (objectId, object.version, repr(object.Stream(False, options.overridingfilters).rstrip()), repr(re.sub('/Length\s+\d+', '/Length %d', FormatOutput(dataPrecedingStream, True)).strip()))) + print(' oPDF.stream(%d, %d, %s, %s)' % (objectId, object.version, repr(object.Stream(False, options.overridingfilters).rstrip()), repr(re.sub(r'/Length\s+\d+', '/Length %d', FormatOutput(dataPrecedingStream, True)).strip()))) else: dictionary = FormatOutput(dataPrecedingStream, True) dictionary = re.sub(r'/Length\s+\d+', '', dictionary) @@ -1158,7 +1158,7 @@ def PrintGenerateObject(object, options, newId=None): dictionary = dictionary.strip() print(" oPDF.stream2(%d, %d, %s, %s, 'f')" % (objectId, object.version, repr(decompressed.rstrip()), repr(dictionary))) else: - print(' oPDF.stream(%d, %d, %s, %s)' % (objectId, object.version, repr(object.Stream(False, options.overridingfilters).rstrip()), repr(re.sub('/Length\s+\d+', '/Length %d', FormatOutput(dataPrecedingStream, True)).strip()))) + print(' oPDF.stream(%d, %d, %s, %s)' % (objectId, object.version, repr(object.Stream(False, options.overridingfilters).rstrip()), repr(re.sub(r'/Length\s+\d+', '/Length %d', FormatOutput(dataPrecedingStream, True)).strip()))) else: print(' oPDF.indirectobject(%d, %d, %s)' % (objectId, object.version, repr(FormatOutput(object.content, True).strip())))