From dd8e521a6ecd1992645fdc56ef1b7a6fcf6e55ca Mon Sep 17 00:00:00 2001 From: Sambhav Kothari Date: Tue, 11 Apr 2017 00:52:17 +0530 Subject: [PATCH] PICARD-1066: Fix update_constants --- setup.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index a537e1975..1f5a1b6cc 100755 --- a/setup.py +++ b/setup.py @@ -493,7 +493,7 @@ class picard_update_constants(Command): log.info('Parsing %s' % countries_potfile) po = pofile.read_po(f) for message in po: - if not message.id or not isinstance(message.id, unicode): + if not message.id or not isinstance(message.id, str): continue for comment in message.auto_comments: if comment.startswith(isocode_comment): @@ -516,7 +516,7 @@ class picard_update_constants(Command): log.info('Parsing %s' % attributes_potfile) po = pofile.read_po(f) for message in po: - if not message.id or not isinstance(message.id, unicode): + if not message.id or not isinstance(message.id, str): continue for loc, pos in message.locations: if loc in extract_attributes: @@ -536,13 +536,13 @@ class picard_update_constants(Command): footer = u"}}\n" filename = os.path.join('picard', 'const', 'countries.py') with open(filename, 'w') as countries_py: - def write_utf8(s, **kwargs): - countries_py.write(s.format(**kwargs).encode('utf-8')) + def write(s, **kwargs): + countries_py.write(s.format(**kwargs)) - write_utf8(header, option=_get_option_name(self)) + write(header, option=_get_option_name(self)) for code, name in sorted(countries.items(), key=lambda t: t[0]): - write_utf8(line, code=code, name=name.replace("'", "\\'")) - write_utf8(footer) + write(line, code=code, name=name.replace("'", "\\'")) + write(footer) log.info("%s was rewritten (%d countries)" % (filename, len(countries))) @@ -556,13 +556,13 @@ class picard_update_constants(Command): footer = u"}}\n" filename = os.path.join('picard', 'const', 'attributes.py') with open(filename, 'w') as attributes_py: - def write_utf8(s, **kwargs): - attributes_py.write(s.format(**kwargs).encode('utf-8')) + def write(s, **kwargs): + attributes_py.write(s.format(**kwargs)) - write_utf8(header, option=_get_option_name(self)) + write(header, option=_get_option_name(self)) for key, value in sorted(attributes.items(), key=lambda i: i[0]): - write_utf8(line, key=key, value=value.replace("'", "\\'")) - write_utf8(footer) + write(line, key=key, value=value.replace("'", "\\'")) + write(footer) log.info("%s was rewritten (%d attributes)" % (filename, len(attributes)))