From d8f3db16a0abd508afbb0374cf353a7570684c78 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Thu, 29 Feb 2024 12:27:41 -0500 Subject: [PATCH] Small cleanups to the REP scripts. (#396) 1. Removes instances of /usr/bin/env python, which don't work on non-Linux and also were wrong in some cases. 2. Makes sure to use raw strings for regexes, which gets rid of some warnings with modern Python. 3. Uses '-f' when removing files to quite warnings. Signed-off-by: Chris Lalancette --- Makefile | 4 ++-- genrepindex.py | 1 - rep2html.py | 10 +++++----- xsdValid.py | 2 -- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 974d7048b..2e70234a1 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,8 @@ xsdvalid: $(PYTHON) xsdValid.py clean: - -rm *.html - -rm rep-0000.rst + -rm -f *.html + -rm -f rep-0000.rst upload: all rsync -r README.txt *.html mermaid.js css rep-0000.rst $(SUBDIRS) rosbot@ros.osuosl.org:/var/www/www.ros.org/reps diff --git a/genrepindex.py b/genrepindex.py index 68e614f5d..e57cf7910 100644 --- a/genrepindex.py +++ b/genrepindex.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.5 """Auto-generate REP 0 (REP index). Generating the REP index is a multi-step process. To begin, you must first diff --git a/rep2html.py b/rep2html.py index 905fb76f3..d49e365ac 100755 --- a/rep2html.py +++ b/rep2html.py @@ -70,9 +70,9 @@ ' "http://www.w3.org/TR/REC-html40/loose.dtd">') fixpat = re.compile( - "((https?|ftp):[-_a-zA-Z0-9/.+~:?#$=&,]+)|(rep-\d+(.rst)?)|" - "(RFC[- ]?(?P\d+))|" - "(REP\s+(?P\d+))|" + r"((https?|ftp):[-_a-zA-Z0-9/.+~:?#$=&,]+)|(rep-\d+(.rst)?)|" + r"(RFC[- ]?(?P\d+))|" + r"(REP\s+(?P\d+))|" ".") EMPTYSTRING = '' @@ -220,7 +220,7 @@ def fixfile(inpath, input_lines, outfile): for k, v in header: if k.lower() in ('author', 'discussions-to'): mailtos = [] - for part in re.split(',\s*', v): + for part in re.split(r',\s*', v): if '@' in part: realname, addr = parseaddr(part) if k.lower() == 'discussions-to': @@ -236,7 +236,7 @@ def fixfile(inpath, input_lines, outfile): v = COMMASPACE.join(mailtos) elif k.lower() in ('replaces', 'replaced-by', 'requires'): otherreps = '' - for otherrep in re.split(',?\s+', v): + for otherrep in re.split(r',?\s+', v): otherrep = int(otherrep) otherreps += '%i ' % (otherrep, otherrep) diff --git a/xsdValid.py b/xsdValid.py index 3bdefb905..404ac87ed 100755 --- a/xsdValid.py +++ b/xsdValid.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import xmlschema format1 = xmlschema.XMLSchema('xsd/package_format1.xsd')