3 commits - .gitlab-ci.yml m4/spice-deps.m4 meson.build python_modules/codegen.py python_modules/spice_parser.py spice_codegen.py
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Dec 16 18:47:54 UTC 2023
.gitlab-ci.yml | 2 +-
m4/spice-deps.m4 | 11 ++---------
meson.build | 2 +-
python_modules/codegen.py | 6 +-----
python_modules/spice_parser.py | 10 ++++------
spice_codegen.py | 17 ++++++-----------
6 files changed, 15 insertions(+), 33 deletions(-)
New commits:
commit 8c0319e31df967e41c74f4121cbdb3b785fe114e
Author: Chris Mayo <aklhfex at gmail.com>
Date: Wed Nov 2 19:29:56 2022 +0000
codegen: Use context manager when opening files
Signed-off-by: Chris Mayo <aklhfex at gmail.com>
Acked-by: Frediano Ziglio <freddy77 at gmail.com>
diff --git a/spice_codegen.py b/spice_codegen.py
index b45a7ef..7a860d7 100755
--- a/spice_codegen.py
+++ b/spice_codegen.py
@@ -108,9 +108,8 @@ def write_enums(writer, describe=False):
def write_content(dest_file, content, keep_identical_file):
if keep_identical_file:
try:
- f = open(dest_file, 'rb')
- old_content = f.read()
- f.close()
+ with open(dest_file, 'rb') as f:
+ old_content = f.read()
if content == old_content:
print("No changes to %s" % dest_file)
@@ -119,9 +118,8 @@ def write_content(dest_file, content, keep_identical_file):
except IOError:
pass
- f = open(dest_file, 'wb')
- f.write(bytes(content, 'UTF-8'))
- f.close()
+ with open(dest_file, 'wb') as f:
+ f.write(bytes(content, 'UTF-8'))
print("Wrote %s" % dest_file)
commit 29dacb5f53f5183fb089a3fb02d081dd08bde8a1
Author: Chris Mayo <aklhfex at gmail.com>
Date: Wed Nov 2 19:29:56 2022 +0000
Stop using Python six package
Signed-off-by: Chris Mayo <aklhfex at gmail.com>
Acked-by: Frediano Ziglio <freddy77 at gmail.com>
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4e4de75..877919b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,7 +3,7 @@ image: fedora:latest
before_script:
- >
dnf install git libtool make libasan
- python3 python3-six python3-pyparsing glib-networking
+ python3 python3-pyparsing glib-networking
meson ninja-build gdk-pixbuf2-devel
glib2-devel pixman-devel openssl-devel libjpeg-devel
libcacard-devel cyrus-sasl-devel lz4-devel opus-devel
diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index b5466e6..46e7729 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -153,14 +153,12 @@ AC_DEFUN([SPICE_CHECK_PYTHON_MODULES], [
if test "x$enable_python_checks" != "xno"; then
AS_IF([test -n "$PYTHON"], # already set required PYTHON version
[AM_PATH_PYTHON
- AX_PYTHON_MODULE([six], [1])
AX_PYTHON_MODULE([pyparsing], [1])],
[PYTHON=python3
- AX_PYTHON_MODULE([six])
AX_PYTHON_MODULE([pyparsing])
- test "$HAVE_PYMOD_SIX" = "yes" && test "$HAVE_PYMOD_PYPARSING" = "yes"],
+ test "$HAVE_PYMOD_PYPARSING" = "yes"],
[AM_PATH_PYTHON([3])],
- [AC_MSG_ERROR([Python modules six and pyparsing are required])])
+ [AC_MSG_ERROR([Python module pyparsing is required])])
else
AM_PATH_PYTHON
fi
diff --git a/meson.build b/meson.build
index 33f8f8a..e98119d 100644
--- a/meson.build
+++ b/meson.build
@@ -130,7 +130,7 @@ if spice_common_generate_client_code or spice_common_generate_server_code
python = py_module.find_installation('python3')
if get_option('python-checks')
- foreach module : ['six', 'pyparsing']
+ foreach module : ['pyparsing']
message('Checking for python module @0@'.format(module))
cmd = run_command(python, '-c', 'import @0@'.format(module), check : false)
if cmd.returncode() != 0
diff --git a/python_modules/codegen.py b/python_modules/codegen.py
index bfb2351..affe5bc 100644
--- a/python_modules/codegen.py
+++ b/python_modules/codegen.py
@@ -1,5 +1,4 @@
-import six
from io import StringIO
def camel_to_underscores(s, upper = False):
@@ -123,10 +122,7 @@ class CodeWriter:
def write(self, s):
# Ensure its a unicode string
- if six.PY3:
- s = str(s)
- else:
- s = unicode(s)
+ s = str(s)
if len(s) == 0:
return
diff --git a/python_modules/spice_parser.py b/python_modules/spice_parser.py
index 4d753cb..1dc7e22 100644
--- a/python_modules/spice_parser.py
+++ b/python_modules/spice_parser.py
@@ -1,11 +1,9 @@
-import six
-
try:
from pyparsing import Literal, CaselessLiteral, Word, OneOrMore, ZeroOrMore, \
Forward, delimitedList, Group, Optional, Combine, alphas, nums, restOfLine, cStyleComment, \
alphanums, ParseException, ParseResults, Keyword, StringEnd, replaceWith
except ImportError:
- six.print_("Module pyparsing not found.")
+ print("Module pyparsing not found.")
exit(1)
@@ -149,9 +147,9 @@ def parse(filename):
bnf = SPICE_BNF()
types = bnf.parseFile(filename)
except ParseException as err:
- six.print_(err.line, file=sys.stderr)
- six.print_(" "*(err.column-1) + "^", file=sys.stderr)
- six.print_(err, file=sys.stderr)
+ print(err.line, file=sys.stderr)
+ print(" "*(err.column-1) + "^", file=sys.stderr)
+ print(err, file=sys.stderr)
return None
for t in types:
diff --git a/spice_codegen.py b/spice_codegen.py
index d3a1bf5..b45a7ef 100755
--- a/spice_codegen.py
+++ b/spice_codegen.py
@@ -9,7 +9,7 @@ from python_modules import ptypes
from python_modules import codegen
from python_modules import demarshal
from python_modules import marshal
-import six
+
def write_channel_enums(writer, channel, client, describe):
messages = list(filter(lambda m : m.channel == channel, \
@@ -113,20 +113,17 @@ def write_content(dest_file, content, keep_identical_file):
f.close()
if content == old_content:
- six.print_("No changes to %s" % dest_file)
+ print("No changes to %s" % dest_file)
return
except IOError:
pass
f = open(dest_file, 'wb')
- if six.PY3:
- f.write(bytes(content, 'UTF-8'))
- else:
- f.write(content)
+ f.write(bytes(content, 'UTF-8'))
f.close()
- six.print_("Wrote %s" % dest_file)
+ print("Wrote %s" % dest_file)
parser = OptionParser(usage="usage: %prog [options] <protocol_file> <destination file>")
commit 91fc091358ac4906a05b68d70e9db94082c0749f
Author: Chris Mayo <aklhfex at gmail.com>
Date: Wed Nov 2 19:29:56 2022 +0000
Drop Python 2 from m4/spice-deps.m4
Signed-off-by: Chris Mayo <aklhfex at gmail.com>
Acked-by: Frediano Ziglio <freddy77 at gmail.com>
diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index 6a07ee6..b5466e6 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -160,11 +160,6 @@ AC_DEFUN([SPICE_CHECK_PYTHON_MODULES], [
AX_PYTHON_MODULE([pyparsing])
test "$HAVE_PYMOD_SIX" = "yes" && test "$HAVE_PYMOD_PYPARSING" = "yes"],
[AM_PATH_PYTHON([3])],
- [PYTHON=python2
- AX_PYTHON_MODULE([six])
- AX_PYTHON_MODULE([pyparsing])
- test "$HAVE_PYMOD_SIX" = "yes" && test "$HAVE_PYMOD_PYPARSING" = "yes"],
- [AM_PATH_PYTHON([2])],
[AC_MSG_ERROR([Python modules six and pyparsing are required])])
else
AM_PATH_PYTHON
More information about the Spice-commits
mailing list