Use _encodings['repo.content'] for decoding profiles.desc, ChangeLog,
authorZac Medico <zmedico@gentoo.org>
Wed, 19 Aug 2009 06:41:21 +0000 (06:41 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 19 Aug 2009 06:41:21 +0000 (06:41 -0000)
metadata.xml, and ebuilds.

svn path=/main/trunk/; revision=14098

bin/repoman
pym/portage/__init__.py

index 368902255650e336b17e02b5e942e70af1bdc5cf..aecd45ca07a4cbd31629a168a329c2e7a0b19f4a 100755 (executable)
@@ -40,6 +40,8 @@ except ImportError:
        import portage
 portage._disable_legacy_globals()
 from portage import os
+from portage import _encodings
+from portage import _unicode_encode
 
 try:
        from repoman.checks import run_checks
@@ -600,8 +602,9 @@ for path in portdb.porttrees:
 
        desc_path = os.path.join(path, 'profiles', 'profiles.desc')
        try:
-               desc_file = codecs.open(desc_path, mode='r',
-                       encoding='utf_8', errors='replace')
+               desc_file = codecs.open(_unicode_encode(desc_path,
+                       encoding=_encodings['fs'], errors='strict'),
+                       mode='r', encoding=_encodings['repo.content'], errors='replace')
        except EnvironmentError:
                pass
        else:
@@ -971,8 +974,9 @@ for x in scanlist:
                        continue
                try:
                        line = 1
-                       for l in codecs.open(os.path.join(checkdir, y), mode='r',
-                               encoding='utf_8'):
+                       for l in codecs.open(_unicode_encode(os.path.join(checkdir, y),
+                               encoding=_encodings['fs'], errors='strict'),
+                               mode='r', encoding=_encodings['repo.content']):
                                line +=1
                except UnicodeDecodeError, ue:
                        stats["file.UTF8"] += 1
@@ -1553,7 +1557,9 @@ for x in scanlist:
                full_path = os.path.join(repodir, relative_path)
                try:
                        # All ebuilds should have utf_8 encoding.
-                       f = codecs.open(full_path, mode='r', encoding='utf_8')
+                       f = codecs.open(_unicode_encode(full_path,
+                               encoding=_encodings['fs'], errors='strict'),
+                               mode='r', encoding=_encodings['repo.content'])
                        try:
                                for check_name, e in run_checks(f, pkg):
                                        stats[check_name] += 1
index 480e00f81d4336e44aa6c8cbd958021117564333..9cb3af2ae7bcc8c1088542ec88ff95eb6e64d14c 100644 (file)
@@ -124,6 +124,7 @@ _encodings = {
        'content'                : 'utf_8',
        'fs'                     : 'utf_8',
        'merge'                  : sys.getfilesystemencoding(),
+       'repo.content'           : 'utf_8',
 }
 
 # Deprecated attributes. Instead use _encodings directly.