iso8859-1 -> latin-1

This commit is contained in:
Thomas Nagy 2017-01-21 13:28:06 +01:00
parent 87bf7ae1fa
commit f1487eab44
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
18 changed files with 38 additions and 38 deletions

View File

@ -19,7 +19,7 @@ def build(bld):
features = 'subst', # the feature 'subst' overrides the source/target processing features = 'subst', # the feature 'subst' overrides the source/target processing
source = 'foo.in', # list of string or nodes source = 'foo.in', # list of string or nodes
target = 'foo.txt', # list of strings or nodes target = 'foo.txt', # list of strings or nodes
encoding = 'ascii', # file encoding for python3, default is ISO8859-1 encoding = 'ascii', # file encoding for python3, default is latin-1
install_path = '/tmp/uff/', # installation path, optional install_path = '/tmp/uff/', # installation path, optional
chmod = Utils.O755, # installation mode, optional chmod = Utils.O755, # installation mode, optional
PREFIX = bld.env.PREFIX, # variables to use in the substitution PREFIX = bld.env.PREFIX, # variables to use in the substitution

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: ISO8859-1 # encoding: utf-8
# Thomas Nagy, 2010 # Thomas Nagy, 2010
top = '.' top = '.'

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: ISO8859-1 # encoding: utf-8
# Thomas Nagy, 2010 # Thomas Nagy, 2010
from waflib import Logs from waflib import Logs

View File

@ -1,10 +1,10 @@
#! /usr/bin/env python #! /usr/bin/env python
# encoding: ISO8859-1 # encoding: utf-8
# Thomas Nagy, 2014-2015 # Thomas Nagy, 2014-2015
""" """
A simple file for verifying signatures in signed waf files A simple file for verifying signatures in signed waf files
This script is meant for Python >= 2.6 and the encoding is bytes - ISO8859-1 This script is meant for Python >= 2.6 and the encoding is bytes - latin-1
Distributing detached signatures is boring Distributing detached signatures is boring
""" """
@ -33,14 +33,14 @@ if __name__ == '__main__':
try: try:
txt = f.read() txt = f.read()
lastline = txt.decode('ISO8859-1').splitlines()[-1] # just the last line lastline = txt.decode('latin-1').splitlines()[-1] # just the last line
if not lastline.startswith('#-----BEGIN PGP SIGNATURE-----'): if not lastline.startswith('#-----BEGIN PGP SIGNATURE-----'):
print("ERROR: there is no signature to verify in %r :-/" % infile) print("ERROR: there is no signature to verify in %r :-/" % infile)
sys.exit(1) sys.exit(1)
sigtext = lastline.replace('\\n', '\n') # convert newlines sigtext = lastline.replace('\\n', '\n') # convert newlines
sigtext = sigtext[1:] # omit the '# character' sigtext = sigtext[1:] # omit the '# character'
sigtext = sigtext.encode('ISO8859-1') # python3 sigtext = sigtext.encode('latin-1') # python3
f2.write(sigtext) f2.write(sigtext)
f1.write(txt[:-len(lastline) - 1]) # one newline character was eaten from splitlines() f1.write(txt[:-len(lastline) - 1]) # one newline character was eaten from splitlines()

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: ISO8859-1 # encoding: latin-1
# Thomas Nagy, 2005-2016 # Thomas Nagy, 2005-2016
# #
""" """

View File

@ -355,14 +355,14 @@ class Context(ctx):
if out: if out:
if not isinstance(out, str): if not isinstance(out, str):
out = out.decode(sys.stdout.encoding or 'iso8859-1', errors='replace') out = out.decode(sys.stdout.encoding or 'latin-1', errors='replace')
if self.logger: if self.logger:
self.logger.debug('out: %s', out) self.logger.debug('out: %s', out)
else: else:
Logs.info(out, extra={'stream':sys.stdout, 'c1': ''}) Logs.info(out, extra={'stream':sys.stdout, 'c1': ''})
if err: if err:
if not isinstance(err, str): if not isinstance(err, str):
err = err.decode(sys.stdout.encoding or 'iso8859-1', errors='replace') err = err.decode(sys.stdout.encoding or 'latin-1', errors='replace')
if self.logger: if self.logger:
self.logger.error('err: %s' % err) self.logger.error('err: %s' % err)
else: else:
@ -440,9 +440,9 @@ class Context(ctx):
raise Errors.WafError('Execution failure: %s' % str(e), ex=e) raise Errors.WafError('Execution failure: %s' % str(e), ex=e)
if not isinstance(out, str): if not isinstance(out, str):
out = out.decode(sys.stdout.encoding or 'iso8859-1', errors='replace') out = out.decode(sys.stdout.encoding or 'latin-1', errors='replace')
if not isinstance(err, str): if not isinstance(err, str):
err = err.decode(sys.stdout.encoding or 'iso8859-1', errors='replace') err = err.decode(sys.stdout.encoding or 'latin-1', errors='replace')
if out and quiet != STDOUT and quiet != BOTH: if out and quiet != STDOUT and quiet != BOTH:
self.to_log('out: %s' % out) self.to_log('out: %s' % out)

View File

@ -121,7 +121,7 @@ class Node(object):
""" """
raise Errors.WafError('nodes are not supposed to be copied') raise Errors.WafError('nodes are not supposed to be copied')
def read(self, flags='r', encoding='ISO8859-1'): def read(self, flags='r', encoding='latin-1'):
""" """
Reads and returns the contents of the file represented by this node, see :py:func:`waflib.Utils.readf`:: Reads and returns the contents of the file represented by this node, see :py:func:`waflib.Utils.readf`::
@ -137,7 +137,7 @@ class Node(object):
""" """
return Utils.readf(self.abspath(), flags, encoding) return Utils.readf(self.abspath(), flags, encoding)
def write(self, data, flags='w', encoding='ISO8859-1'): def write(self, data, flags='w', encoding='latin-1'):
""" """
Writes data to the file represented by this node, see :py:func:`waflib.Utils.writef`:: Writes data to the file represented by this node, see :py:func:`waflib.Utils.writef`::

View File

@ -863,10 +863,10 @@ if sys.hexversion > 0x3000000:
try: try:
return self.uid_ return self.uid_
except AttributeError: except AttributeError:
m = Utils.md5(self.__class__.__name__.encode('iso8859-1', 'xmlcharrefreplace')) m = Utils.md5(self.__class__.__name__.encode('latin-1', 'xmlcharrefreplace'))
up = m.update up = m.update
for x in self.inputs + self.outputs: for x in self.inputs + self.outputs:
up(x.abspath().encode('iso8859-1', 'xmlcharrefreplace')) up(x.abspath().encode('latin-1', 'xmlcharrefreplace'))
self.uid_ = m.digest() self.uid_ = m.digest()
return self.uid_ return self.uid_
uid.__doc__ = Task.uid.__doc__ uid.__doc__ = Task.uid.__doc__

View File

@ -723,11 +723,11 @@ class subst_pc(Task.Task):
self.force_permissions() self.force_permissions()
return ret return ret
code = self.inputs[0].read(encoding=getattr(self.generator, 'encoding', 'ISO8859-1')) code = self.inputs[0].read(encoding=getattr(self.generator, 'encoding', 'latin-1'))
if getattr(self.generator, 'subst_fun', None): if getattr(self.generator, 'subst_fun', None):
code = self.generator.subst_fun(self, code) code = self.generator.subst_fun(self, code)
if code is not None: if code is not None:
self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'ISO8859-1')) self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'latin-1'))
self.force_permissions() self.force_permissions()
return None return None
@ -758,7 +758,7 @@ class subst_pc(Task.Task):
d[x] = tmp d[x] = tmp
code = code % d code = code % d
self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'ISO8859-1')) self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'latin-1'))
self.generator.bld.raw_deps[self.uid()] = lst self.generator.bld.raw_deps[self.uid()] = lst
# make sure the signature is updated # make sure the signature is updated

View File

@ -199,7 +199,7 @@ class grep_for_endianness(Task.Task):
""" """
color = 'PINK' color = 'PINK'
def run(self): def run(self):
txt = self.inputs[0].read(flags='rb').decode('iso8859-1') txt = self.inputs[0].read(flags='rb').decode('latin-1')
if txt.find('LiTTleEnDian') > -1: if txt.find('LiTTleEnDian') > -1:
self.generator.tmp.append('little') self.generator.tmp.append('little')
elif txt.find('BIGenDianSyS') > -1: elif txt.find('BIGenDianSyS') > -1:

View File

@ -188,7 +188,7 @@ is_win32 = os.sep == '\\' or sys.platform == 'win32' # msys2
Whether this system is a Windows series Whether this system is a Windows series
""" """
def readf(fname, m='r', encoding='ISO8859-1'): def readf(fname, m='r', encoding='latin-1'):
""" """
Reads an entire file into a string. See also :py:meth:`waflib.Node.Node.readf`:: Reads an entire file into a string. See also :py:meth:`waflib.Node.Node.readf`::
@ -226,7 +226,7 @@ def readf(fname, m='r', encoding='ISO8859-1'):
f.close() f.close()
return txt return txt
def writef(fname, data, m='w', encoding='ISO8859-1'): def writef(fname, data, m='w', encoding='latin-1'):
""" """
Writes an entire file from a string. Writes an entire file from a string.
See also :py:meth:`waflib.Node.Node.writef`:: See also :py:meth:`waflib.Node.Node.writef`::
@ -274,7 +274,7 @@ def h_file(fname):
f.close() f.close()
return m.digest() return m.digest()
def readf_win32(f, m='r', encoding='ISO8859-1'): def readf_win32(f, m='r', encoding='latin-1'):
flags = os.O_NOINHERIT | os.O_RDONLY flags = os.O_NOINHERIT | os.O_RDONLY
if 'b' in m: if 'b' in m:
flags |= os.O_BINARY flags |= os.O_BINARY
@ -304,7 +304,7 @@ def readf_win32(f, m='r', encoding='ISO8859-1'):
f.close() f.close()
return txt return txt
def writef_win32(f, data, m='w', encoding='ISO8859-1'): def writef_win32(f, data, m='w', encoding='latin-1'):
if sys.hexversion > 0x3000000 and not 'b' in m: if sys.hexversion > 0x3000000 and not 'b' in m:
data = data.encode(encoding) data = data.encode(encoding)
m += 'b' m += 'b'
@ -473,7 +473,7 @@ def split_path_msys(path):
global msysroot global msysroot
if not msysroot: if not msysroot:
# msys has python 2.7 or 3, so we can use this # msys has python 2.7 or 3, so we can use this
msysroot = subprocess.check_output(['cygpath', '-w', '/']).decode(sys.stdout.encoding or 'iso8859-1') msysroot = subprocess.check_output(['cygpath', '-w', '/']).decode(sys.stdout.encoding or 'latin-1')
msysroot = msysroot.strip() msysroot = msysroot.strip()
path = os.path.normpath(msysroot + os.sep + path) path = os.path.normpath(msysroot + os.sep + path)
return split_path_win32(path) return split_path_win32(path)
@ -630,7 +630,7 @@ def h_cmd(ins):
# or just a python function # or just a python function
ret = str(h_fun(ins)) ret = str(h_fun(ins))
if sys.hexversion > 0x3000000: if sys.hexversion > 0x3000000:
ret = ret.encode('iso8859-1', 'xmlcharrefreplace') ret = ret.encode('latin-1', 'xmlcharrefreplace')
return ret return ret
reg_subst = re.compile(r"(\\\\)|(\$\$)|\$\{([^}]+)\}") reg_subst = re.compile(r"(\\\\)|(\$\$)|\$\{([^}]+)\}")

View File

@ -32,7 +32,7 @@ def get_emscripten_version(conf, cc):
conf.fatal('Could not determine emscripten version %r: %s' % (cmd, e)) conf.fatal('Could not determine emscripten version %r: %s' % (cmd, e))
if not isinstance(out, str): if not isinstance(out, str):
out = out.decode(sys.stdout.encoding or 'iso8859-1') out = out.decode(sys.stdout.encoding or 'latin-1')
k = {} k = {}
out = out.splitlines() out = out.splitlines()

View File

@ -302,7 +302,7 @@ def rm_blank_lines(txt):
BOM = '\xef\xbb\xbf' BOM = '\xef\xbb\xbf'
try: try:
BOM = bytes(BOM, 'iso8859-1') # python 3 BOM = bytes(BOM, 'latin-1') # python 3
except (TypeError, NameError): except (TypeError, NameError):
pass pass

View File

@ -359,7 +359,7 @@ def rm_blank_lines(txt):
BOM = '\xef\xbb\xbf' BOM = '\xef\xbb\xbf'
try: try:
BOM = bytes(BOM, 'iso8859-1') # python 3 BOM = bytes(BOM, 'latin-1') # python 3
except TypeError: except TypeError:
pass pass

View File

@ -40,7 +40,7 @@ all_sigs_in_cache = (0.0, [])
def put_data(conn, data): def put_data(conn, data):
if sys.hexversion > 0x3000000: if sys.hexversion > 0x3000000:
data = data.encode('iso8859-1') data = data.encode('latin-1')
cnt = 0 cnt = 0
while cnt < len(data): while cnt < len(data):
sent = conn.send(data[cnt:]) sent = conn.send(data[cnt:])
@ -107,8 +107,8 @@ def read_header(conn):
buf.append(data) buf.append(data)
cnt += len(data) cnt += len(data)
if sys.hexversion > 0x3000000: if sys.hexversion > 0x3000000:
ret = ''.encode('iso8859-1').join(buf) ret = ''.encode('latin-1').join(buf)
ret = ret.decode('iso8859-1') ret = ret.decode('latin-1')
else: else:
ret = ''.join(buf) ret = ''.join(buf)
return ret return ret
@ -140,8 +140,8 @@ def check_cache(conn, ssig):
cnt += len(data) cnt += len(data)
if sys.hexversion > 0x3000000: if sys.hexversion > 0x3000000:
ret = ''.encode('iso8859-1').join(buf) ret = ''.encode('latin-1').join(buf)
ret = ret.decode('iso8859-1') ret = ret.decode('latin-1')
else: else:
ret = ''.join(buf) ret = ''.join(buf)

View File

@ -62,14 +62,14 @@ def exec_command(self, cmd, **kw):
if out: if out:
if not isinstance(out, str): if not isinstance(out, str):
out = out.decode(sys.stdout.encoding or 'iso8859-1') out = out.decode(sys.stdout.encoding or 'latin-1')
if self.logger: if self.logger:
self.logger.debug('out: %s' % out) self.logger.debug('out: %s' % out)
else: else:
Logs.info(out, extra={'stream':sys.stdout, 'c1': ''}) Logs.info(out, extra={'stream':sys.stdout, 'c1': ''})
if err: if err:
if not isinstance(err, str): if not isinstance(err, str):
err = err.decode(sys.stdout.encoding or 'iso8859-1') err = err.decode(sys.stdout.encoding or 'latin-1')
if self.logger: if self.logger:
self.logger.error('err: %s' % err) self.logger.error('err: %s' % err)
else: else:

View File

@ -56,7 +56,7 @@ def subst(*k):
def r1(code): def r1(code):
"utf-8 fixes for python < 2.6" "utf-8 fixes for python < 2.6"
code = code.replace('as e:', ',e:') code = code.replace('as e:', ',e:')
code = code.replace(".decode(sys.stdout.encoding or'iso8859-1',errors='replace')", '') code = code.replace(".decode(sys.stdout.encoding or'latin-1',errors='replace')", '')
return code.replace('.encode()', '') return code.replace('.encode()', '')
@subst('Runner.py') @subst('Runner.py')

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: ISO8859-1 # encoding: latin-1
# Thomas Nagy, 2005-2011 # Thomas Nagy, 2005-2011
""" """