From abdbb7c11e4008d3cfe67a436b3ec4b2e047fc25 Mon Sep 17 00:00:00 2001 From: "Dr. Peter Poeml" Date: Wed, 11 Jul 2007 21:14:58 +0000 Subject: [PATCH] updatepacmetafromspec: read spec files in utf-8, or whatever the preferred encoding is in the locale --- osc/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osc/core.py b/osc/core.py index bf7523f7..bf3ff683 100755 --- a/osc/core.py +++ b/osc/core.py @@ -1051,13 +1051,17 @@ def show_upstream_rev(apiurl, prj, pac): def read_meta_from_spec(specfile): + import codecs, locale """read Name, Summary and %description from spec file""" if not os.path.isfile(specfile): print 'file \'%s\' is not a readable file' % specfile return (None, None) - lines = open(specfile).readlines() + try: + lines = codecs.open(specfile, 'r', locale.getpreferredencoding()).readlines() + except UnicodeDecodeError: + lines = open(specfile).readlines() for line in lines: if line.startswith('Name:'):