From 65ecf06f5df60e117e2acafe078cb5367dceed66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 21 Jul 2020 10:28:54 +0200 Subject: [PATCH] fix package description generation script to be compatible with python 2 and 3 --- Documentation/doc/scripts/pkglist_filter | 8 +------- Documentation/doc/scripts/pkglist_filter.bat | 14 +------------- Documentation/doc/scripts/pkglist_filter.py | 12 +++++++++--- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/Documentation/doc/scripts/pkglist_filter b/Documentation/doc/scripts/pkglist_filter index 4c930d5edc9..2ec8ce96c9b 100755 --- a/Documentation/doc/scripts/pkglist_filter +++ b/Documentation/doc/scripts/pkglist_filter @@ -1,9 +1,3 @@ #!/bin/sh -if which python2 2>/dev/null >/dev/null; then - exec python2 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1" -elif which python2.7 2>/dev/null >/dev/null; then - exec python2.7 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1" -elif which python2.6 2>/dev/null >/dev/null; then - exec python2.6 ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1" -fi +exec ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/pkglist_filter.py "$1" diff --git a/Documentation/doc/scripts/pkglist_filter.bat b/Documentation/doc/scripts/pkglist_filter.bat index 4d8cccb9524..83dff1aa121 100644 --- a/Documentation/doc/scripts/pkglist_filter.bat +++ b/Documentation/doc/scripts/pkglist_filter.bat @@ -1,18 +1,6 @@ @echo off -@where /q python -if not errorlevel 1 ( set python=python ) - -@where /q python2 -if not errorlevel 1 ( set python=python2 ) - -@where /q python2.6 -if not errorlevel 1 ( set python=python2.6 ) - -@where /q python2.7 -if not errorlevel 1 ( set python=python2.7 ) - :go -%python% ${CMAKE_BINARY_DIR}/pkglist_filter.py %1 +${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/pkglist_filter.py %1 @echo on diff --git a/Documentation/doc/scripts/pkglist_filter.py b/Documentation/doc/scripts/pkglist_filter.py index 3a5e75d4f75..af99777d529 100755 --- a/Documentation/doc/scripts/pkglist_filter.py +++ b/Documentation/doc/scripts/pkglist_filter.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import codecs import re @@ -28,10 +28,16 @@ def main(argv): for l in pkgdesc: do_print = do_print or re.match(".*cgalPkgDescriptionBegin.*", l) if(do_print): - sys.stdout.write(l.encode('utf-8')) + if hasattr(sys.stdout, 'buffer'): + sys.stdout.buffer.write(l.encode('utf-8')) #python3 + else: + sys.stdout.write(l.encode('utf-8')) #python2 do_print = do_print and (not re.match(".*cgalPkgDescriptionEnd.*", l)) else: - sys.stdout.write(line.encode('utf-8')) + if hasattr(sys.stdout, 'buffer'): + sys.stdout.buffer.write(line.encode('utf-8')) #python3 + else: + sys.stdout.write(line.encode('utf-8')) #python2 if __name__ == "__main__": main(sys.argv)