summaryrefslogtreecommitdiff
path: root/examples/gen_ctypes.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gen_ctypes.py')
-rw-r--r--examples/gen_ctypes.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/gen_ctypes.py b/examples/gen_ctypes.py
index 9e74819..e79798f 100644
--- a/examples/gen_ctypes.py
+++ b/examples/gen_ctypes.py
@@ -102,7 +102,7 @@ def getUDType(typestr):
key = typestr.rstrip(" *")
if key not in typemap:
user_defined_types.add(key)
- typemap[key] = "%s_%s" % (module, key)
+ typemap[key] = "{}_{}".format(module, key)
def typeAsCtypes(typestr):
if typestr in typemap:
@@ -140,13 +140,13 @@ for en_,_,_ in enum_def.scanString(c_header):
enum_constants.append( (ev.name, ev.value) )
print("from ctypes import *")
-print("%s = CDLL('%s.dll')" % (module, module))
+print("{} = CDLL('{}.dll')".format(module, module))
print()
print("# user defined types")
for tdname,tdtyp in typedefs:
- print("%s = %s" % (tdname, typemap[tdtyp]))
+ print("{} = {}".format(tdname, typemap[tdtyp]))
for fntd in fn_typedefs:
- print("%s = CFUNCTYPE(%s)" % (fntd.fn_name,
+ print("{} = CFUNCTYPE({})".format(fntd.fn_name,
',\n '.join(typeAsCtypes(a.argtype) for a in fntd.fn_args)))
for udtype in user_defined_types:
print("class %s(Structure): pass" % typemap[udtype])
@@ -154,20 +154,20 @@ for udtype in user_defined_types:
print()
print("# constant definitions")
for en,ev in enum_constants:
- print("%s = %s" % (en,ev))
+ print("{} = {}".format(en,ev))
print()
print("# functions")
for fn in functions:
- prefix = "%s.%s" % (module, fn.fn_name)
+ prefix = "{}.{}".format(module, fn.fn_name)
- print("%s.restype = %s" % (prefix, typeAsCtypes(fn.fn_type)))
+ print("{}.restype = {}".format(prefix, typeAsCtypes(fn.fn_type)))
if fn.varargs:
print("# warning - %s takes variable argument list" % prefix)
del fn.fn_args[-1]
if fn.fn_args.asList() != [['void']]:
- print("%s.argtypes = (%s,)" % (prefix, ','.join(typeAsCtypes(a.argtype) for a in fn.fn_args)))
+ print("{}.argtypes = ({},)".format(prefix, ','.join(typeAsCtypes(a.argtype) for a in fn.fn_args)))
else:
print("%s.argtypes = ()" % (prefix))