Author: tille Date: 2012-04-20 20:52:37 +0000 (Fri, 20 Apr 2012) New Revision: 2228
Modified: udd/udd/aux.py udd/udd/ddtp_gatherer.py udd/udd/ftpnew_gatherer.py Log: Move to_unicode to aux.py because it is used in more than one script; use parse_email in ftpnew_gatherer Modified: udd/udd/aux.py =================================================================== --- udd/udd/aux.py 2012-04-19 06:02:19 UTC (rev 2227) +++ udd/udd/aux.py 2012-04-20 20:52:37 UTC (rev 2228) @@ -110,3 +110,9 @@ return True except UnicodeDecodeError: return False + +def to_unicode(value, encoding='utf-8'): + if isinstance(value, str): + return value.decode(encoding) + else: + return unicode(value) Modified: udd/udd/ddtp_gatherer.py =================================================================== --- udd/udd/ddtp_gatherer.py 2012-04-19 06:02:19 UTC (rev 2227) +++ udd/udd/ddtp_gatherer.py 2012-04-20 20:52:37 UTC (rev 2228) @@ -7,7 +7,7 @@ http://ftp.debian.org/debian/dists/${release}/${component}/i18n/ """ -from aux import quote +from aux import quote, to_unicode from gatherer import gatherer import re try: @@ -26,11 +26,6 @@ import logging.handlers debug=0 -def to_unicode(value, encoding='utf-8'): - if isinstance(value, str): - return value.decode(encoding) - else: - return unicode(value) def get_gatherer(connection, config, source): return ddtp_gatherer(connection, config, source) Modified: udd/udd/ftpnew_gatherer.py =================================================================== --- udd/udd/ftpnew_gatherer.py 2012-04-19 06:02:19 UTC (rev 2227) +++ udd/udd/ftpnew_gatherer.py 2012-04-20 20:52:37 UTC (rev 2228) @@ -12,10 +12,8 @@ from debian_bundle import deb822 from os import access, mkdir, unlink, W_OK from sys import stderr -import aux -from aux import quote +from aux import quote, to_unicode, parse_email from gatherer import gatherer -import email.Utils import re from time import ctime from psycopg2 import IntegrityError, ProgrammingError @@ -24,11 +22,6 @@ return ftpnew_gatherer(connection, config, source) DEBUG=0 -def to_unicode(value, encoding='utf-8'): - if isinstance(value, str): - return value.decode(encoding) - else: - return unicode(value) # When parsing src html pages we have to get rid of certain html strings def de_html(string): @@ -309,7 +302,7 @@ elif field == 'Maintainer': if in_source: srcpkg.s[field] = to_unicode(value) - srcpkg.s['maintainer_name'], srcpkg.s['maintainer_email'] = email.Utils.parseaddr(srcpkg.s[field]) + srcpkg.s['maintainer_name'], srcpkg.s['maintainer_email'] = parse_email(srcpkg.s[field]) else: binpkg.b[field] = value print >>srco, "%s: %s" % (field, value) _______________________________________________ Collab-qa-commits mailing list Collab-qa-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/collab-qa-commits