extract_types.py: force io to use UTF-8 encoding (fixes #27332)
This commit is contained in:
parent
14febd3c5f
commit
580aca65b1
|
@ -1,9 +1,9 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import io
|
||||
import glob
|
||||
import re
|
||||
import sys
|
||||
from six.moves import cStringIO as StringIO
|
||||
import six
|
||||
|
||||
enable_wsf = 0
|
||||
|
@ -24,12 +24,12 @@ wsf = ['lasso_disco_', 'lasso_dst_', 'lasso_is_', 'lasso_profile_service_',
|
|||
if enable_wsf:
|
||||
wsf = []
|
||||
|
||||
fd = StringIO()
|
||||
fd = io.StringIO()
|
||||
|
||||
six.print_("/* This file has been autogenerated; changes will be lost */", file=fd)
|
||||
six.print_("", file=fd)
|
||||
six.print_("typedef GType (*type_function) ();", file=fd)
|
||||
six.print_("", file=fd)
|
||||
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)
|
||||
|
||||
header_files = []
|
||||
for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % srcdir):
|
||||
|
@ -37,7 +37,7 @@ for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % src
|
|||
continue
|
||||
header_files.append(header_file)
|
||||
try:
|
||||
type = re.findall('lasso_.*get_type', open(header_file).read())[0]
|
||||
type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
|
||||
except IndexError:
|
||||
continue
|
||||
for t in wsf:
|
||||
|
@ -46,19 +46,19 @@ for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % src
|
|||
else:
|
||||
six.print_("extern GType %s();" % type, file=fd)
|
||||
|
||||
six.print_("", file=fd)
|
||||
six.print_("type_function functions[] = {", file=fd)
|
||||
six.print_(u"", file=fd)
|
||||
six.print_(u"type_function functions[] = {", file=fd)
|
||||
for header_file in header_files:
|
||||
try:
|
||||
type = re.findall('lasso_.*get_type', open(header_file).read())[0]
|
||||
type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
|
||||
except IndexError:
|
||||
continue
|
||||
for t in wsf:
|
||||
if type.startswith(t):
|
||||
break
|
||||
else:
|
||||
six.print_("\t%s," % type, file=fd)
|
||||
six.print_("\tNULL", file=fd)
|
||||
six.print_("};", file=fd)
|
||||
six.print_(u"\t%s," % type, file=fd)
|
||||
six.print_(u"\tNULL", file=fd)
|
||||
six.print_(u"};", file=fd)
|
||||
|
||||
open('types.c', 'w').write(fd.getvalue())
|
||||
io.open('types.c', 'w', encoding='utf-8').write(fd.getvalue())
|
||||
|
|
Loading…
Reference in New Issue