File remove-six.patch of Package lasso
From dd581fc3c4d67bbe072db43c50b3cf54030030aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Wed, 28 Aug 2024 17:25:03 +0200
Subject: [PATCH] misc: remove usage of python six module (#94580)
---
INSTALL | 3
bindings/bindings.py | 29
bindings/perl/lang.py | 15
bindings/php5/php_code.py | 173 ++---
bindings/php5/wrapper_header.py | 9
bindings/php5/wrapper_source.py | 249 +++----
bindings/php7/php_code.py | 167 ++---
bindings/php7/wrapper_header.py | 9
bindings/php7/wrapper_source.py | 253 ++++----
bindings/python/examples/get_attributes_from_assertion.py | 5
bindings/python/lang.py | 439 ++++++--------
bindings/python/tests/XmlTestRunner.py | 14
bindings/python/tests/tests.py | 19
configure.ac | 2
lasso/build_strerror.py | 10
lasso/extract_sections.py | 29
lasso/extract_symbols.py | 5
lasso/extract_types.py | 27
lasso/id-ff/provider.h | 2
lasso/registry-private.h | 2
lasso/utils.h | 10
tools/api.py | 15
tools/check-lasso-sections.py | 11
tools/format-suppressions.py | 11
24 files changed, 740 insertions(+), 768 deletions(-)
Index: lasso-2.8.2/INSTALL
===================================================================
--- lasso-2.8.2.orig/INSTALL 2020-12-17 10:22:08.718894940 +0100
+++ lasso-2.8.2/INSTALL 2025-06-18 21:27:46.765240980 +0200
@@ -26,9 +26,6 @@
aptitude install libxml2-dev libxslt1-dev libxmlsec1-dev libxmlsec1-openssl \
libglib2.0-dev python-all-dev fastjar php5-dev php5-cli python-lxml
-Python bindings require the "six" library:
-
- pip install six
Basic Installation
==================
Index: lasso-2.8.2/bindings/bindings.py
===================================================================
--- lasso-2.8.2.orig/bindings/bindings.py 2025-06-18 21:27:17.234890175 +0200
+++ lasso-2.8.2/bindings/bindings.py 2025-06-18 21:27:46.765574546 +0200
@@ -23,16 +23,9 @@
import os
import re
-from six import print_, PY3
import sys
from utils import *
-if PY3:
- do_open = lambda *args, **kwargs: open(*args, encoding='utf-8', **kwargs)
-else:
- do_open = open
-
-
from optparse import OptionParser
try:
@@ -166,10 +159,10 @@
if not 'Makefile.am' in filenames:
# not a source dir
continue
- makefile_am = do_open(os.path.join(base, 'Makefile.am')).read()
+ makefile_am = open(os.path.join(base, 'Makefile.am')).read()
filenames = [x for x in filenames if x.endswith('.c') if x in makefile_am]
for filename in filenames:
- s = do_open(os.path.join(base, filename)).read()
+ s = open(os.path.join(base, filename)).read()
docstrings = regex.findall(s)
for d in docstrings:
docstring = '\n'.join([x[3:] for x in d.splitlines()])
@@ -247,7 +240,7 @@
try:
arg = [x for x in self.args if x[1] == param.attrib.get('name')][0]
except IndexError:
- print_('W: no such param (%s) in function (%s)' % (
+ print('W: no such param (%s) in function (%s)' % (
param.attrib.get('name'), self.name), file=sys.stderr)
continue
if param.attrib.get('optional') == 'true':
@@ -410,7 +403,7 @@
in_struct_private = False
in_ifdef_zero = False
- lines = do_open(header_file).readlines()
+ lines = open(header_file).readlines()
i = 0
while i < len(lines):
line = lines[i]
@@ -435,7 +428,7 @@
enum_name = line[2:].strip().strip(';')
binding.enums.append(enum_name)
else:
- m = re.match('\s*([a-zA-Z0-9_]+)', line)
+ m = re.match(r'\s*([a-zA-Z0-9_]+)', line)
if m:
binding.constants.append(('i', m.group(1)))
elif line.startswith('#define'):
@@ -475,7 +468,7 @@
if not in_struct.name in binding.structs_toskip:
binding.structs.append(in_struct)
else:
- print_('W: skipping structure %s due to overrides.xml' % in_struct.name, file=sys.stderr)
+ print('W: skipping structure %s due to overrides.xml' % in_struct.name, file=sys.stderr)
in_struct = None
elif '/*< public >*/' in line:
in_struct_private = False
@@ -489,13 +482,13 @@
# TODO: Add parsing of OFTYPE
# Transform struct to typedef
# example: "struct _LassoAssertion" -> "LassoAssertion"
- line = re.sub('\s+struct _', ' ', line)
- member_match = re.match('\s+(\w+)\s+(\*?\w+)', line)
+ line = re.sub(r'\s+struct _', ' ', line)
+ member_match = re.match(r'\s+(\w+)\s+(\*?\w+)', line)
if member_match:
member_type, member_name = normalise_var(member_match.group(1), member_match.group(2))
field = (member_type, member_name, {})
if member_type == 'void*':
- print_('W: skipping field %s.%s' % (in_struct.name, member_name), file=sys.stderr)
+ print('W: skipping field %s.%s' % (in_struct.name, member_name), file=sys.stderr)
else:
if is_glist(field) or is_hashtable(field):
found = re.search(r' of ([^*]*)', line)
@@ -544,13 +537,13 @@
type = clean_type(type)
f.args.append(list((type, name, {})))
else:
- print_('failed to process:', arg, 'in line:', line, file=sys.stderr)
+ print('failed to process:', arg, 'in line:', line, file=sys.stderr)
f.skip = True
f.apply_overrides()
if not f.skip:
binding.functions.append(f)
else:
- print_('W: skipping function', f, file=sys.stderr)
+ print('W: skipping function', f, file=sys.stderr)
i += 1
Index: lasso-2.8.2/bindings/perl/lang.py
===================================================================
--- lasso-2.8.2.orig/bindings/perl/lang.py 2021-09-11 19:20:25.848637964 +0200
+++ lasso-2.8.2/bindings/perl/lang.py 2025-06-18 21:27:46.765998487 +0200
@@ -22,20 +22,19 @@
import os.path
import sys
import re
-from six import print_
from utils import *
-class Output(object):
+class Output:
def __init__(self, filename, indent = 4):
self.fd = open(filename, 'w')
self.indent_stack = [0]
self.indent_size = indent
def pn(self, s = ''):
- print_((' ' * self.indent_stack[-1]) + s, file=self.fd)
+ print((' ' * self.indent_stack[-1]) + s, file=self.fd)
def p(self, s = ''):
- print_(s, file=self.fd, end="")
+ print(s, file=self.fd, end="")
def close(self):
self.fd.close()
@@ -277,7 +276,7 @@
try:
self.xs.pn(self.glist_type(func.return_arg))
except:
- print_('failed', func.return_arg, func, file=sys.stderr)
+ print('failed', func.return_arg, func, file=sys.stderr)
raise
self.xs.p(name + '(')
arg_list = []
@@ -448,7 +447,7 @@
kind = "objects"
else:
kind = "strings"
- self.xs.pn('''
+ self.xs.pn(r'''
HV*
%(field)s(%(clss)s* obj, ...)
PROTOTYPE:
@@ -587,12 +586,12 @@
self.generate_xs_function(func, prefix = prefix)
for member in struct.members:
if arg_type(member) == 'void*':
- print_('Skipping %s' % member)
+ print('Skipping %s' % member)
continue
try:
self.generate_xs_getter_setter(struct, member)
except:
- print_('failed', struct, member)
+ print('failed', struct, member)
raise
def generate_wrapper(self):
Index: lasso-2.8.2/bindings/php5/php_code.py
===================================================================
--- lasso-2.8.2.orig/bindings/php5/php_code.py 2021-09-11 19:20:25.848637964 +0200
+++ lasso-2.8.2/bindings/php5/php_code.py 2025-06-18 21:27:46.766309493 +0200
@@ -20,7 +20,6 @@
import re
import sys
-import six
from utils import *
@@ -40,7 +39,7 @@
self.generate_footer()
def generate_header(self):
- six.print_('''\
+ print('''\
<?php
/* this file has been generated automatically; do not edit */
@@ -108,27 +107,27 @@
else:
inheritence = ' extends LassoObject'
- six.print_('/**', file=self.fd)
- six.print_(' * @package Lasso', file=self.fd)
- six.print_(' */', file=self.fd)
- six.print_('class %(class_name)s%(inheritence)s {' % locals(), file=self.fd)
+ print('/**', file=self.fd)
+ print(' * @package Lasso', file=self.fd)
+ print(' */', file=self.fd)
+ print('class %(class_name)s%(inheritence)s {' % locals(), file=self.fd)
if klass.members or klass.methods:
self.generate_constructors(klass)
self.generate_getters_and_setters(klass)
self.generate_methods(klass)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
# Add a special class to get an object instance without initialising
- six.print_('/**', file=self.fd)
- six.print_(' * @package Lasso', file=self.fd)
- six.print_(' */', file=self.fd)
- six.print_('class %(class_name)sNoInit extends %(class_name)s {' % locals(), file=self.fd)
- six.print_(' public function __construct() {}', file=self.fd)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('/**', file=self.fd)
+ print(' * @package Lasso', file=self.fd)
+ print(' */', file=self.fd)
+ print('class %(class_name)sNoInit extends %(class_name)s {' % locals(), file=self.fd)
+ print(' public function __construct() {}', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_constructors(self, klass):
method_prefix = format_as_underscored(klass.name) + '_'
@@ -153,13 +152,13 @@
c_args = ', '.join(c_args)
# XXX: could check $this->_cptr->typename to see if it got the
# right class type
- six.print_(' public $_cptr = null;', file=self.fd)
- six.print_('', file=self.fd)
- six.print_(' public function __construct(%s) {' % php_args, file=self.fd)
- six.print_(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd)
- six.print_(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' public $_cptr = null;', file=self.fd)
+ print('', file=self.fd)
+ print(' public function __construct(%s) {' % php_args, file=self.fd)
+ print(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd)
+ print(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
elif name.startswith(method_prefix) and m.args \
and clean_type(unconstify(m.args[0][0])) != klass.name:
@@ -186,10 +185,10 @@
c_args.append('$%s' % arg_name)
php_args = ', '.join(php_args)
c_args = ', '.join(c_args)
- six.print_(' public static function %s(%s) {' % (php_name, php_args), file=self.fd)
- six.print_(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' public static function %s(%s) {' % (php_name, php_args), file=self.fd)
+ print(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
@@ -201,50 +200,50 @@
'class': c.name
}
- six.print_('''\
+ print('''\
/**
* @return %(docstring)s
*/
protected function get_%(name)s() {''' % d, file=self.fd)
- six.print_(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd)
+ print(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd)
if self.is_object(m):
- six.print_(' $t = cptrToPhp($t);', file=self.fd)
+ print(' $t = cptrToPhp($t);', file=self.fd)
elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)):
- six.print_(' foreach ($t as $key => $item) {', file=self.fd)
- six.print_(' $t[$key] = cptrToPhp($item);', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' foreach ($t as $key => $item) {', file=self.fd)
+ print(' $t[$key] = cptrToPhp($item);', file=self.fd)
+ print(' }', file=self.fd)
elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \
or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \
or is_boolean(m) or is_cstring(m) or is_xml_node(m):
pass
else:
raise Exception('Cannot generate a Php getter %s.%s' % (c,m))
- six.print_(' return $t;', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' return $t;', file=self.fd)
+ print(' }', file=self.fd)
def generate_setter(self, c, m):
d = { 'type': arg_type(m), 'name': format_as_camelcase(arg_name(m)),
'docstring': self.get_docstring_return_type(arg_type(m)), 'class': c.name }
- six.print_(' protected function set_%(name)s($value) {' % d, file=self.fd)
+ print(' protected function set_%(name)s($value) {' % d, file=self.fd)
if self.is_object(m):
- six.print_(' $value = $value->_cptr;', file=self.fd)
+ print(' $value = $value->_cptr;', file=self.fd)
elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)):
- six.print_(' $array = array();', file=self.fd)
- six.print_(' if (!is_null($value)) {', file=self.fd)
- six.print_(' foreach ($value as $key => $item) {', file=self.fd)
- six.print_(' $array[$key] = $item->_cptr;', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' $value = $array;', file=self.fd)
+ print(' $array = array();', file=self.fd)
+ print(' if (!is_null($value)) {', file=self.fd)
+ print(' foreach ($value as $key => $item) {', file=self.fd)
+ print(' $array[$key] = $item->_cptr;', file=self.fd)
+ print(' }', file=self.fd)
+ print(' }', file=self.fd)
+ print(' $value = $array;', file=self.fd)
elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \
or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \
or is_boolean(m) or is_cstring(m) or is_xml_node(m):
pass
else:
raise Exception('Cannot generate a Php setter %s.%s' % (c,m))
- six.print_(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
def generate_getters_and_setters(self, klass):
for m in klass.members:
@@ -272,27 +271,27 @@
mname = re.match(r'lasso_.*_get_(\w+)', meth_name).group(1)
mname = format_as_camelcase(mname)
- six.print_(' /**', file=self.fd)
- six.print_(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd)
- six.print_(' */', file=self.fd)
- six.print_(' protected function get_%s() {' % mname, file=self.fd)
+ print(' /**', file=self.fd)
+ print(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd)
+ print(' */', file=self.fd)
+ print(' protected function get_%s() {' % mname, file=self.fd)
if self.is_object(m.return_type):
- six.print_(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd)
- six.print_(' if (! is_null($cptr)) {', file=self.fd)
- six.print_(' return cptrToPhp($cptr);', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' return null;', file=self.fd)
+ print(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd)
+ print(' if (! is_null($cptr)) {', file=self.fd)
+ print(' return cptrToPhp($cptr);', file=self.fd)
+ print(' }', file=self.fd)
+ print(' return null;', file=self.fd)
else:
- six.print_(' return %s($this->_cptr);' % meth_name, file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' return %s($this->_cptr);' % meth_name, file=self.fd)
+ print(' }', file=self.fd)
if setter:
- six.print_(' protected function set_%s($value) {' % mname, file=self.fd)
+ print(' protected function set_%s($value) {' % mname, file=self.fd)
if self.is_object(m.return_type):
- six.print_(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd)
+ print(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd)
else:
- six.print_(' %s($this->_cptr, $value);' % setter.name, file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' %s($this->_cptr, $value);' % setter.name, file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
# second pass on methods, real methods
method_prefix = format_as_underscored(klass.name) + '_'
@@ -301,7 +300,7 @@
m.name.endswith('_new_full'):
continue
if not m.name.startswith(method_prefix):
- six.print_('W:', m.name, 'vs', method_prefix, file=sys.stderr)
+ print('W:', m.name, 'vs', method_prefix, file=sys.stderr)
continue
if m.rename:
@@ -327,7 +326,7 @@
elif defval.startswith('b:'): # boolean
php_args.append('%s = %s' % (arg_name, defval[2:]))
else:
- six.print_("E: don't know what to do with %s" % defval, file=sys.stderr)
+ print("E: don't know what to do with %s" % defval, file=sys.stderr)
sys.exit(1)
else:
php_args.append('%s = null' % arg_name)
@@ -357,26 +356,26 @@
c_args = ''
if m.docstring:
- six.print_(self.generate_docstring(m, mname, 4), file=self.fd)
- six.print_(' public function %s(%s) {' % (
+ print(self.generate_docstring(m, mname, 4), file=self.fd)
+ print(' public function %s(%s) {' % (
format_underscore_as_camelcase(mname), php_args), file=self.fd)
if m.return_type == 'void':
- six.print_(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
+ print(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
elif is_rc(m.return_type):
- six.print_(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
- six.print_(' if ($rc == 0) {', file=self.fd)
- six.print_(' return 0;', file=self.fd)
- six.print_(' } else if ($rc > 0) {', file=self.fd) # recoverable error
- six.print_(' return $rc;', file=self.fd)
- six.print_(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error
- six.print_(' LassoError::throw_on_rc($rc);', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
+ print(' if ($rc == 0) {', file=self.fd)
+ print(' return 0;', file=self.fd)
+ print(' } else if ($rc > 0) {', file=self.fd) # recoverable error
+ print(' return $rc;', file=self.fd)
+ print(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error
+ print(' LassoError::throw_on_rc($rc);', file=self.fd)
+ print(' }', file=self.fd)
else:
- six.print_(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
- six.print_('', file=self.fd)
+ print('', file=self.fd)
def generate_docstring(self, func, method_name, indent):
docstring = func.docstring.orig_docstring
@@ -393,7 +392,7 @@
elif type == '%': # %TRUE, %FALSE
if var in ('TRUE', 'FALSE'):
return var
- six.print_('W: unknown docstring thingie \'%s\' in \'%s\'' % (s.group(1), func.docstring.orig_docstring),
+ print('W: unknown docstring thingie \'%s\' in \'%s\'' % (s.group(1), func.docstring.orig_docstring),
file=sys.stderr)
elif type == '@':
if var == first_arg_name:
@@ -437,7 +436,7 @@
cat = exc_cat.attrib.get('name')
done_cats.append(cat)
parent_cat = exc_cat.attrib.get('parent', '')
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -462,7 +461,7 @@
else:
parent_cat = ''
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -470,7 +469,7 @@
''' % (cat, parent_cat), file=self.fd)
if detail not in exceptions_dict:
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -480,7 +479,7 @@
''' % (detail, cat, c[1]), file=self.fd)
exceptions_dict[detail] = c[1]
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -488,9 +487,9 @@
private static $exceptions_dict = array(''', file=self.fd)
for k, v in exceptions_dict.items():
- six.print_(' %s => "Lasso%sError",' % (v, k), file=self.fd)
+ print(' %s => "Lasso%sError",' % (v, k), file=self.fd)
- six.print_('''\
+ print('''\
);
public static function throw_on_rc($rc) {
@@ -504,6 +503,6 @@
''', file=self.fd)
def generate_footer(self):
- six.print_('''\
+ print('''\
?>''', file=self.fd)
Index: lasso-2.8.2/bindings/php5/wrapper_header.py
===================================================================
--- lasso-2.8.2.orig/bindings/php5/wrapper_header.py 2020-12-17 10:22:08.726895006 +0100
+++ lasso-2.8.2/bindings/php5/wrapper_header.py 2025-06-18 21:27:46.766674767 +0200
@@ -17,7 +17,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-import six
class WrapperHeader:
def __init__(self, binding_data, fd, functions_list):
@@ -32,7 +31,7 @@
def generate_header(self):
# FIXME: Get the current version and name
- six.print_('''\
+ print('''\
/* this file has been generated automatically; do not edit */
#include "../../config.h"
@@ -51,11 +50,11 @@
def generate_functions_list(self):
for m in self.functions_list:
- six.print_('PHP_FUNCTION(%s);' % m, file=self.fd)
- six.print_('', file=self.fd)
+ print('PHP_FUNCTION(%s);' % m, file=self.fd)
+ print('', file=self.fd)
def generate_footer(self):
- six.print_('''\
+ print('''\
extern zend_module_entry lasso_module_entry;
#define phpext_lasso_ptr &lasso_module_entry
Index: lasso-2.8.2/bindings/php5/wrapper_source.py
===================================================================
--- lasso-2.8.2.orig/bindings/php5/wrapper_source.py 2021-05-17 22:00:09.035310519 +0200
+++ lasso-2.8.2/bindings/php5/wrapper_source.py 2025-06-18 21:27:46.766910973 +0200
@@ -20,7 +20,6 @@
import sys
import os
-import six
from utils import *
@@ -53,17 +52,17 @@
self.functions_list.append('lasso_init')
self.functions_list.append('lasso_shutdown')
- six.print_('''\
+ print('''\
/* this file has been generated automatically; do not edit */
''', file=self.fd)
- six.print_(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd)
+ print(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd)
for h in self.binding_data.headers:
- six.print_('#include <%s>' % h, file=self.fd)
- six.print_('', file=self.fd)
+ print('#include <%s>' % h, file=self.fd)
+ print('', file=self.fd)
- six.print_('''\
+ print('''\
PHP_MINIT_FUNCTION(lasso)
{
le_lasso_server = zend_register_list_destructors_ex(php_gobject_generic_destructor, NULL, PHP_LASSO_SERVER_RES_NAME, module_number);
@@ -71,25 +70,25 @@
''', file=self.fd)
def generate_constants(self):
- six.print_(' /* Constants (both enums and defines) */', file=self.fd)
+ print(' /* Constants (both enums and defines) */', file=self.fd)
for c in self.binding_data.constants:
if c[0] == 'i':
- six.print_(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
+ print(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
elif c[0] == 's':
- six.print_(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
+ print(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
elif c[0] == 'b':
- six.print_('''\
+ print('''\
#ifdef %s
REGISTER_LONG_CONSTANT("%s", 1, CONST_CS|CONST_PERSISTENT);
#else
REGISTER_LONG_CONSTANT("%s", 0, CONST_CS|CONST_PERSISTENT);
#endif''' % (c[1], c[1], c[1]), file=self.fd)
else:
- six.print_('E: unknown constant type: %r' % c[0], file=sys.stderr)
- six.print_('', file=self.fd)
+ print('E: unknown constant type: %r' % c[0], file=sys.stderr)
+ print('', file=self.fd)
def generate_middle(self):
- six.print_('''\
+ print('''\
return SUCCESS;
}
@@ -107,21 +106,21 @@
# first we free the previous value
p = (zval_name, c_variable)
q = { 'zval_name' : zval_name, 'c_variable' : c_variable }
- six.print_(' zval_dtor(%s);' % zval_name, file=self.fd)
+ print(' zval_dtor(%s);' % zval_name, file=self.fd)
if is_pointer(type):
- six.print_(' if (! %s) {' % c_variable, file=self.fd)
- six.print_(' ZVAL_NULL(%s);' % zval_name, file=self.fd)
- six.print_(' } else {', file=self.fd)
+ print(' if (! %s) {' % c_variable, file=self.fd)
+ print(' ZVAL_NULL(%s);' % zval_name, file=self.fd)
+ print(' } else {', file=self.fd)
if is_int(type, self.binding_data):
- six.print_(' ZVAL_LONG(%s, %s);' % p, file=self.fd)
+ print(' ZVAL_LONG(%s, %s);' % p, file=self.fd)
elif is_boolean(type):
- six.print_(' ZVAL_BOOL(%s, %s);' % p, file=self.fd)
+ print(' ZVAL_BOOL(%s, %s);' % p, file=self.fd)
elif is_cstring(type):
- six.print_(' ZVAL_STRING(%s, (char*)%s, 1);' % p, file=self.fd)
+ print(' ZVAL_STRING(%s, (char*)%s, 1);' % p, file=self.fd)
if free and not is_const(type):
- six.print_('g_free(%s)' % c_variable, file=self.fd)
+ print('g_free(%s)' % c_variable, file=self.fd)
elif arg_type(type) == 'xmlNode*':
- six.print_('''\
+ print('''\
{
char* xmlString = get_string_from_xml_node(%(c_variable)s);
if (xmlString) {
@@ -146,11 +145,11 @@
free_function = 'g_list_free(%(c_variable)s);'
else:
raise Exception('unknown element-type: ' + repr(type))
- six.print_(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd)
+ print(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd)
if free:
- six.print_(' ', free_function % q, file=self.fd)
+ print(' ', free_function % q, file=self.fd)
elif is_object(type):
- six.print_('''\
+ print('''\
if (G_IS_OBJECT(%(c_variable)s)) {
PhpGObjectPtr *obj = PhpGObjectPtr_New(G_OBJECT(%(c_variable)s));
ZEND_REGISTER_RESOURCE(%(zval_name)s, obj, le_lasso_server);
@@ -158,7 +157,7 @@
ZVAL_NULL(%(zval_name)s);
}''' % q, file=self.fd)
if free:
- six.print_('''\
+ print('''\
if (%(c_variable)s) {
g_object_unref(%(c_variable)s); // If constructor ref is off by one'
}''' % q, file=self.fd)
@@ -166,7 +165,7 @@
else:
raise Exception('unknown type: ' + repr(type) + unconstify(arg_type(type)))
if is_pointer(type):
- six.print_(' }', file=self.fd)
+ print(' }', file=self.fd)
@@ -175,20 +174,20 @@
return
if is_boolean(arg):
- six.print_(' RETVAL_BOOL(return_c_value);', file=self.fd)
+ print(' RETVAL_BOOL(return_c_value);', file=self.fd)
elif is_int(arg, self.binding_data):
- six.print_(' RETVAL_LONG(return_c_value);', file=self.fd)
+ print(' RETVAL_LONG(return_c_value);', file=self.fd)
elif is_cstring(arg):
- six.print_('''\
+ print('''\
if (return_c_value) {
RETVAL_STRING((char*)return_c_value, 1);
} else {
RETVAL_NULL();
}''', file=self.fd)
if free:
- six.print_(' free(return_c_value);', file=self.fd)
+ print(' free(return_c_value);', file=self.fd)
elif is_xml_node(arg):
- six.print_('''\
+ print('''\
{
char* xmlString = get_string_from_xml_node(return_c_value);
if (xmlString) {
@@ -199,44 +198,44 @@
}
''', file=self.fd)
if free:
- six.print_(' lasso_release_xml_node(return_c_value);', file=self.fd)
+ print(' lasso_release_xml_node(return_c_value);', file=self.fd)
elif is_glist(arg):
el_type = element_type(arg)
if is_cstring(el_type):
- six.print_('''\
+ print('''\
set_array_from_list_of_strings((GList*)return_c_value, &return_value);
''', file=self.fd)
if free:
- six.print_(' lasso_release_list_of_strings(return_c_value);', file=self.fd)
+ print(' lasso_release_list_of_strings(return_c_value);', file=self.fd)
elif is_xml_node(el_type):
- six.print_('''\
+ print('''\
set_array_from_list_of_xmlnodes((GList*)return_c_value, &return_value);
''', file=self.fd)
if free or is_transfer_full(arg):
- six.print_(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd)
+ print(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd)
elif is_object(el_type):
- six.print_('''\
+ print('''\
set_array_from_list_of_objects((GList*)return_c_value, &return_value);
''', file=self.fd)
if free:
- six.print_(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd)
+ print(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd)
else:
raise Exception('cannot return value for %s' % (arg,))
elif is_hashtable(arg):
el_type = element_type(arg)
if is_object(el_type):
- six.print_('''\
+ print('''\
set_array_from_hashtable_of_objects(return_c_value, &return_value);
''', file=self.fd)
else:
if not is_cstring(arg):
- six.print_('W: %s has no explicit string annotation' % (arg,),
+ print('W: %s has no explicit string annotation' % (arg,),
file=sys.stderr)
- six.print_('''\
+ print('''\
set_array_from_hashtable_of_strings(return_c_value, &return_value);
''', file=self.fd)
elif is_object(arg):
- six.print_('''\
+ print('''\
if (return_c_value) {
PhpGObjectPtr *self;
self = PhpGObjectPtr_New(G_OBJECT(return_c_value));
@@ -245,7 +244,7 @@
RETVAL_NULL();
}''', file=self.fd)
if free:
- six.print_(' lasso_release_gobject(return_c_value);', file=self.fd)
+ print(' lasso_release_gobject(return_c_value);', file=self.fd)
else:
raise Exception('cannot return value for %s' % (arg,))
@@ -257,61 +256,61 @@
else:
name = m.name
self.functions_list.append(name)
- six.print_('''PHP_FUNCTION(%s)
+ print('''PHP_FUNCTION(%s)
{''' % name, file=self.fd)
parse_tuple_format = []
parse_tuple_args = []
for arg in m.args:
if is_out(arg):
- six.print_(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd)
- six.print_(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd)
+ print(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd)
+ print(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd)
parse_tuple_format.append('z!')
parse_tuple_args.append('&php_out_%s' % arg_name(arg))
elif is_cstring(arg):
parse_tuple_format.append('s!')
parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg)))
- six.print_(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd)
+ print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
+ print(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd)
elif is_int(arg, self.binding_data) or is_boolean(arg):
parse_tuple_format.append('l')
parse_tuple_args.append('&%s' % arg_name(arg))
- six.print_(' %s %s;' % ('long', arg_name(arg)), file=self.fd)
+ print(' %s %s;' % ('long', arg_name(arg)), file=self.fd)
elif is_time_t_pointer(arg):
parse_tuple_format.append('l')
parse_tuple_args.append('&%s' % (arg_name(arg),))
- six.print_(' time_t %s = 0;' % (arg_name(arg),), file=self.fd)
+ print(' time_t %s = 0;' % (arg_name(arg),), file=self.fd)
elif is_xml_node(arg):
parse_tuple_format.append('s!')
parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg)))
- six.print_(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd)
+ print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
+ print(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd)
elif is_glist(arg):
parse_tuple_format.append('a!')
parse_tuple_args.append('&zval_%s' % arg_name(arg))
- six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd)
+ print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd)
elif is_object(arg):
parse_tuple_format.append('r')
parse_tuple_args.append('&zval_%s' % arg_name(arg))
- six.print_(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd)
- six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
- six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd)
+ print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
+ print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd)
else:
raise Exception('Unsupported type %s %s' % (arg, m))
if m.return_type:
- six.print_(' %s return_c_value;' % m.return_type, file=self.fd)
+ print(' %s return_c_value;' % m.return_type, file=self.fd)
if m.return_type is not None and self.is_object(m.return_arg):
- six.print_(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd)
- six.print_('', file=self.fd)
+ print(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd)
+ print('', file=self.fd)
parse_tuple_args = ', '.join(parse_tuple_args)
if parse_tuple_args:
parse_tuple_args = ', ' + parse_tuple_args
- six.print_('''\
+ print('''\
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "%s"%s) == FAILURE) {
RETURN_FALSE;
}
@@ -321,22 +320,22 @@
if is_out(arg):
continue
elif is_xml_node(arg):
- six.print_('''\
+ print('''\
%(name)s = get_xml_node_from_string(%(name)s_str);''' % {'name': arg[1]}, file=self.fd)
elif f.startswith('s'):
- six.print_('''\
+ print('''\
%(name)s = %(name)s_str;''' % {'name': arg[1]}, file=self.fd)
elif f.startswith('r'):
- six.print_(' ZEND_FETCH_RESOURCE(cvt_%s, PhpGObjectPtr *, &zval_%s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % (arg[1], arg[1]), file=self.fd)
- six.print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd)
+ print(' ZEND_FETCH_RESOURCE(cvt_%s, PhpGObjectPtr *, &zval_%s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % (arg[1], arg[1]), file=self.fd)
+ print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd)
elif f.startswith('a'):
el_type = element_type(arg)
if is_cstring(el_type):
- six.print_(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
+ print(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
elif is_object(el_type):
- six.print_(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
+ print(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
else:
- six.print_('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr)
+ print('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr)
elif f == 'l':
pass
else:
@@ -344,17 +343,17 @@
if m.return_type is not None:
- six.print_(' return_c_value = ', file=self.fd)
+ print(' return_c_value = ', file=self.fd)
if 'new' in m.name:
- six.print_('(%s)' % m.return_type, file=self.fd)
+ print('(%s)' % m.return_type, file=self.fd)
else:
- six.print_(' ', file=self.fd)
+ print(' ', file=self.fd)
def special(x):
if is_time_t_pointer(x):
return '%(name)s ? &%(name)s : NULL' % { 'name': arg_name(x) }
else:
return ref_name(x)
- six.print_('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd)
+ print('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd)
# Free the converted arguments
for f, arg in zip(parse_tuple_format, m.args):
@@ -365,21 +364,21 @@
self.set_zval('php_out_%s' % argname, argname, unref_type(arg), free = free)
pass
elif argtype == 'xmlNode*':
- six.print_(' xmlFree(%s);' % argname, file=self.fd)
+ print(' xmlFree(%s);' % argname, file=self.fd)
elif f.startswith('a'):
el_type = element_type(arg)
if is_cstring(el_type):
- six.print_(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd)
- six.print_(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd)
+ print(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd)
+ print(' }', file=self.fd)
try:
self.return_value(m.return_arg, is_transfer_full(m.return_arg, default=True))
except:
raise Exception('Cannot return value for function %s' % m)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_members(self, c):
for m in c.members:
@@ -392,16 +391,16 @@
type = arg_type(m)
function_name = '%s_%s_get' % (klassname, format_as_camelcase(name))
- six.print_('''PHP_FUNCTION(%s)
+ print('''PHP_FUNCTION(%s)
{''' % function_name, file=self.fd)
self.functions_list.append(function_name)
- six.print_(' %s return_c_value;' % type, file=self.fd)
- six.print_(' %s* this;' % klassname, file=self.fd)
- six.print_(' zval* zval_this;', file=self.fd)
- six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd)
- six.print_('', file=self.fd)
- six.print_('''\
+ print(' %s return_c_value;' % type, file=self.fd)
+ print(' %s* this;' % klassname, file=self.fd)
+ print(' zval* zval_this;', file=self.fd)
+ print(' PhpGObjectPtr *cvt_this;', file=self.fd)
+ print('', file=self.fd)
+ print('''\
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zval_this) == FAILURE) {
RETURN_FALSE;
}
@@ -409,23 +408,23 @@
ZEND_FETCH_RESOURCE(cvt_this, PhpGObjectPtr *, &zval_this, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);
this = (%s*)cvt_this->obj;
''' % (klassname), file=self.fd)
- six.print_(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd)
+ print(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd)
self.return_value(m)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_setter(self, c, m):
klassname = c.name
name = arg_name(m)
type = arg_type(m)
function_name = '%s_%s_set' % (klassname, format_as_camelcase(name))
- six.print_('''PHP_FUNCTION(%s)
+ print('''PHP_FUNCTION(%s)
{''' % function_name, file=self.fd)
self.functions_list.append(function_name)
- six.print_(' %s* this;' % klassname, file=self.fd)
- six.print_(' zval* zval_this;', file=self.fd)
- six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd)
+ print(' %s* this;' % klassname, file=self.fd)
+ print(' zval* zval_this;', file=self.fd)
+ print(' PhpGObjectPtr *cvt_this;', file=self.fd)
# FIXME: This bloc should be factorised
parse_tuple_format = ''
@@ -434,41 +433,41 @@
# arg_type = arg_type.replace('const ', '')
parse_tuple_format += 's'
parse_tuple_args.append('&%s_str, &%s_len' % (name, name))
- six.print_(' %s %s_str = NULL;' % ('char*', name), file=self.fd)
- six.print_(' %s %s_len = 0;' % ('int', name), file=self.fd)
+ print(' %s %s_str = NULL;' % ('char*', name), file=self.fd)
+ print(' %s %s_len = 0;' % ('int', name), file=self.fd)
elif is_int(m, self.binding_data) or is_boolean(m):
parse_tuple_format += 'l'
parse_tuple_args.append('&%s' % name)
- six.print_(' %s %s;' % ('long', name), file=self.fd)
+ print(' %s %s;' % ('long', name), file=self.fd)
# Must also handle lists of Objects
elif is_glist(m) or is_hashtable(m):
parse_tuple_format += 'a'
parse_tuple_args.append('&zval_%s' % name)
- six.print_(' %s zval_%s;' % ('zval*', name), file=self.fd)
+ print(' %s zval_%s;' % ('zval*', name), file=self.fd)
elif is_object(m):
parse_tuple_format += 'r'
parse_tuple_args.append('&zval_%s' % name)
- six.print_(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd)
- six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd)
+ print(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd)
+ print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd)
else:
raise Exception('Cannot make a setter for %s.%s' % (c,m))
if parse_tuple_args:
parse_tuple_arg = parse_tuple_args[0]
else:
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
return
- six.print_('', file=self.fd)
- six.print_('''\
+ print('', file=self.fd)
+ print('''\
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r%s", &zval_this, %s) == FAILURE) {
return;
}
''' % (parse_tuple_format, parse_tuple_arg), file=self.fd)
# Get 'this' object
- six.print_('''\
+ print('''\
ZEND_FETCH_RESOURCE(cvt_this, PhpGObjectPtr *, &zval_this, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);
this = (%s*)cvt_this->obj;
''' % klassname, file=self.fd)
@@ -476,51 +475,51 @@
# Set new value
d = { 'name': name, 'type': type }
if is_int(m, self.binding_data) or is_boolean(m):
- six.print_(' this->%s = %s;' % (name, name), file=self.fd)
+ print(' this->%s = %s;' % (name, name), file=self.fd)
elif is_cstring(m):
- six.print_(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd)
+ print(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd)
elif is_xml_node(m):
- six.print_(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd)
+ print(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd)
elif is_glist(m):
el_type = element_type(m)
if is_cstring(el_type):
- six.print_(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd)
+ print(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd)
elif is_xml_node(el_type):
- six.print_(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd)
+ print(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd)
elif is_object(el_type):
- six.print_(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd)
+ print(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd)
else:
raise Exception('Cannot create C setter for %s.%s' % (c,m))
elif is_hashtable(m):
el_type = element_type(m)
- six.print_('''\
+ print('''\
{
GHashTable *oldhash = this->%(name)s;''' % d, file=self.fd)
if is_object(el_type):
- six.print_(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd)
+ print(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd)
else:
- six.print_(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd)
- six.print_(' g_hash_table_destroy(oldhash);', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd)
+ print(' g_hash_table_destroy(oldhash);', file=self.fd)
+ print(' }', file=self.fd)
elif is_object(m):
- six.print_(' ZEND_FETCH_RESOURCE(cvt_%(name)s, PhpGObjectPtr*, &zval_%(name)s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % d, file=self.fd)
- six.print_(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd)
+ print(' ZEND_FETCH_RESOURCE(cvt_%(name)s, PhpGObjectPtr*, &zval_%(name)s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % d, file=self.fd)
+ print(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_functions_list(self):
- six.print_('''\
+ print('''\
static zend_function_entry lasso_functions[] = {''', file=self.fd)
for m in self.functions_list:
- six.print_(' PHP_FE(%s, NULL)' % m, file=self.fd)
- six.print_('''\
+ print(' PHP_FE(%s, NULL)' % m, file=self.fd)
+ print('''\
{NULL, NULL, NULL, 0, 0}
};
''', file=self.fd)
def generate_footer(self):
- six.print_('''\
+ print('''\
zend_module_entry lasso_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
Index: lasso-2.8.2/bindings/php7/php_code.py
===================================================================
--- lasso-2.8.2.orig/bindings/php7/php_code.py 2021-09-11 19:20:25.848637964 +0200
+++ lasso-2.8.2/bindings/php7/php_code.py 2025-06-18 21:27:46.767358242 +0200
@@ -20,7 +20,6 @@
import re
import sys
-import six
from utils import *
@@ -40,7 +39,7 @@
self.generate_footer()
def generate_header(self):
- six.print_('''\
+ print('''\
<?php
/* this file has been generated automatically; do not edit */
@@ -107,27 +106,27 @@
else:
inheritence = ' extends LassoObject'
- six.print_('/**', file=self.fd)
- six.print_(' * @package Lasso', file=self.fd)
- six.print_(' */', file=self.fd)
- six.print_('class %(class_name)s%(inheritence)s {' % locals(), file=self.fd)
+ print('/**', file=self.fd)
+ print(' * @package Lasso', file=self.fd)
+ print(' */', file=self.fd)
+ print('class %(class_name)s%(inheritence)s {' % locals(), file=self.fd)
if klass.members or klass.methods:
self.generate_constructors(klass)
self.generate_getters_and_setters(klass)
self.generate_methods(klass)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
# Add a special class to get an object instance without initialising
- six.print_('/**', file=self.fd)
- six.print_(' * @package Lasso', file=self.fd)
- six.print_(' */', file=self.fd)
- six.print_('class %(class_name)sNoInit extends %(class_name)s {' % locals(), file=self.fd)
- six.print_(' public function __construct() {}', file=self.fd)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('/**', file=self.fd)
+ print(' * @package Lasso', file=self.fd)
+ print(' */', file=self.fd)
+ print('class %(class_name)sNoInit extends %(class_name)s {' % locals(), file=self.fd)
+ print(' public function __construct() {}', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_constructors(self, klass):
method_prefix = format_as_underscored(klass.name) + '_'
@@ -152,13 +151,13 @@
c_args = ', '.join(c_args)
# XXX: could check $this->_cptr->typename to see if it got the
# right class type
- six.print_(' public $_cptr = null;', file=self.fd)
- six.print_('', file=self.fd)
- six.print_(' public function __construct(%s) {' % php_args, file=self.fd)
- six.print_(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd)
- six.print_(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' public $_cptr = null;', file=self.fd)
+ print('', file=self.fd)
+ print(' public function __construct(%s) {' % php_args, file=self.fd)
+ print(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd)
+ print(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
elif name.startswith(method_prefix) and m.args \
and clean_type(unconstify(m.args[0][0])) != klass.name:
@@ -185,10 +184,10 @@
c_args.append('$%s' % arg_name)
php_args = ', '.join(php_args)
c_args = ', '.join(c_args)
- six.print_(' public static function %s(%s) {' % (php_name, php_args), file=self.fd)
- six.print_(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' public static function %s(%s) {' % (php_name, php_args), file=self.fd)
+ print(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
@@ -200,50 +199,50 @@
'class': c.name
}
- six.print_('''\
+ print('''\
/**
* @return %(docstring)s
*/
protected function get_%(name)s() {''' % d, file=self.fd)
- six.print_(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd)
+ print(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd)
if self.is_object(m):
- six.print_(' $t = cptrToPhp($t);', file=self.fd)
+ print(' $t = cptrToPhp($t);', file=self.fd)
elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)):
- six.print_(' foreach ($t as $key => $item) {', file=self.fd)
- six.print_(' $t[$key] = cptrToPhp($item);', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' foreach ($t as $key => $item) {', file=self.fd)
+ print(' $t[$key] = cptrToPhp($item);', file=self.fd)
+ print(' }', file=self.fd)
elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \
or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \
or is_boolean(m) or is_cstring(m) or is_xml_node(m):
pass
else:
raise Exception('Cannot generate a Php getter %s.%s' % (c,m))
- six.print_(' return $t;', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' return $t;', file=self.fd)
+ print(' }', file=self.fd)
def generate_setter(self, c, m):
d = { 'type': arg_type(m), 'name': format_as_camelcase(arg_name(m)),
'docstring': self.get_docstring_return_type(arg_type(m)), 'class': c.name }
- six.print_(' protected function set_%(name)s($value) {' % d, file=self.fd)
+ print(' protected function set_%(name)s($value) {' % d, file=self.fd)
if self.is_object(m):
- six.print_(' $value = $value->_cptr;', file=self.fd)
+ print(' $value = $value->_cptr;', file=self.fd)
elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)):
- six.print_(' $array = array();', file=self.fd)
- six.print_(' if (!is_null($value)) {', file=self.fd)
- six.print_(' foreach ($value as $key => $item) {', file=self.fd)
- six.print_(' $array[$key] = $item->_cptr;', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' $value = $array;', file=self.fd)
+ print(' $array = array();', file=self.fd)
+ print(' if (!is_null($value)) {', file=self.fd)
+ print(' foreach ($value as $key => $item) {', file=self.fd)
+ print(' $array[$key] = $item->_cptr;', file=self.fd)
+ print(' }', file=self.fd)
+ print(' }', file=self.fd)
+ print(' $value = $array;', file=self.fd)
elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \
or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \
or is_boolean(m) or is_cstring(m) or is_xml_node(m):
pass
else:
raise Exception('Cannot generate a Php setter %s.%s' % (c,m))
- six.print_(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
def generate_getters_and_setters(self, klass):
for m in klass.members:
@@ -271,27 +270,27 @@
mname = re.match(r'lasso_.*_get_(\w+)', meth_name).group(1)
mname = format_as_camelcase(mname)
- six.print_(' /**', file=self.fd)
- six.print_(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd)
- six.print_(' */', file=self.fd)
- six.print_(' protected function get_%s() {' % mname, file=self.fd)
+ print(' /**', file=self.fd)
+ print(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd)
+ print(' */', file=self.fd)
+ print(' protected function get_%s() {' % mname, file=self.fd)
if self.is_object(m.return_type):
- six.print_(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd)
- six.print_(' if (! is_null($cptr)) {', file=self.fd)
- six.print_(' return cptrToPhp($cptr);', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' return null;', file=self.fd)
+ print(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd)
+ print(' if (! is_null($cptr)) {', file=self.fd)
+ print(' return cptrToPhp($cptr);', file=self.fd)
+ print(' }', file=self.fd)
+ print(' return null;', file=self.fd)
else:
- six.print_(' return %s($this->_cptr);' % meth_name, file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' return %s($this->_cptr);' % meth_name, file=self.fd)
+ print(' }', file=self.fd)
if setter:
- six.print_(' protected function set_%s($value) {' % mname, file=self.fd)
+ print(' protected function set_%s($value) {' % mname, file=self.fd)
if self.is_object(m.return_type):
- six.print_(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd)
+ print(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd)
else:
- six.print_(' %s($this->_cptr, $value);' % setter.name, file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' %s($this->_cptr, $value);' % setter.name, file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
# second pass on methods, real methods
method_prefix = format_as_underscored(klass.name) + '_'
@@ -356,26 +355,26 @@
c_args = ''
if m.docstring:
- six.print_(self.generate_docstring(m, mname, 4), file=self.fd)
- six.print_(' public function %s(%s) {' % (
+ print(self.generate_docstring(m, mname, 4), file=self.fd)
+ print(' public function %s(%s) {' % (
format_underscore_as_camelcase(mname), php_args), file=self.fd)
if m.return_type == 'void':
- six.print_(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
+ print(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
elif is_rc(m.return_type):
- six.print_(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
- six.print_(' if ($rc == 0) {', file=self.fd)
- six.print_(' return 0;', file=self.fd)
- six.print_(' } else if ($rc > 0) {', file=self.fd) # recoverable error
- six.print_(' return $rc;', file=self.fd)
- six.print_(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error
- six.print_(' LassoError::throw_on_rc($rc);', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
+ print(' if ($rc == 0) {', file=self.fd)
+ print(' return 0;', file=self.fd)
+ print(' } else if ($rc > 0) {', file=self.fd) # recoverable error
+ print(' return $rc;', file=self.fd)
+ print(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error
+ print(' LassoError::throw_on_rc($rc);', file=self.fd)
+ print(' }', file=self.fd)
else:
- six.print_(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_('', file=self.fd)
+ print(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd)
+ print(' }', file=self.fd)
+ print('', file=self.fd)
- six.print_('', file=self.fd)
+ print('', file=self.fd)
def generate_docstring(self, func, method_name, indent):
docstring = func.docstring.orig_docstring
@@ -435,7 +434,7 @@
cat = exc_cat.attrib.get('name')
done_cats.append(cat)
parent_cat = exc_cat.attrib.get('parent', '')
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -460,7 +459,7 @@
else:
parent_cat = ''
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -468,7 +467,7 @@
''' % (cat, parent_cat), file=self.fd)
if detail not in exceptions_dict:
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -478,7 +477,7 @@
''' % (detail, cat, c[1]), file=self.fd)
exceptions_dict[detail] = c[1]
- six.print_('''\
+ print('''\
/**
* @package Lasso
*/
@@ -486,9 +485,9 @@
private static $exceptions_dict = array(''', file=self.fd)
for k, v in exceptions_dict.items():
- six.print_(' %s => "Lasso%sError",' % (v, k), file=self.fd)
+ print(' %s => "Lasso%sError",' % (v, k), file=self.fd)
- six.print_('''\
+ print('''\
);
public static function throw_on_rc($rc) {
@@ -502,6 +501,6 @@
''', file=self.fd)
def generate_footer(self):
- six.print_('''\
+ print('''\
?>''', file=self.fd)
Index: lasso-2.8.2/bindings/php7/wrapper_header.py
===================================================================
--- lasso-2.8.2.orig/bindings/php7/wrapper_header.py 2021-05-17 22:00:09.047310384 +0200
+++ lasso-2.8.2/bindings/php7/wrapper_header.py 2025-06-18 21:27:46.767689432 +0200
@@ -17,7 +17,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-import six
class WrapperHeader:
def __init__(self, binding_data, fd, functions_list):
@@ -32,7 +31,7 @@
def generate_header(self):
# FIXME: Get the current version and name
- six.print_('''\
+ print('''\
/* this file has been generated automatically; do not edit */
#include "../../config.h"
@@ -51,11 +50,11 @@
def generate_functions_list(self):
for m in self.functions_list:
- six.print_('PHP_FUNCTION(%s);' % m, file=self.fd)
- six.print_('', file=self.fd)
+ print('PHP_FUNCTION(%s);' % m, file=self.fd)
+ print('', file=self.fd)
def generate_footer(self):
- six.print_('''\
+ print('''\
extern zend_module_entry lasso_module_entry;
#define phpext_lasso_ptr &lasso_module_entry
Index: lasso-2.8.2/bindings/php7/wrapper_source.py
===================================================================
--- lasso-2.8.2.orig/bindings/php7/wrapper_source.py 2021-05-17 22:00:09.047310384 +0200
+++ lasso-2.8.2/bindings/php7/wrapper_source.py 2025-06-18 21:27:46.767990801 +0200
@@ -20,7 +20,6 @@
import sys
import os
-import six
from utils import *
@@ -53,17 +52,17 @@
self.functions_list.append('lasso_init')
self.functions_list.append('lasso_shutdown')
- six.print_('''\
+ print('''\
/* this file has been generated automatically; do not edit */
''', file=self.fd)
- six.print_(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd)
+ print(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd)
for h in self.binding_data.headers:
- six.print_('#include <%s>' % h, file=self.fd)
- six.print_('', file=self.fd)
+ print('#include <%s>' % h, file=self.fd)
+ print('', file=self.fd)
- six.print_('''\
+ print('''\
PHP_MINIT_FUNCTION(lasso)
{
le_lasso_server = zend_register_list_destructors_ex(php_gobject_generic_destructor, NULL, PHP_LASSO_SERVER_RES_NAME, module_number);
@@ -71,25 +70,25 @@
''', file=self.fd)
def generate_constants(self):
- six.print_(' /* Constants (both enums and defines) */', file=self.fd)
+ print(' /* Constants (both enums and defines) */', file=self.fd)
for c in self.binding_data.constants:
if c[0] == 'i':
- six.print_(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
+ print(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
elif c[0] == 's':
- six.print_(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
+ print(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd)
elif c[0] == 'b':
- six.print_('''\
+ print('''\
#ifdef %s
REGISTER_LONG_CONSTANT("%s", 1, CONST_CS|CONST_PERSISTENT);
#else
REGISTER_LONG_CONSTANT("%s", 0, CONST_CS|CONST_PERSISTENT);
#endif''' % (c[1], c[1], c[1]), file=self.fd)
else:
- six.print_('E: unknown constant type: %r' % c[0], file=sys.stderr)
- six.print_('', file=self.fd)
+ print('E: unknown constant type: %r' % c[0], file=sys.stderr)
+ print('', file=self.fd)
def generate_middle(self):
- six.print_('''\
+ print('''\
return SUCCESS;
}
@@ -107,21 +106,21 @@
# first we free the previous value
p = (zval_name, c_variable)
q = { 'zval_name' : zval_name, 'c_variable' : c_variable }
- six.print_(' zval_dtor(%s);' % zval_name, file=self.fd)
+ print(' zval_dtor(%s);' % zval_name, file=self.fd)
if is_pointer(type):
- six.print_(' if (! %s) {' % c_variable, file=self.fd)
- six.print_(' ZVAL_NULL(%s);' % zval_name, file=self.fd)
- six.print_(' } else {', file=self.fd)
+ print(' if (! %s) {' % c_variable, file=self.fd)
+ print(' ZVAL_NULL(%s);' % zval_name, file=self.fd)
+ print(' } else {', file=self.fd)
if is_int(type, self.binding_data):
- six.print_(' ZVAL_LONG(%s, %s);' % p, file=self.fd)
+ print(' ZVAL_LONG(%s, %s);' % p, file=self.fd)
elif is_boolean(type):
- six.print_(' ZVAL_BOOL(%s, %s);' % p, file=self.fd)
+ print(' ZVAL_BOOL(%s, %s);' % p, file=self.fd)
elif is_cstring(type):
- six.print_(' ZVAL_STRING(%s, (char*)%s);' % p, file=self.fd)
+ print(' ZVAL_STRING(%s, (char*)%s);' % p, file=self.fd)
if free and not is_const(type):
- six.print_('g_free(%s)' % c_variable, file=self.fd)
+ print('g_free(%s)' % c_variable, file=self.fd)
elif arg_type(type) == 'xmlNode*':
- six.print_('''\
+ print('''\
{
char* xmlString = get_string_from_xml_node(%(c_variable)s);
if (xmlString) {
@@ -146,11 +145,11 @@
free_function = 'g_list_free(%(c_variable)s);'
else:
raise Exception('unknown element-type: ' + repr(type))
- six.print_(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd)
+ print(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd)
if free:
- six.print_(' ', free_function % q, file=self.fd)
+ print(' ', free_function % q, file=self.fd)
elif is_object(type):
- six.print_('''\
+ print('''\
if (G_IS_OBJECT(%(c_variable)s)) {
PhpGObjectPtr *obj = PhpGObjectPtr_New(G_OBJECT(%(c_variable)s));
zend_resource *res = zend_register_resource(obj, le_lasso_server);
@@ -159,7 +158,7 @@
ZVAL_NULL(%(zval_name)s);
}''' % q, file=self.fd)
if free:
- six.print_('''\
+ print('''\
if (%(c_variable)s) {
g_object_unref(%(c_variable)s); // If constructor ref is off by one'
}''' % q, file=self.fd)
@@ -167,7 +166,7 @@
else:
raise Exception('unknown type: ' + repr(type) + unconstify(arg_type(type)))
if is_pointer(type):
- six.print_(' }', file=self.fd)
+ print(' }', file=self.fd)
@@ -176,20 +175,20 @@
return
if is_boolean(arg):
- six.print_(' RETVAL_BOOL(return_c_value);', file=self.fd)
+ print(' RETVAL_BOOL(return_c_value);', file=self.fd)
elif is_int(arg, self.binding_data):
- six.print_(' RETVAL_LONG(return_c_value);', file=self.fd)
+ print(' RETVAL_LONG(return_c_value);', file=self.fd)
elif is_cstring(arg):
- six.print_('''\
+ print('''\
if (return_c_value) {
RETVAL_STRING((char*)return_c_value);
} else {
RETVAL_NULL();
}''', file=self.fd)
if free:
- six.print_(' free(return_c_value);', file=self.fd)
+ print(' free(return_c_value);', file=self.fd)
elif is_xml_node(arg):
- six.print_('''\
+ print('''\
{
char* xmlString = get_string_from_xml_node(return_c_value);
if (xmlString) {
@@ -200,43 +199,43 @@
}
''', file=self.fd)
if free:
- six.print_(' lasso_release_xml_node(return_c_value);', file=self.fd)
+ print(' lasso_release_xml_node(return_c_value);', file=self.fd)
elif is_glist(arg):
el_type = element_type(arg)
if is_cstring(el_type):
- six.print_('''\
+ print('''\
set_array_from_list_of_strings((GList*)return_c_value, &return_value);
''', file=self.fd)
if free:
- six.print_(' lasso_release_list_of_strings(return_c_value);', file=self.fd)
+ print(' lasso_release_list_of_strings(return_c_value);', file=self.fd)
elif is_xml_node(el_type):
- six.print_('''\
+ print('''\
set_array_from_list_of_xmlnodes((GList*)return_c_value, &return_value);
''', file=self.fd)
if free or is_transfer_full(arg):
- six.print_(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd)
+ print(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd)
elif is_object(el_type):
- six.print_('''\
+ print('''\
set_array_from_list_of_objects((GList*)return_c_value, &return_value);
''', file=self.fd)
if free:
- six.print_(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd)
+ print(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd)
else:
raise Exception('cannot return value for %s' % (arg,))
elif is_hashtable(arg):
el_type = element_type(arg)
if is_object(el_type):
- six.print_('''\
+ print('''\
set_array_from_hashtable_of_objects(return_c_value, &return_value);
''', file=self.fd)
else:
if not is_cstring(arg):
print >>sys.stderr, 'W: %s has no explicit string annotation' % (arg,)
- six.print_('''\
+ print('''\
set_array_from_hashtable_of_strings(return_c_value, &return_value);
''', file=self.fd)
elif is_object(arg):
- six.print_('''\
+ print('''\
if (return_c_value) {
PhpGObjectPtr *self;
self = PhpGObjectPtr_New(G_OBJECT(return_c_value));
@@ -246,7 +245,7 @@
RETVAL_NULL();
}''', file=self.fd)
if free:
- six.print_(' lasso_release_gobject(return_c_value);', file=self.fd)
+ print(' lasso_release_gobject(return_c_value);', file=self.fd)
else:
raise Exception('cannot return value for %s' % (arg,))
@@ -258,26 +257,26 @@
else:
name = m.name
self.functions_list.append(name)
- six.print_('''PHP_FUNCTION(%s)
+ print('''PHP_FUNCTION(%s)
{''' % name, file=self.fd)
parse_tuple_format = []
parse_tuple_args = []
for arg in m.args:
if is_out(arg):
- six.print_(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd)
- six.print_(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd)
+ print(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd)
+ print(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd)
parse_tuple_format.append('z!')
parse_tuple_args.append('&php_out_%s' % arg_name(arg))
elif is_cstring(arg):
parse_tuple_format.append('s!')
parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg)))
- six.print_(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd)
+ print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
+ print(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd)
elif is_int(arg, self.binding_data) or is_boolean(arg):
parse_tuple_format.append('l')
parse_tuple_args.append('&%s' % arg_name(arg))
- six.print_(' %s %s;' % ('long', arg_name(arg)), file=self.fd)
+ print(' %s %s;' % ('long', arg_name(arg)), file=self.fd)
elif is_time_t_pointer(arg):
parse_tuple_format.append('l')
parse_tuple_args.append('&%s' % (arg_name(arg),))
@@ -285,34 +284,34 @@
elif is_xml_node(arg):
parse_tuple_format.append('s!')
parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg)))
- six.print_(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd)
+ print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd)
+ print(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd)
elif is_glist(arg):
parse_tuple_format.append('a!')
parse_tuple_args.append('&zval_%s' % arg_name(arg))
- six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
- six.print_(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd)
+ print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd)
elif is_object(arg):
parse_tuple_format.append('r')
parse_tuple_args.append('&zval_%s' % arg_name(arg))
- six.print_(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd)
- six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
- six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd)
+ print(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd)
+ print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd)
+ print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd)
else:
raise Exception('Unsupported type %s %s' % (arg, m))
if m.return_type:
- six.print_(' %s return_c_value;' % m.return_type, file=self.fd)
+ print(' %s return_c_value;' % m.return_type, file=self.fd)
if m.return_type is not None and self.is_object(m.return_arg):
- six.print_(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd)
- six.print_('', file=self.fd)
+ print(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd)
+ print('', file=self.fd)
parse_tuple_args = ', '.join(parse_tuple_args)
if parse_tuple_args:
parse_tuple_args = ', ' + parse_tuple_args
- six.print_('''\
+ print('''\
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "%s"%s) == FAILURE) {
RETURN_FALSE;
}
@@ -322,24 +321,24 @@
if is_out(arg):
continue
elif is_xml_node(arg):
- six.print_('''\
+ print('''\
%(name)s = get_xml_node_from_string(%(name)s_str);''' % {'name': arg[1]}, file=self.fd)
elif f.startswith('s'):
- six.print_('''\
+ print('''\
%(name)s = %(name)s_str;''' % {'name': arg[1]}, file=self.fd)
elif f.startswith('r'):
- six.print_(' if ((cvt_%s = (PhpGObjectPtr *)zend_fetch_resource(Z_RES_P(zval_%s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % (arg[1], arg[1]), file=self.fd)
- six.print_(' RETURN_FALSE;', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd)
+ print(' if ((cvt_%s = (PhpGObjectPtr *)zend_fetch_resource(Z_RES_P(zval_%s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % (arg[1], arg[1]), file=self.fd)
+ print(' RETURN_FALSE;', file=self.fd)
+ print(' }', file=self.fd)
+ print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd)
elif f.startswith('a'):
el_type = element_type(arg)
if is_cstring(el_type):
- six.print_(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
+ print(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
elif is_object(el_type):
- six.print_(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
+ print(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd)
else:
- six.print_('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr)
+ print('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr)
elif f == 'l':
pass
else:
@@ -347,17 +346,17 @@
if m.return_type is not None:
- six.print_(' return_c_value = ', file=self.fd)
+ print(' return_c_value = ', file=self.fd)
if 'new' in m.name:
- six.print_('(%s)' % m.return_type, file=self.fd)
+ print('(%s)' % m.return_type, file=self.fd)
else:
- six.print_(' ', file=self.fd)
+ print(' ', file=self.fd)
def special(x):
if is_time_t_pointer(x):
return '%(name)s ? &%(name)s : NULL' % { 'name': arg_name(x) }
else:
return ref_name(x)
- six.print_('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd)
+ print('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd)
# Free the converted arguments
for f, arg in zip(parse_tuple_format, m.args):
@@ -368,21 +367,21 @@
self.set_zval('php_out_%s' % argname, argname, unref_type(arg), free = free)
pass
elif argtype == 'xmlNode*':
- six.print_(' xmlFree(%s);' % argname, file=self.fd)
+ print(' xmlFree(%s);' % argname, file=self.fd)
elif f.startswith('a'):
el_type = element_type(arg)
if is_cstring(el_type):
- six.print_(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd)
- six.print_(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd)
+ print(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd)
+ print(' }', file=self.fd)
try:
self.return_value(m.return_arg, is_transfer_full(m.return_arg, default=True))
except:
raise Exception('Cannot return value for function %s' % m)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_members(self, c):
for m in c.members:
@@ -395,16 +394,16 @@
type = arg_type(m)
function_name = '%s_%s_get' % (klassname, format_as_camelcase(name))
- six.print_('''PHP_FUNCTION(%s)
+ print('''PHP_FUNCTION(%s)
{''' % function_name, file=self.fd)
self.functions_list.append(function_name)
- six.print_(' %s return_c_value;' % type, file=self.fd)
- six.print_(' %s* this;' % klassname, file=self.fd)
- six.print_(' zval* zval_this;', file=self.fd)
- six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd)
- six.print_('', file=self.fd)
- six.print_('''\
+ print(' %s return_c_value;' % type, file=self.fd)
+ print(' %s* this;' % klassname, file=self.fd)
+ print(' zval* zval_this;', file=self.fd)
+ print(' PhpGObjectPtr *cvt_this;', file=self.fd)
+ print('', file=self.fd)
+ print('''\
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zval_this) == FAILURE) {
RETURN_FALSE;
}
@@ -414,23 +413,23 @@
}
this = (%s*)cvt_this->obj;
''' % (klassname), file=self.fd)
- six.print_(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd)
+ print(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd)
self.return_value(m)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_setter(self, c, m):
klassname = c.name
name = arg_name(m)
type = arg_type(m)
function_name = '%s_%s_set' % (klassname, format_as_camelcase(name))
- six.print_('''PHP_FUNCTION(%s)
+ print('''PHP_FUNCTION(%s)
{''' % function_name, file=self.fd)
self.functions_list.append(function_name)
- six.print_(' %s* this;' % klassname, file=self.fd)
- six.print_(' zval* zval_this;', file=self.fd)
- six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd)
+ print(' %s* this;' % klassname, file=self.fd)
+ print(' zval* zval_this;', file=self.fd)
+ print(' PhpGObjectPtr *cvt_this;', file=self.fd)
# FIXME: This bloc should be factorised
parse_tuple_format = ''
@@ -439,41 +438,41 @@
# arg_type = arg_type.replace('const ', '')
parse_tuple_format += 's'
parse_tuple_args.append('&%s_str, &%s_len' % (name, name))
- six.print_(' %s %s_str = NULL;' % ('char*', name), file=self.fd)
- six.print_(' %s %s_len = 0;' % ('size_t', name), file=self.fd)
+ print(' %s %s_str = NULL;' % ('char*', name), file=self.fd)
+ print(' %s %s_len = 0;' % ('size_t', name), file=self.fd)
elif is_int(m, self.binding_data) or is_boolean(m):
parse_tuple_format += 'l'
parse_tuple_args.append('&%s' % name)
- six.print_(' %s %s;' % ('long', name), file=self.fd)
+ print(' %s %s;' % ('long', name), file=self.fd)
# Must also handle lists of Objects
elif is_glist(m) or is_hashtable(m):
parse_tuple_format += 'a'
parse_tuple_args.append('&zval_%s' % name)
- six.print_(' %s zval_%s;' % ('zval*', name), file=self.fd)
+ print(' %s zval_%s;' % ('zval*', name), file=self.fd)
elif is_object(m):
parse_tuple_format += 'r'
parse_tuple_args.append('&zval_%s' % name)
- six.print_(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd)
- six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd)
+ print(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd)
+ print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd)
else:
raise Exception('Cannot make a setter for %s.%s' % (c,m))
if parse_tuple_args:
parse_tuple_arg = parse_tuple_args[0]
else:
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
return
- six.print_('', file=self.fd)
- six.print_('''\
+ print('', file=self.fd)
+ print('''\
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r%s", &zval_this, %s) == FAILURE) {
return;
}
''' % (parse_tuple_format, parse_tuple_arg), file=self.fd)
# Get 'this' object
- six.print_('''\
+ print('''\
if ((cvt_this = (PhpGObjectPtr *)zend_fetch_resource(Z_RES_P(zval_this), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {
RETURN_FALSE;
}
@@ -483,53 +482,53 @@
# Set new value
d = { 'name': name, 'type': type }
if is_int(m, self.binding_data) or is_boolean(m):
- six.print_(' this->%s = %s;' % (name, name), file=self.fd)
+ print(' this->%s = %s;' % (name, name), file=self.fd)
elif is_cstring(m):
- six.print_(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd)
+ print(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd)
elif is_xml_node(m):
- six.print_(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd)
+ print(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd)
elif is_glist(m):
el_type = element_type(m)
if is_cstring(el_type):
- six.print_(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd)
+ print(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd)
elif is_xml_node(el_type):
- six.print_(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd)
+ print(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd)
elif is_object(el_type):
- six.print_(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd)
+ print(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd)
else:
raise Exception('Cannot create C setter for %s.%s' % (c,m))
elif is_hashtable(m):
el_type = element_type(m)
- six.print_('''\
+ print('''\
{
GHashTable *oldhash = this->%(name)s;''' % d, file=self.fd)
if is_object(el_type):
- six.print_(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd)
+ print(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd)
else:
- six.print_(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd)
- six.print_(' g_hash_table_destroy(oldhash);', file=self.fd)
- six.print_(' }', file=self.fd)
+ print(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd)
+ print(' g_hash_table_destroy(oldhash);', file=self.fd)
+ print(' }', file=self.fd)
elif is_object(m):
- six.print_(' if ((cvt_%(name)s = (PhpGObjectPtr*)zend_fetch_resource(Z_RES_P(zval_%(name)s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % d, file=self.fd)
- six.print_(' RETURN_FALSE;', file=self.fd)
- six.print_(' }', file=self.fd)
- six.print_(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd)
+ print(' if ((cvt_%(name)s = (PhpGObjectPtr*)zend_fetch_resource(Z_RES_P(zval_%(name)s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % d, file=self.fd)
+ print(' RETURN_FALSE;', file=self.fd)
+ print(' }', file=self.fd)
+ print(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd)
- six.print_('}', file=self.fd)
- six.print_('', file=self.fd)
+ print('}', file=self.fd)
+ print('', file=self.fd)
def generate_functions_list(self):
- six.print_('''\
+ print('''\
static zend_function_entry lasso_functions[] = {''', file=self.fd)
for m in self.functions_list:
- six.print_(' PHP_FE(%s, NULL)' % m, file=self.fd)
- six.print_('''\
+ print(' PHP_FE(%s, NULL)' % m, file=self.fd)
+ print('''\
{NULL, NULL, NULL, 0, 0}
};
''', file=self.fd)
def generate_footer(self):
- six.print_('''\
+ print('''\
zend_module_entry lasso_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
Index: lasso-2.8.2/bindings/python/examples/get_attributes_from_assertion.py
===================================================================
--- lasso-2.8.2.orig/bindings/python/examples/get_attributes_from_assertion.py 2021-05-17 22:00:09.051310339 +0200
+++ lasso-2.8.2/bindings/python/examples/get_attributes_from_assertion.py 2025-06-18 21:27:46.768394837 +0200
@@ -1,10 +1,9 @@
# Example SP Python code to get attributes from an assertion
-from six import print_
for attribute in assertion.attributeStatement[0].attribute:
if attribute.name == lasso.SAML2_ATTRIBUTE_NAME_EPR:
continue
- print_('attribute : ' + attribute.name)
+ print('attribute : ' + attribute.name)
for value in attribute.attributeValue:
- print_(' value : ' + value.any[0].content)
+ print(' value : ' + value.any[0].content)
Index: lasso-2.8.2/bindings/python/lang.py
===================================================================
--- lasso-2.8.2.orig/bindings/python/lang.py 2021-09-28 10:24:47.113979037 +0200
+++ lasso-2.8.2/bindings/python/lang.py 2025-06-18 21:27:46.768729590 +0200
@@ -19,7 +19,6 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import os
-from six import print_
import sys
import re
import textwrap
@@ -34,9 +33,9 @@
if not '=' in x:
non_opt = True
elif non_opt:
- print_('W: changed', x, file=sys.stderr, end=' ')
+ print('W: changed', x, file=sys.stderr, end=' ')
x = re.sub(' *=.*', '', x)
- print_('to', x, file=sys.stderr)
+ print('to', x, file=sys.stderr)
new_args.append(x)
new_args.reverse()
return new_args
@@ -73,17 +72,17 @@
if not name:
raise Exception('Cannot free, missing a name')
if is_cstring(type):
- print_(' lasso_release_string(%s);' % name, file=fd)
+ print(' lasso_release_string(%s);' % name, file=fd)
elif is_int(type, self.binding_data) or is_boolean(type):
pass
elif is_xml_node(type):
- print_(' lasso_release_xml_node(%s);' % name, file=fd)
+ print(' lasso_release_xml_node(%s);' % name, file=fd)
elif is_glist(type):
etype = element_type(type)
if is_cstring(etype):
- print_(' lasso_release_list_of_strings(%s);' % name, file=fd)
+ print(' lasso_release_list_of_strings(%s);' % name, file=fd)
elif is_object(etype):
- print_(' lasso_release_list_of_gobjects(%s);' % name, file=fd)
+ print(' lasso_release_list_of_gobjects(%s);' % name, file=fd)
else:
raise Exception('Unsupported caller owned return type %s' % ((repr(type), name),))
elif is_hashtable(type):
@@ -91,11 +90,11 @@
k_type = key_type(type)
v_type = value_type(type)
if is_cstring(el_type) or (is_cstring(k_type) and is_cstring(v_type)):
- print_(' if (%s) { g_hash_table_destroy(%s); }' % (name, name), file=fd)
+ print(' if (%s) { g_hash_table_destroy(%s); }' % (name, name), file=fd)
else:
raise Exception('Unsupported free value of type GHashTable: %s' % type)
elif is_object(type):
- print_(' if (return_value) g_object_unref(%s);' % name, file=fd)
+ print(' if (return_value) g_object_unref(%s);' % name, file=fd)
else:
raise Exception('Unsupported caller owned return type %s' % ((repr(type), name),))
@@ -116,7 +115,7 @@
fd.close()
def generate_header(self, fd):
- print_('''\
+ print('''\
# this file has been generated automatically; do not edit
import _lasso
@@ -172,7 +171,7 @@
def generate_exceptions(self, fd):
done_cats = []
- print_('''\
+ print('''\
class Error(Exception):
code = None
@@ -206,7 +205,7 @@
cat = exc_cat.attrib.get('name')
done_cats.append(cat)
parent_cat = exc_cat.attrib.get('parent', '')
- print_('''\
+ print('''\
class %sError(%sError):
pass
''' % (cat, parent_cat), file=fd)
@@ -229,7 +228,7 @@
else:
parent_cat = ''
- print_('''\
+ print('''\
class %sError(%sError):
pass
''' % (cat, parent_cat), file=fd)
@@ -247,19 +246,19 @@
# ordering would change)
continue
- print_('''\
+ print('''\
class %sError(%sError):
pass
''' % (detail, cat), file=fd)
- print_('exceptions_dict = {', file=fd)
+ print('exceptions_dict = {', file=fd)
for k, v in exceptions_dict.items():
- print_(' _lasso.%s: %sError,' % (v, k), file=fd)
- print_('}', file=fd)
- print_('', file=fd)
+ print(' _lasso.%s: %sError,' % (v, k), file=fd)
+ print('}', file=fd)
+ print('', file=fd)
def generate_footer(self, fd):
- print_('''
+ print('''
def _profileGetIssuer(cls, *args, **kwargs):
return profileGetIssuer(*args, **kwargs)
@@ -304,19 +303,19 @@
''', file=fd)
def generate_constants(self, fd):
- print_('### Constants (both enums and defines)', file=fd)
+ print('### Constants (both enums and defines)', file=fd)
for c in self.binding_data.constants:
- print_('%s = _lasso.%s' % (c[1][6:], c[1][6:]), file=fd)
+ print('%s = _lasso.%s' % (c[1][6:], c[1][6:]), file=fd)
for c in self.binding_data.overrides.findall('constant'):
name = c.attrib.get('name')
if c.attrib.get('value'):
name = name[6:] # dropping LASSO_
value = c.attrib.get('value')
if value == 'True':
- print_('%s = True' % name, file=fd)
+ print('%s = True' % name, file=fd)
else:
- print_('E: unknown value for constant: %r' % value, file=sys.stderr)
- print_('', file=fd)
+ print('E: unknown value for constant: %r' % value, file=sys.stderr)
+ print('', file=fd)
def generate_class(self, clss, fd):
klassname = clss.name[5:] # remove Lasso from class name
@@ -325,7 +324,7 @@
else:
parentname = clss.parent[5:]
- print_('''class %(klassname)s(%(parentname)s):''' % locals(), file=fd)
+ print('''class %(klassname)s(%(parentname)s):''' % locals(), file=fd)
methods = clss.methods[:]
# constructor(s)
@@ -348,14 +347,14 @@
c_args = ', '.join(c_args)
py_args = ', ' + ', '.join(py_args)
- print_(' def __init__(self%s):' % py_args, file=fd)
+ print(' def __init__(self%s):' % py_args, file=fd)
# XXX: could check self._cptr.typename to see if it got the
# right class type
- print_(' self._cptr = _lasso.%s(%s)' % (
+ print(' self._cptr = _lasso.%s(%s)' % (
m.name[6:], c_args), file=fd)
- print_(' if self._cptr is None:', file=fd)
- print_(' raise Error(\'failed to create object\')', file=fd)
- print_('', file=fd)
+ print(' if self._cptr is None:', file=fd)
+ print(' raise Error(\'failed to create object\')', file=fd)
+ print('', file=fd)
for m in self.binding_data.functions:
if m.name.startswith(method_prefix + 'new_'):
@@ -379,13 +378,13 @@
if '=' in x:
opt = True
elif opt:
- print_('W: non-optional follows optional,', m, file=sys.stderr)
+ print('W: non-optional follows optional,', m, file=sys.stderr)
c_args = ', '.join(c_args)
py_args = ', ' + ', '.join(py_args)
- print_(' @classmethod', file=fd)
- print_(' def %s(cls%s):' % (constructor_name, py_args), file=fd)
- print_(' return cptrToPy(_lasso.%s(%s))' % (m.name[6:], c_args), file=fd)
- print_('', file=fd)
+ print(' @classmethod', file=fd)
+ print(' def %s(cls%s):' % (constructor_name, py_args), file=fd)
+ print(' return cptrToPy(_lasso.%s(%s))' % (m.name[6:], c_args), file=fd)
+ print('', file=fd)
# create properties for members
for m in clss.members:
@@ -393,13 +392,13 @@
mname = format_as_camelcase(m[1])
options = m[2]
# getter
- print_(' def get_%s(self):' % mname, file=fd)
- print_(' t = _lasso.%s_%s_get(self._cptr)' % (
+ print(' def get_%s(self):' % mname, file=fd)
+ print(' t = _lasso.%s_%s_get(self._cptr)' % (
klassname, mname), file=fd)
if is_int(m, self.binding_data) or is_xml_node(m) or is_cstring(m) or is_boolean(m):
pass
elif is_object(m):
- print_(' t = cptrToPy(t)', file=fd)
+ print(' t = cptrToPy(t)', file=fd)
elif is_glist(m):
el_type = element_type(m)
if is_cstring(el_type):
@@ -407,54 +406,54 @@
elif is_xml_node(el_type):
pass
elif is_object(el_type):
- print_(' if not t: return t', file=fd)
- print_(' t = tuple([cptrToPy(x) for x in t])', file=fd)
+ print(' if not t: return t', file=fd)
+ print(' t = tuple([cptrToPy(x) for x in t])', file=fd)
else:
raise Exception('Unsupported python getter %s.%s' % (clss, m))
elif is_hashtable(m):
el_type = element_type(m)
- print_(' if not t: return t', file=fd)
+ print(' if not t: return t', file=fd)
if is_object(el_type):
- print_(' d2 = {}', file=fd)
- print_(' for k, v in t.items():', file=fd)
- print_(' d2[k] = cptrToPy(v)', file=fd)
- print_(' t = frozendict(d2)', file=fd)
+ print(' d2 = {}', file=fd)
+ print(' for k, v in t.items():', file=fd)
+ print(' d2[k] = cptrToPy(v)', file=fd)
+ print(' t = frozendict(d2)', file=fd)
else:
- print_(' t = frozendict(t)', file=fd)
+ print(' t = frozendict(t)', file=fd)
elif is_boolean(m) or is_int(m, self.binding_data) or is_xml_node(m) or is_cstring(m):
pass
else:
raise Exception('Unsupported python getter %s.%s' % (clss, m))
- print_(' return t;', file=fd)
+ print(' return t;', file=fd)
# setter
- print_(' def set_%s(self, value):' % mname, file=fd)
+ print(' def set_%s(self, value):' % mname, file=fd)
if is_int(m, self.binding_data) or is_xml_node(m) or is_boolean(m):
pass
elif is_cstring(m):
- print_(' value = str2lasso(value)', file=fd)
+ print(' value = str2lasso(value)', file=fd)
elif is_object(m):
- print_(' if value is not None:', file=fd)
- print_(' value = value and value._cptr', file=fd)
+ print(' if value is not None:', file=fd)
+ print(' value = value and value._cptr', file=fd)
elif is_glist(m):
el_type = element_type(m)
if is_cstring(el_type) or is_xml_node(el_type):
pass
elif is_object(el_type):
- print_(' if value is not None:', file=fd)
- print_(' value = tuple([x._cptr for x in value])', file=fd)
+ print(' if value is not None:', file=fd)
+ print(' value = tuple([x._cptr for x in value])', file=fd)
else:
raise Exception('Unsupported python setter %s.%s' % (clss, m))
elif is_hashtable(m):
- print_('W: unsupported setter for hashtable %s' % (m,), file=sys.stderr)
+ print('W: unsupported setter for hashtable %s' % (m,), file=sys.stderr)
else:
- print_('W: unsupported setter for %s' % (m,), file=sys.stderr)
- print_(' _lasso.%s_%s_set(self._cptr, value)' % (
+ print('W: unsupported setter for %s' % (m,), file=sys.stderr)
+ print(' _lasso.%s_%s_set(self._cptr, value)' % (
klassname, mname), file=fd)
- print_(' %s = property(get_%s, set_%s)' % (mname, mname, mname), file=fd)
+ print(' %s = property(get_%s, set_%s)' % (mname, mname, mname), file=fd)
old_mname = old_format_as_camelcase(m[1])
if mname != old_mname:
- print_(' %s = %s' % (old_mname, mname), file=fd)
- print_('', file=fd)
+ print(' %s = %s' % (old_mname, mname), file=fd)
+ print('', file=fd)
# first pass on methods, getting accessors
# second pass on methods, real methods
@@ -464,7 +463,7 @@
m.name.endswith('_new_full'):
continue
if not m.name.startswith(method_prefix):
- print_('W:', m.name, 'vs', method_prefix, file=sys.stderr)
+ print('W:', m.name, 'vs', method_prefix, file=sys.stderr)
continue
if m.rename:
@@ -501,7 +500,7 @@
if '=' in x:
opt = True
elif opt:
- print_('W: non-optional follow optional,', m, file=sys.stderr)
+ print('W: non-optional follow optional,', m, file=sys.stderr)
if py_args:
py_args = ', ' + ', '.join(py_args)
@@ -512,51 +511,51 @@
else:
c_args = ''
- print_(' def %s(self%s):' % (
+ print(' def %s(self%s):' % (
format_underscore_as_camelcase(mname), py_args), file=fd)
if m.docstring:
- print_(" '''", file=fd)
- print_(self.format_docstring(m, mname, 8), file=fd)
- print_(" '''", file=fd)
+ print(" '''", file=fd)
+ print(self.format_docstring(m, mname, 8), file=fd)
+ print(" '''", file=fd)
if outarg:
- print_(" %s = list((None,))" % outvar, file=fd)
+ print(" %s = list((None,))" % outvar, file=fd)
return_type = m.return_type
return_type_qualifier = m.return_type_qualifier
assert is_int(make_arg(return_type),self.binding_data) or not outarg
if return_type in (None, 'void'):
- print_(' _lasso.%s(self._cptr%s)' % (
+ print(' _lasso.%s(self._cptr%s)' % (
function_name, c_args), file=fd)
elif is_rc(m.return_arg):
- print_(' rc = _lasso.%s(self._cptr%s)' % (
+ print(' rc = _lasso.%s(self._cptr%s)' % (
function_name, c_args), file=fd)
- print_(' Error.raise_on_rc(rc)', file=fd)
+ print(' Error.raise_on_rc(rc)', file=fd)
elif (is_int(m.return_arg, self.binding_data) or is_xml_node(m.return_arg) or
is_cstring(m.return_arg) or is_boolean(m.return_arg) or
is_hashtable(m.return_arg)):
- print_(' return _lasso.%s(self._cptr%s)' % (
+ print(' return _lasso.%s(self._cptr%s)' % (
function_name, c_args), file=fd)
elif is_glist(m.return_arg):
el_type = element_type(m.return_arg)
if is_object(el_type):
- print_(' value = _lasso.%s(self._cptr%s)' % (
+ print(' value = _lasso.%s(self._cptr%s)' % (
function_name, c_args), file=fd)
- print_(' if value is not None:', file=fd)
- print_(' value = tuple([cptrToPy(x) for x in value])', file=fd)
- print_(' return value', file=fd)
+ print(' if value is not None:', file=fd)
+ print(' value = tuple([cptrToPy(x) for x in value])', file=fd)
+ print(' return value', file=fd)
elif is_cstring(el_type) or is_xml_node(el_type):
- print_(' return _lasso.%s(self._cptr%s)' % (
+ print(' return _lasso.%s(self._cptr%s)' % (
function_name, c_args), file=fd)
else:
raise Exception('Return Type GList<%s> is not supported' % el_type)
elif is_object(m.return_arg):
- print_(' return cptrToPy(_lasso.%s(self._cptr%s))' % (
+ print(' return cptrToPy(_lasso.%s(self._cptr%s))' % (
function_name, c_args), file=fd)
else:
raise Exception('Return type %s is unsupported' % (m.return_arg,))
if outarg:
- print_(' return %s[0]' % outvar, file=fd)
- print_('', file=fd)
+ print(' return %s[0]' % outvar, file=fd)
+ print('', file=fd)
# transform methods to properties
for m in methods:
if len(m.args) > 1:
@@ -564,7 +563,7 @@
name = m.rename or m.name
suffix = name[len(method_prefix)+len('get_'):]
if clss.getMember(suffix):
- print_('W: method %s and member %s clashes' % (m.name, arg_name(clss.getMember(suffix))), file=sys.stderr)
+ print('W: method %s and member %s clashes' % (m.name, arg_name(clss.getMember(suffix))), file=sys.stderr)
continue
if not name.startswith(method_prefix) or not name[len(method_prefix):].startswith('get_'):
continue
@@ -576,13 +575,13 @@
pname = format_as_camelcase(name[len(method_prefix)+len('get_'):])
fname = format_as_camelcase(name[len(method_prefix):])
if not setter:
- print_(' %s = property(%s)' % (pname, fname), file=fd)
+ print(' %s = property(%s)' % (pname, fname), file=fd)
else:
f2name = format_as_camelcase(setter.name[len(method_prefix):])
- print_(' %s = property(%s, %s)' % (pname, fname, f2name), file=fd)
+ print(' %s = property(%s, %s)' % (pname, fname, f2name), file=fd)
if empty:
- print_(' pass', file=fd)
- print_('', file=fd)
+ print(' pass', file=fd)
+ print('', file=fd)
def format_docstring(self, func, method_name, indent):
if func.args:
@@ -601,7 +600,7 @@
return 'True'
if var == 'FALSE':
return 'False'
- print_('W: unknown docstring thingie: %s' % s.group(1), file=sys.stderr)
+ print('W: unknown docstring thingie: %s' % s.group(1), file=sys.stderr)
elif type == '@':
if var == first_arg_name:
var = 'self'
@@ -686,14 +685,14 @@
else:
name = m.name[6:]
pname = format_as_camelcase(name)
- print_('%s = _lasso.%s' % (pname, name), file=fd)
+ print('%s = _lasso.%s' % (pname, name), file=fd)
def generate_wrapper(self, fd):
- print_(open(os.path.join(self.src_dir,'wrapper_top.c')).read(), file=fd)
+ print(open(os.path.join(self.src_dir,'wrapper_top.c')).read(), file=fd)
for h in self.binding_data.headers:
- print_('#include <%s>' % h, file=fd)
- print_('', file=fd)
+ print('#include <%s>' % h, file=fd)
+ print('', file=fd)
self.generate_constants_wrapper(fd)
@@ -705,33 +704,33 @@
for m in c.methods:
self.generate_function_wrapper(m, fd)
self.generate_wrapper_list(fd)
- print_(open(os.path.join(self.src_dir,'wrapper_bottom.c')).read(), file=fd)
+ print(open(os.path.join(self.src_dir,'wrapper_bottom.c')).read(), file=fd)
def generate_constants_wrapper(self, fd):
- print_('''static void
+ print('''static void
register_constants(PyObject *d)
{
PyObject *obj;
''', file=fd)
for c in self.binding_data.constants:
if c[0] == 'i':
- print_(' obj = PyInt_FromLong(%s);' % c[1], file=fd)
+ print(' obj = PyInt_FromLong(%s);' % c[1], file=fd)
elif c[0] == 's':
- print_(' obj = PyString_FromString((char*)%s);' % c[1], file=fd)
+ print(' obj = PyString_FromString((char*)%s);' % c[1], file=fd)
elif c[0] == 'b':
- print_('''\
+ print('''\
#ifdef %s
obj = Py_True;
#else
obj = Py_False;
#endif''' % c[1], file=fd)
else:
- print_('E: unknown constant type: %r' % c[0], file=sys.stderr)
- print_(' PyDict_SetItemString(d, "%s", obj);' % c[1][6:], file=fd)
+ print('E: unknown constant type: %r' % c[0], file=sys.stderr)
+ print(' PyDict_SetItemString(d, "%s", obj);' % c[1][6:], file=fd)
if c[0] != 'b': # refcount of Py_True/False should not be changed
- print_(' Py_DECREF(obj);', file=fd)
- print_('}', file=fd)
- print_('', file=fd)
+ print(' Py_DECREF(obj);', file=fd)
+ print('}', file=fd)
+ print('', file=fd)
def generate_member_wrapper(self, c, fd):
@@ -740,7 +739,7 @@
name = arg_name(m)
mname = format_as_camelcase(arg_name(m))
# getter
- print_('''static PyObject*
+ print('''static PyObject*
%s_%s_get(G_GNUC_UNUSED PyObject *self, PyObject *args)
{''' % (klassname[5:], mname), file=fd)
self.wrapper_list.append('%s_%s_get' % (klassname[5:], mname))
@@ -748,140 +747,140 @@
ftype = arg_type(m)
if is_cstring(m):
ftype = 'char*'
- print_(' %s return_value;' % ftype, file=fd)
- print_(' PyObject* return_pyvalue;', file=fd)
- print_(' PyGObjectPtr* cvt_this;', file=fd)
- print_(' %s* this;' % klassname, file=fd)
- print_('', file=fd)
- print_(' if (! PyArg_ParseTuple(args, "O", &cvt_this)) return NULL;', file=fd)
- print_(' this = (%s*)cvt_this->obj;' % klassname, file=fd)
- print_(' return_value = this->%s;' % arg_name(m), file=fd)
+ print(' %s return_value;' % ftype, file=fd)
+ print(' PyObject* return_pyvalue;', file=fd)
+ print(' PyGObjectPtr* cvt_this;', file=fd)
+ print(' %s* this;' % klassname, file=fd)
+ print('', file=fd)
+ print(' if (! PyArg_ParseTuple(args, "O", &cvt_this)) return NULL;', file=fd)
+ print(' this = (%s*)cvt_this->obj;' % klassname, file=fd)
+ print(' return_value = this->%s;' % arg_name(m), file=fd)
try:
self.return_value(fd, m)
except:
- print_('W: cannot make an assignment for', c, m, file=sys.stderr)
+ print('W: cannot make an assignment for', c, m, file=sys.stderr)
raise
- print_(' return return_pyvalue;', file=fd)
- print_('}', file=fd)
- print_('', file=fd)
+ print(' return return_pyvalue;', file=fd)
+ print('}', file=fd)
+ print('', file=fd)
# setter
- print_('''static PyObject*
+ print('''static PyObject*
%s_%s_set(G_GNUC_UNUSED PyObject *self, PyObject *args)
{''' % (klassname[5:], mname), file=fd)
self.wrapper_list.append('%s_%s_set' % (klassname[5:], mname))
- print_(' PyGObjectPtr* cvt_this;', file=fd)
- print_(' %s* this;' % klassname, file=fd)
+ print(' PyGObjectPtr* cvt_this;', file=fd)
+ print(' %s* this;' % klassname, file=fd)
type = m[0]
# Determine type class
if is_cstring(m):
type = type.replace('const ', '')
parse_format = 'z'
parse_arg = '&value'
- print_(' %s value;' % type, file=fd)
+ print(' %s value;' % type, file=fd)
elif is_int(m, self.binding_data):
parse_format = 'l'
parse_arg = '&value'
- print_(' long value;', file=fd)
+ print(' long value;', file=fd)
elif is_glist(m) or is_hashtable(m) or is_xml_node(m) or is_boolean(m):
parse_format = 'O'
- print_(' PyObject *cvt_value;', file=fd)
+ print(' PyObject *cvt_value;', file=fd)
parse_arg = '&cvt_value'
elif is_object(m):
parse_format = 'O'
- print_(' PyGObjectPtr *cvt_value;', file=fd)
+ print(' PyGObjectPtr *cvt_value;', file=fd)
parse_arg = '&cvt_value'
else:
raise Exception('Unsupported field: %s' % (m,))
# Get GObject
- print_(' if (! PyArg_ParseTuple(args, "O%s", &cvt_this, %s)) return NULL;' % (
+ print(' if (! PyArg_ParseTuple(args, "O%s", &cvt_this, %s)) return NULL;' % (
parse_format, parse_arg), file=fd)
- print_(' this = (%s*)cvt_this->obj;' % klassname, file=fd)
+ print(' this = (%s*)cvt_this->obj;' % klassname, file=fd)
# Change value
if is_int(m, self.binding_data):
- print_(' this->%s = value;' % name, file=fd)
+ print(' this->%s = value;' % name, file=fd)
elif is_boolean(m):
- print_(' this->%s = PyInt_AS_LONG(cvt_value) ? TRUE : FALSE;' % name, file=fd)
+ print(' this->%s = PyInt_AS_LONG(cvt_value) ? TRUE : FALSE;' % name, file=fd)
elif is_cstring(m):
- print_(' lasso_assign_string(this->%s, value);' % name, file=fd)
+ print(' lasso_assign_string(this->%s, value);' % name, file=fd)
elif is_xml_node(m):
- print_(' if (this->%s) xmlFreeNode(this->%s);' % (name, name), file=fd)
- print_(' this->%s = get_xml_node_from_pystring(cvt_value);' % name, file=fd)
+ print(' if (this->%s) xmlFreeNode(this->%s);' % (name, name), file=fd)
+ print(' this->%s = get_xml_node_from_pystring(cvt_value);' % name, file=fd)
elif is_glist(m):
el_type = element_type(m)
if is_cstring(el_type):
- print_(' RETURN_IF_FAIL(set_list_of_strings(&this->%s, cvt_value));' % name, file=fd)
+ print(' RETURN_IF_FAIL(set_list_of_strings(&this->%s, cvt_value));' % name, file=fd)
elif is_xml_node(el_type):
- print_(' RETURN_IF_FAIL(set_list_of_xml_nodes(&this->%s, cvt_value));' % name, file=fd)
+ print(' RETURN_IF_FAIL(set_list_of_xml_nodes(&this->%s, cvt_value));' % name, file=fd)
elif is_object(el_type):
- print_(' RETURN_IF_FAIL(set_list_of_pygobject(&this->%s, cvt_value));' % name, file=fd)
+ print(' RETURN_IF_FAIL(set_list_of_pygobject(&this->%s, cvt_value));' % name, file=fd)
else:
raise Exception('Unsupported setter for %s' % (m,))
elif is_hashtable(m):
el_type = element_type(m)
if is_object(el_type):
- print_(' RETURN_IF_FAIL(set_hashtable_of_pygobject(this->%s, cvt_value));' % name, file=fd)
+ print(' RETURN_IF_FAIL(set_hashtable_of_pygobject(this->%s, cvt_value));' % name, file=fd)
else:
- print_(' RETURN_IF_FAIL(set_hashtable_of_strings(this->%s, cvt_value));' % name, file=fd)
+ print(' RETURN_IF_FAIL(set_hashtable_of_strings(this->%s, cvt_value));' % name, file=fd)
elif is_object(m):
- print_(' set_object_field((GObject**)&this->%s, cvt_value);' % name, file=fd)
+ print(' set_object_field((GObject**)&this->%s, cvt_value);' % name, file=fd)
else:
raise Exception('Unsupported member %s.%s' % (klassname, m))
- print_(' return noneRef();', file=fd)
- print_('}', file=fd)
- print_('', file=fd)
+ print(' return noneRef();', file=fd)
+ print('}', file=fd)
+ print('', file=fd)
def return_value(self, fd, arg, return_var_name = 'return_value', return_pyvar_name = 'return_pyvalue'):
if is_boolean(arg):
- print_(' if (%s) {' % return_var_name, file=fd)
- print_(' Py_INCREF(Py_True);', file=fd)
- print_(' %s = Py_True;' % return_pyvar_name, file=fd)
- print_(' } else {', file=fd)
- print_(' Py_INCREF(Py_False);', file=fd)
- print_(' %s = Py_False;' % return_pyvar_name, file=fd)
- print_(' }', file=fd)
+ print(' if (%s) {' % return_var_name, file=fd)
+ print(' Py_INCREF(Py_True);', file=fd)
+ print(' %s = Py_True;' % return_pyvar_name, file=fd)
+ print(' } else {', file=fd)
+ print(' Py_INCREF(Py_False);', file=fd)
+ print(' %s = Py_False;' % return_pyvar_name, file=fd)
+ print(' }', file=fd)
elif is_int(arg, self.binding_data):
- print_(' %s = PyInt_FromLong(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' %s = PyInt_FromLong(%s);' % (return_pyvar_name, return_var_name), file=fd)
elif is_cstring(arg) and is_transfer_full(arg):
- print_(' if (%s) {' % return_var_name, file=fd)
- print_(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd)
- print_(' } else {', file=fd)
- print_(' %s = noneRef();' % return_pyvar_name, file=fd)
- print_(' }', file=fd)
+ print(' if (%s) {' % return_var_name, file=fd)
+ print(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' } else {', file=fd)
+ print(' %s = noneRef();' % return_pyvar_name, file=fd)
+ print(' }', file=fd)
elif is_cstring(arg):
- print_(' if (%s) {' % return_var_name, file=fd)
- print_(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd)
- print_(' } else {', file=fd)
- print_(' %s = noneRef();' % return_pyvar_name, file=fd)
- print_(' }', file=fd)
+ print(' if (%s) {' % return_var_name, file=fd)
+ print(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' } else {', file=fd)
+ print(' %s = noneRef();' % return_pyvar_name, file=fd)
+ print(' }', file=fd)
elif is_glist(arg):
el_type = element_type(arg)
if is_object(el_type):
- print_(' %s = get_list_of_pygobject(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' %s = get_list_of_pygobject(%s);' % (return_pyvar_name, return_var_name), file=fd)
elif is_cstring(el_type):
- print_(' %s = get_list_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' %s = get_list_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd)
elif is_xml_node(el_type):
- print_(' %s = get_list_of_xml_nodes(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' %s = get_list_of_xml_nodes(%s);' % (return_pyvar_name, return_var_name), file=fd)
else:
raise Exception('failed to make an assignment for %s' % (arg,))
elif is_hashtable(arg):
el_type = element_type(arg)
if is_object(el_type):
- print_(' %s = get_dict_from_hashtable_of_objects(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' %s = get_dict_from_hashtable_of_objects(%s);' % (return_pyvar_name, return_var_name), file=fd)
else:
- print_(' %s = get_dict_from_hashtable_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' %s = get_dict_from_hashtable_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd)
elif is_xml_node(arg):
# convert xmlNode* to strings
- print_(' if (%s) {' % return_var_name, file=fd)
- print_(' %s = get_pystring_from_xml_node(%s);' % (return_pyvar_name, return_var_name), file=fd)
- print_(' } else {', file=fd)
- print_(' %s = noneRef();' % return_pyvar_name, file=fd)
- print_(' }', file=fd)
+ print(' if (%s) {' % return_var_name, file=fd)
+ print(' %s = get_pystring_from_xml_node(%s);' % (return_pyvar_name, return_var_name), file=fd)
+ print(' } else {', file=fd)
+ print(' %s = noneRef();' % return_pyvar_name, file=fd)
+ print(' }', file=fd)
elif is_object(arg):
# return a PyGObjectPtr (wrapper around GObject)
- print_('''\
+ print('''\
if (%s) {
%s = PyGObjectPtr_New(G_OBJECT(%s));
} else {
@@ -899,7 +898,7 @@
else:
name = m.name[6:]
self.wrapper_list.append(name)
- print_('''static PyObject*
+ print('''static PyObject*
%s(G_GNUC_UNUSED PyObject *self, PyObject *args)
{
int ok = 1;''' % name, file=fd)
@@ -951,21 +950,21 @@
parse_tuple_args.pop()
parse_tuple_args.append('&cvt_%s_out' % aname)
python_cvt_def = ' PyObject *cvt_%s_out = NULL;' % aname
- print_(' PyObject *out_pyvalue = NULL;', file=fd)
- print_(arg_def, file=fd)
+ print(' PyObject *out_pyvalue = NULL;', file=fd)
+ print(arg_def, file=fd)
if python_cvt_def:
- print_(python_cvt_def, file=fd)
+ print(python_cvt_def, file=fd)
if m.return_type:
- print_(' %s return_value;' % m.return_type, file=fd)
- print_(' PyObject* return_pyvalue = NULL;', file=fd)
- print_('', file=fd)
+ print(' %s return_value;' % m.return_type, file=fd)
+ print(' PyObject* return_pyvalue = NULL;', file=fd)
+ print('', file=fd)
parse_tuple_args = ', '.join(parse_tuple_args)
if parse_tuple_args:
parse_tuple_args = ', ' + parse_tuple_args
- print_(' if (! PyArg_ParseTuple(args, "%s"%s)) return NULL;' % (
+ print(' if (! PyArg_ParseTuple(args, "%s"%s)) return NULL;' % (
''.join(parse_tuple_format), parse_tuple_args), file=fd)
for f, arg in zip([ x for x in parse_tuple_format if x != '|'], m.args):
@@ -974,48 +973,48 @@
if is_list(arg):
qualifier = element_type(arg)
if is_cstring(qualifier):
- print_(' EXIT_IF_FAIL(set_list_of_strings(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
+ print(' EXIT_IF_FAIL(set_list_of_strings(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
elif is_xml_node(qualifier):
- print_(' EXIT_IF_FAIL(set_list_of_xml_nodes(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
+ print(' EXIT_IF_FAIL(set_list_of_xml_nodes(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
elif isinstance(qualifier, str) and qualifier.startswith('Lasso'):
- print_(' EXIT_IF_FAIL(set_list_of_pygobject(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
+ print(' EXIT_IF_FAIL(set_list_of_pygobject(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
else:
- print_('E: unqualified GList argument in', name, qualifier, arg, file=sys.stderr)
+ print('E: unqualified GList argument in', name, qualifier, arg, file=sys.stderr)
elif is_xml_node(arg):
- print_(' %s = get_xml_node_from_pystring(cvt_%s);' % (arg[1], arg[1]), file=fd)
+ print(' %s = get_xml_node_from_pystring(cvt_%s);' % (arg[1], arg[1]), file=fd)
elif is_time_t_pointer(arg):
- print_(' %s = get_time_t(cvt_%s);' % (arg[1], arg[1]), file=fd)
+ print(' %s = get_time_t(cvt_%s);' % (arg[1], arg[1]), file=fd)
elif is_hashtable(arg):
el_type = element_type(arg)
k_type = key_type(arg)
v_type = value_type(arg)
if is_cstring(el_type) or (is_cstring(k_type) and is_cstring(v_type)):
- print_(' %s = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);' % arg[1], file=fd)
- print_(' EXIT_IF_FAIL(set_hashtable_of_strings(%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
+ print(' %s = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);' % arg[1], file=fd)
+ print(' EXIT_IF_FAIL(set_hashtable_of_strings(%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
elif f == 'O':
if is_optional(arg):
- print_(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd)
- print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd)
- print_(' } else {', file=fd)
- print_(' %s = NULL;' % arg[1], file=fd)
- print_(' }', file=fd)
+ print(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd)
+ print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd)
+ print(' } else {', file=fd)
+ print(' %s = NULL;' % arg[1], file=fd)
+ print(' }', file=fd)
else:
- print_(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd)
- print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd)
- print_(' } else {', file=fd)
- print_(' PyErr_SetString(PyExc_TypeError, "value should be a PyGObject");', file=fd)
- print_(' return NULL;', file=fd)
- print_(' }', file=fd)
+ print(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd)
+ print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd)
+ print(' } else {', file=fd)
+ print(' PyErr_SetString(PyExc_TypeError, "value should be a PyGObject");', file=fd)
+ print(' return NULL;', file=fd)
+ print(' }', file=fd)
if m.return_type:
- print_(' return_value = ', file=fd, end='')
+ print(' return_value = ', file=fd, end='')
if 'new' in m.name:
- print_('(%s)' % m.return_type, file=fd)
+ print('(%s)' % m.return_type, file=fd)
else:
- print_(' ', file=fd, end='')
- print_('%s(%s);' % (m.name, ', '.join([ref_name(x) for x in m.args])), file=fd)
+ print(' ', file=fd, end='')
+ print('%s(%s);' % (m.name, ', '.join([ref_name(x) for x in m.args])), file=fd)
if m.return_type:
# Constructor so decrease refcount (it was incremented by PyGObjectPtr_New called
@@ -1023,7 +1022,7 @@
try:
self.return_value(fd, m.return_arg)
except:
- print_('W: cannot assign return value of', m, file=sys.stderr)
+ print('W: cannot assign return value of', m, file=sys.stderr)
raise
if is_transfer_full(m.return_arg, default=True):
@@ -1033,48 +1032,48 @@
if is_out(arg):
self.return_value(fd, arg, return_var_name = arg[1], return_pyvar_name = 'out_pyvalue')
- print_(' EXIT_IF_FAIL(%s);' % arg[1], file=fd)
- print_(' if (PyList_SetItem(cvt_%s_out, 0, out_pyvalue) == -1) {' % arg[1], file=fd)
- print_(' ok = 0;', file=fd)
- print_(' Py_XDECREF(out_pyvalue);', file=fd)
- print_(' }', file=fd)
+ print(' EXIT_IF_FAIL(%s);' % arg[1], file=fd)
+ print(' if (PyList_SetItem(cvt_%s_out, 0, out_pyvalue) == -1) {' % arg[1], file=fd)
+ print(' ok = 0;', file=fd)
+ print(' Py_XDECREF(out_pyvalue);', file=fd)
+ print(' }', file=fd)
elif arg[0] == 'GList*':
qualifier = arg[2].get('element-type')
if is_cstring(qualifier):
- print_(' free_list(&%s, (GFunc)g_free);' % arg[1], file=fd)
+ print(' free_list(&%s, (GFunc)g_free);' % arg[1], file=fd)
elif is_xml_node(qualifier):
- print_(' free_list(&%s, (GFunc)xmlFreeNode);' % arg[1], file=fd)
+ print(' free_list(&%s, (GFunc)xmlFreeNode);' % arg[1], file=fd)
elif is_object(qualifier):
- print_(' free_list(&%s, (GFunc)g_object_unref);' % arg[1], file=fd)
+ print(' free_list(&%s, (GFunc)g_object_unref);' % arg[1], file=fd)
elif is_time_t_pointer(arg):
- print_(' if (%s) free(%s);' % (arg[1], arg[1]), file=fd)
+ print(' if (%s) free(%s);' % (arg[1], arg[1]), file=fd)
elif not is_transfer_full(arg) and is_hashtable(arg):
self.free_value(fd, arg)
elif not is_transfer_full(arg) and is_xml_node(arg):
self.free_value(fd, arg)
- print_('failure:', file=fd)
+ print('failure:', file=fd)
if not m.return_type:
- print_(' if (ok) {', file=fd)
- print_(' return noneRef();', file=fd)
+ print(' if (ok) {', file=fd)
+ print(' return noneRef();', file=fd)
else:
- print_(' if (ok && return_pyvalue) {', file=fd)
- print_(' return return_pyvalue;', file=fd)
- print_(' } else {', file=fd)
+ print(' if (ok && return_pyvalue) {', file=fd)
+ print(' return return_pyvalue;', file=fd)
+ print(' } else {', file=fd)
if m.return_type:
- print_(' Py_XDECREF(return_pyvalue);', file=fd)
- print_(' return NULL;', file=fd)
- print_(' }', file=fd)
- print_('}', file=fd)
- print_('', file=fd)
+ print(' Py_XDECREF(return_pyvalue);', file=fd)
+ print(' return NULL;', file=fd)
+ print(' }', file=fd)
+ print('}', file=fd)
+ print('', file=fd)
def generate_wrapper_list(self, fd):
- print_('''
+ print('''
static PyMethodDef lasso_methods[] = {''', file=fd)
for m in self.wrapper_list:
- print_(' {"%s", %s, METH_VARARGS, NULL},' % (m, m), file=fd)
- print_(' {NULL, NULL, 0, NULL}', file=fd)
- print_('};', file=fd)
- print_('', file=fd)
+ print(' {"%s", %s, METH_VARARGS, NULL},' % (m, m), file=fd)
+ print(' {NULL, NULL, 0, NULL}', file=fd)
+ print('};', file=fd)
+ print('', file=fd)
Index: lasso-2.8.2/bindings/python/tests/XmlTestRunner.py
===================================================================
--- lasso-2.8.2.orig/bindings/python/tests/XmlTestRunner.py 2021-05-17 22:00:09.051310339 +0200
+++ lasso-2.8.2/bindings/python/tests/XmlTestRunner.py 2025-06-18 21:27:46.769338054 +0200
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# $Id: XmlTestRunner.py 3254 2007-06-05 21:23:57Z fpeters $
#
@@ -25,7 +24,6 @@
import unittest
import time
import sys
-from six import print_
def xml(text):
if not text:
@@ -34,14 +32,14 @@
class XmlTestResult(unittest.TestResult):
def addSuccess(self, test):
- print_(""" <test result="success">
+ print(""" <test result="success">
<id>%s</id>
<description>%s</description>
</test>""" % (test.id(), xml(test.shortDescription())))
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
- print_(""" <test result="error">
+ print(""" <test result="error">
<id>%s</id>
<description>%s</description>
</test>""" % (test.id(), xml(test.shortDescription())))
@@ -49,7 +47,7 @@
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
- print_(""" <test result="failure">
+ print(""" <test result="failure">
<id>%s</id>
<description>%s</description>
</test>""" % (test.id(), xml(test.shortDescription())))
@@ -61,14 +59,14 @@
return XmlTestResult()
def run(self, test):
- print_("<suite>")
+ print("<suite>")
result = self._makeResult()
startTime = time.time()
test(result)
stopTime = time.time()
timeTaken = float(stopTime - startTime)
- print_(" <duration>%s</duration>" % timeTaken)
- print_("</suite>")
+ print(" <duration>%s</duration>" % timeTaken)
+ print("</suite>")
return result
Index: lasso-2.8.2/bindings/python/tests/tests.py
===================================================================
--- lasso-2.8.2.orig/bindings/python/tests/tests.py 2025-06-18 21:27:33.094107516 +0200
+++ lasso-2.8.2/bindings/python/tests/tests.py 2025-06-18 21:27:46.769588507 +0200
@@ -30,7 +30,6 @@
import sys
import time
import unittest
-from six import print_
from XmlTestRunner import XmlTestRunner
@@ -60,10 +59,10 @@
__builtin__.__dict__['dataDir'] = os.path.join(options.srcDir, '../../../tests/data')
if options.xmlMode:
- print_('<?xml version="1.0"?>')
- print_('<testsuites xmlns="http://check.sourceforge.net/ns">')
- print_(' <title>Python Bindings</title>')
- print_(' <datetime>%s</datetime>' % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
+ print('<?xml version="1.0"?>')
+ print('<testsuites xmlns="http://check.sourceforge.net/ns">')
+ print(' <title>Python Bindings</title>')
+ print(' <datetime>%s</datetime>' % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
success = True
for testSuite in testSuites:
@@ -74,7 +73,7 @@
if fp:
fp.close()
if not module:
- print_('Unable to load test suite:', testSuite, file=sys.stderr)
+ print('Unable to load test suite:', testSuite, file=sys.stderr)
continue
if module.__doc__:
@@ -87,13 +86,13 @@
else:
runner = unittest.TextTestRunner(verbosity=2)
print
- print_('-' * len(doc))
- print_(doc)
- print_('-' * len(doc))
+ print('-' * len(doc))
+ print(doc)
+ print('-' * len(doc))
result = runner.run(module.allTests)
success = success and result.wasSuccessful()
if options.xmlMode:
- print_('</testsuites>')
+ print('</testsuites>')
sys.exit(not success)
Index: lasso-2.8.2/configure.ac
===================================================================
--- lasso-2.8.2.orig/configure.ac 2023-03-06 12:05:02.761160572 +0100
+++ lasso-2.8.2/configure.ac 2025-06-18 21:27:46.769832466 +0200
@@ -133,7 +133,7 @@
AC_CHECK_PROGS(PHP5_CONFIG, php-config5 php-config)
AC_CHECK_PROGS(PHP7, php7.4 php7.3 php7.2 php7.1 php7.0 php7 php)
AC_CHECK_PROGS(PHP7_CONFIG, php-config7.4 php-config7.3 php-config7.2 php-config7.1 php-config7.0 php-config7 php-config)
-AC_CHECK_PROGS(PYTHON, python3 python python2)
+AC_CHECK_PROGS(PYTHON, python3 python)
AC_CHECK_PROGS(SWIG, swig)
dnl Make sure we have an ANSI compiler
Index: lasso-2.8.2/lasso/build_strerror.py
===================================================================
--- lasso-2.8.2.orig/lasso/build_strerror.py 2025-06-18 21:27:17.236364820 +0200
+++ lasso-2.8.2/lasso/build_strerror.py 2025-06-18 21:27:46.770076564 +0200
@@ -4,14 +4,14 @@
import re
import sys
import os
-from six import print_, StringIO
+from io import StringIO
srcdir = sys.argv[1]
messages = dict()
description = ''
-with open('%s/errors.h' % srcdir,'r') as f:
+with open('%s/errors.h' % srcdir) as f:
for line in f:
m = re.match(r'^ \* LASSO.*ERROR', line)
if m:
@@ -30,13 +30,13 @@
if m:
messages[m.group(1)] = m.group(1)
-with open('%s/errors.c.in' % srcdir,'r') as f:
+with open('%s/errors.c.in' % srcdir) as f:
for line in f:
if '@ERROR_CASES@' in line:
keys = sorted(messages.keys())
for k in keys:
- print_(' case %s:\n'
+ print(' case %s:\n'
' return "%s";' %
(k,messages[k].rstrip('\n')))
else:
- print_(line, end="")
+ print(line, end="")
Index: lasso-2.8.2/lasso/extract_sections.py
===================================================================
--- lasso-2.8.2.orig/lasso/extract_sections.py 2025-06-18 21:27:17.236654944 +0200
+++ lasso-2.8.2/lasso/extract_sections.py 2025-06-18 21:27:46.770285391 +0200
@@ -5,7 +5,6 @@
import sys
import os
import os.path
-from six import print_
if len(sys.argv) == 2:
srcdir = sys.argv[1]
@@ -19,21 +18,21 @@
prefixes.append(os.path.splitext(file)[0])
for prefix in prefixes:
try:
- header = io.open(os.path.join(root, prefix + '.h'), encoding='utf-8').read()
- implementation = io.open(os.path.join(root, prefix + '.c'), encoding='utf-8').read()
- exported_functions = re.findall('LASSO_EXPORT.*(lasso_\w*)', header)
+ header = open(os.path.join(root, prefix + '.h'), encoding='utf-8').read()
+ implementation = open(os.path.join(root, prefix + '.c'), encoding='utf-8').read()
+ exported_functions = re.findall(r'LASSO_EXPORT.*(lasso_\w*)', header)
normal_functions = sorted ([ x for x in exported_functions if not x.endswith('get_type') ])
get_type = [ x for x in exported_functions if x.endswith('get_type') ][0]
file_name = re.findall('lasso_(.*)_get_type', get_type)[0]
try:
- macro_type = re.findall('LASSO_(\w*)_CLASS\(', header)[0]
+ macro_type = re.findall(r'LASSO_(\w*)_CLASS\(', header)[0]
except:
macro_type = None
try:
type = re.findall(r'^struct _(Lasso\w*)', header, re.MULTILINE)[0]
except:
type = None
- types = re.findall('^} (Lasso\w*);', header)
+ types = re.findall(r'^} (Lasso\w*);', header)
def convert(x):
if '%s' in x:
return x % macro_type
@@ -41,17 +40,17 @@
return x
if type and macro_type:
standard_decl = [ convert(x) for x in [ 'LASSO_%s', 'LASSO_IS_%s', 'LASSO_TYPE_%s', get_type, 'LASSO_%s_CLASS', 'LASSO_IS_%s_CLASS', 'LASSO_%s_GET_CLASS' ] ]
- print_('')
- print_('<SECTION>')
- print_('<FILE>%s</FILE>' % file_name)
- print_('<TITLE>%s</TITLE>' % type)
- print_(type)
+ print('')
+ print('<SECTION>')
+ print('<FILE>%s</FILE>' % file_name)
+ print('<TITLE>%s</TITLE>' % type)
+ print(type)
for x in types + normal_functions:
- print_(x)
- print_('<SUBSECTION Standard>')
+ print(x)
+ print('<SUBSECTION Standard>')
for x in standard_decl:
- print_(x)
- print_('</SECTION>')
+ print(x)
+ print('</SECTION>')
except:
continue
Index: lasso-2.8.2/lasso/extract_symbols.py
===================================================================
--- lasso-2.8.2.orig/lasso/extract_symbols.py 2025-06-18 21:27:17.236878508 +0200
+++ lasso-2.8.2/lasso/extract_symbols.py 2025-06-18 21:27:46.770437158 +0200
@@ -4,7 +4,6 @@
import glob
import re
import sys
-import six
if len(sys.argv) == 2:
srcdir = sys.argv[1]
@@ -17,8 +16,8 @@
for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*.h' % srcdir) + \
glob.glob('%s/*/*/*.h' % srcdir):
assert not ('/id-wsf/' in header_file or '/id-wsf-2.0' in header_file)
- symbols.extend(regex.findall(io.open(header_file, encoding='utf-8').read().replace('\\\n', '')))
+ symbols.extend(regex.findall(open(header_file, encoding='utf-8').read().replace('\\\n', '')))
for s in symbols:
- six.print_(s)
+ print(s)
Index: lasso-2.8.2/lasso/extract_types.py
===================================================================
--- lasso-2.8.2.orig/lasso/extract_types.py 2025-06-18 21:27:17.237043056 +0200
+++ lasso-2.8.2/lasso/extract_types.py 2025-06-18 21:27:46.770600309 +0200
@@ -4,7 +4,6 @@
import glob
import re
import sys
-import six
if len(sys.argv) == 2:
srcdir = sys.argv[1]
@@ -14,30 +13,30 @@
fd = io.StringIO()
-six.print_(u"/* This file has been autogenerated; changes will be lost */", file=fd)
-six.print_(u"", file=fd)
-six.print_(u"typedef GType (*type_function) ();", file=fd)
-six.print_(u"", file=fd)
+print("/* This file has been autogenerated; changes will be lost */", file=fd)
+print("", file=fd)
+print("typedef GType (*type_function) ();", file=fd)
+print("", file=fd)
header_files = []
for header_file in sorted(glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % srcdir)):
assert not ('/id-wsf/' in header_file or '/id-wsf-2.0' in header_file)
header_files.append(header_file)
try:
- type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
+ type = re.findall('lasso_.*get_type', open(header_file, encoding='utf-8').read())[0]
except IndexError:
continue
- six.print_("extern GType %s();" % type, file=fd)
+ print("extern GType %s();" % type, file=fd)
-six.print_(u"", file=fd)
-six.print_(u"type_function functions[] = {", file=fd)
+print("", file=fd)
+print("type_function functions[] = {", file=fd)
for header_file in header_files:
try:
- type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
+ type = re.findall('lasso_.*get_type', open(header_file, encoding='utf-8').read())[0]
except IndexError:
continue
- six.print_(u"\t%s," % type, file=fd)
-six.print_(u"\tNULL", file=fd)
-six.print_(u"};", file=fd)
+ print("\t%s," % type, file=fd)
+print("\tNULL", file=fd)
+print("};", file=fd)
-io.open('types.c', 'w', encoding='utf-8').write(fd.getvalue())
+open('types.c', 'w', encoding='utf-8').write(fd.getvalue())
Index: lasso-2.8.2/lasso/id-ff/provider.h
===================================================================
--- lasso-2.8.2.orig/lasso/id-ff/provider.h 2021-09-11 19:20:25.852638017 +0200
+++ lasso-2.8.2/lasso/id-ff/provider.h 2025-06-18 21:41:20.767758430 +0200
@@ -284,7 +284,7 @@
LASSO_EXPORT void lasso_provider_set_key_encryption_method(
LassoProvider *provider, LassoKeyEncryptionMethod method);
-LASSO_EXPORT LassoKeyEncryptionMethod lasso_provider_get_key_encryption_method();
+LASSO_EXPORT LassoKeyEncryptionMethod lasso_provider_get_key_encryption_method(const LassoProvider* provider);
#ifdef __cplusplus
Index: lasso-2.8.2/lasso/registry-private.h
===================================================================
--- lasso-2.8.2.orig/lasso/registry-private.h 2021-09-03 08:15:49.818436908 +0200
+++ lasso-2.8.2/lasso/registry-private.h 2025-06-18 21:47:03.979076528 +0200
@@ -39,7 +39,7 @@
};
LassoRegistry *lasso_registry_new();
-void lasso_registry_destroy();
+void lasso_registry_destroy(LassoRegistry *registry);
void lasso_registry_default_shutdown();
gint lasso_registry_add_direct_mapping(LassoRegistry *registry, const char *from_namespace,
const char *from_name, const char *to_namespace, const char *to_name);
Index: lasso-2.8.2/lasso/utils.h
===================================================================
--- lasso-2.8.2.orig/lasso/utils.h 2021-09-06 10:36:35.111573704 +0200
+++ lasso-2.8.2/lasso/utils.h 2025-06-18 21:34:24.739436545 +0200
@@ -70,7 +70,7 @@
/**
* lasso_unref:
* @object: an object whose reference count must be decremented.
- *
+ *
* Decrement the reference count of an object, do not emit warnings if it is NULL.
*
* Return value: the @object.
@@ -190,13 +190,13 @@
lasso_release_full(dest, g_hash_table_destroy)
#define lasso_release_gstring(dest, b) \
- { \
+ ({ \
GString **__tmp = &(dest); \
- if (*__tmp) {\
- g_string_free(*__tmp, (b)); \
+ if (*__tmp) { \
+ g_string_free(*__tmp, TRUE); /* Always free the segment */ \
*__tmp = NULL; \
} \
- }
+ })
#define lasso_release_array_of_xml_strings(dest) \
{ \
Index: lasso-2.8.2/tools/api.py
===================================================================
--- lasso-2.8.2.orig/tools/api.py 2021-09-11 19:20:25.856638071 +0200
+++ lasso-2.8.2/tools/api.py 2025-06-18 21:27:46.770754870 +0200
@@ -2,7 +2,6 @@
import os.path
sys.path.append(os.path.join(os.path.dirname(__file__),'../bindings'))
import bindings
-from six import print_
def main(args):
@@ -29,16 +28,16 @@
l = sorted(d.keys())
for x in l:
if isinstance(d[x], bindings.Function):
- print_(d[x].return_type, " ",)
- print_(x, end='')
- print_('(', ', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].args)), ')')
+ print(d[x].return_type, " ",)
+ print(x, end='')
+ print('(', ', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].args)), ')')
elif isinstance(d[x], bindings.Struct):
- print_('struct', x, '{ ',)
- print_(', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].members)),
+ print('struct', x, '{ ',)
+ print(', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].members)),
end='')
- print_(' }')
+ print(' }')
else:
- print_(x)
+ print(x)
if __name__ == "__main__":
main(sys.argv)
Index: lasso-2.8.2/tools/check-lasso-sections.py
===================================================================
--- lasso-2.8.2.orig/tools/check-lasso-sections.py 2025-06-18 21:27:17.237215845 +0200
+++ lasso-2.8.2/tools/check-lasso-sections.py 2025-06-18 21:27:46.770973545 +0200
@@ -3,10 +3,9 @@
import sys
import os.path
import re
-from six import print_
if len(sys.argv) < 3:
- print_("Usage: check-lasso-sections.py "
+ print("Usage: check-lasso-sections.py "
"lasso docs/referenrece/lasso/lasso-sections.txt",
file=sys.stderr)
sys.exit(1)
@@ -34,13 +33,13 @@
lasso_sections_txt=file(lasso_sections_txt).read()
-print_(' = Methods missing from lasso-sections.txt =\n')
+print(' = Methods missing from lasso-sections.txt =\n')
for method in methods:
if not method in lasso_sections_txt:
- print_(method)
+ print(method)
-print_(' = Methods in lasso-sections.txt which does not exist anymore = \n')
+print(' = Methods in lasso-sections.txt which does not exist anymore = \n')
for line in lasso_sections_txt.splitlines():
if line.startswith('lasso_'):
if line not in methods:
- print_(line)
+ print(line)
Index: lasso-2.8.2/tools/format-suppressions.py
===================================================================
--- lasso-2.8.2.orig/tools/format-suppressions.py 2021-05-17 22:00:09.275307814 +0200
+++ lasso-2.8.2/tools/format-suppressions.py 2025-06-18 21:27:46.771164563 +0200
@@ -1,7 +1,6 @@
import re
-from six import print_
-valgrind_log = open('log','r').read()
+valgrind_log = open('log').read()
inblock = False
l = 0
@@ -34,11 +33,11 @@
i = 43
for x in keep:
block = keep[x]
- print_("{")
- print_(" suppression", i)
+ print("{")
+ print(" suppression", i)
for x in block[1:]:
- print_(x)
+ print(x)
if re.search(limit_re, x):
break
- print_('}')
+ print('}')
i += 1