From: "Zac Medico (zmedico)" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] portage r14461 - in main/trunk/pym: _emerge portage portage/dbapi
Date: Tue, 29 Sep 2009 06:04:43 +0000 [thread overview]
Message-ID: <E1MsVpL-0000Qb-61@stork.gentoo.org> (raw)
Author: zmedico
Date: 2009-09-29 06:04:42 +0000 (Tue, 29 Sep 2009)
New Revision: 14461
Modified:
main/trunk/pym/_emerge/Binpkg.py
main/trunk/pym/portage/__init__.py
main/trunk/pym/portage/dbapi/bintree.py
Log:
Handle encoding/decoding of unicode when using the xpak api.
Use tbz2.get_data() instead of tbz2.getfile() when reading multiple values,
in order to avoid multiple tbz2.scan() and searchindex() calls.
Modified: main/trunk/pym/_emerge/Binpkg.py
===================================================================
--- main/trunk/pym/_emerge/Binpkg.py 2009-09-29 05:56:39 UTC (rev 14460)
+++ main/trunk/pym/_emerge/Binpkg.py 2009-09-29 06:04:42 UTC (rev 14461)
@@ -215,7 +215,8 @@
check_missing_metadata = ("CATEGORY", "PF")
missing_metadata = set()
for k in check_missing_metadata:
- v = pkg_xpak.getfile(k)
+ v = pkg_xpak.getfile(_unicode_encode(k,
+ encoding=_encodings['repo.content']))
if not v:
missing_metadata.add(k)
Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py 2009-09-29 05:56:39 UTC (rev 14460)
+++ main/trunk/pym/portage/__init__.py 2009-09-29 06:04:42 UTC (rev 14461)
@@ -8573,11 +8573,14 @@
mypkg = os.path.basename(mytbz2)[:-5]
xptbz2 = portage.xpak.tbz2(mytbz2)
- mycat = xptbz2.getfile("CATEGORY")
+ mycat = xptbz2.getfile(_unicode_encode("CATEGORY",
+ encoding=_encodings['repo.content']))
if not mycat:
writemsg(_("!!! CATEGORY info missing from info chunk, aborting...\n"),
noiselevel=-1)
return 1
+ mycat = _unicode_decode(mycat,
+ encoding=_encodings['repo.content'], errors='replace')
mycat = mycat.strip()
# These are the same directories that would be used at build time.
Modified: main/trunk/pym/portage/dbapi/bintree.py
===================================================================
--- main/trunk/pym/portage/dbapi/bintree.py 2009-09-29 05:56:39 UTC (rev 14460)
+++ main/trunk/pym/portage/dbapi/bintree.py 2009-09-29 06:04:42 UTC (rev 14461)
@@ -78,9 +78,11 @@
tbz2_path = self.bintree.getname(mycpv)
if not os.path.exists(tbz2_path):
raise KeyError(mycpv)
- tbz2 = portage.xpak.tbz2(tbz2_path)
+ metadata_bytes = portage.xpak.tbz2(tbz2_path).get_data()
def getitem(k):
- v = tbz2.getfile(k)
+ v = metadata_bytes.get(_unicode_encode(k,
+ encoding=_encodings['repo.content'],
+ errors='backslashreplace'))
if v is not None:
v = _unicode_decode(v,
encoding=_encodings['repo.content'], errors='replace')
@@ -377,8 +379,12 @@
if st is not None:
# For invalid packages, other_cat could be None.
- other_cat = portage.xpak.tbz2(dest_path).getfile("CATEGORY")
+ other_cat = portage.xpak.tbz2(dest_path).getfile(
+ _unicode_encode("CATEGORY",
+ encoding=_encodings['repo.content']))
if other_cat:
+ other_cat = _unicode_decode(other_cat,
+ encoding=_encodings['repo.content'], errors='replace')
other_cat = other_cat.strip()
other_cpv = other_cat + "/" + mypkg
self._move_from_all(other_cpv)
@@ -546,11 +552,19 @@
noiselevel=-1)
self.invalids.append(myfile[:-5])
continue
- mytbz2 = portage.xpak.tbz2(full_path)
- # For invalid packages, mycat could be None.
- mycat = mytbz2.getfile("CATEGORY")
- mypf = mytbz2.getfile("PF")
- slot = mytbz2.getfile("SLOT")
+ metadata_bytes = portage.xpak.tbz2(full_path).get_data()
+ mycat = _unicode_decode(metadata_bytes.get(
+ _unicode_encode("CATEGORY",
+ encoding=_encodings['repo.content']), ""),
+ encoding=_encodings['repo.content'], errors='replace')
+ mypf = _unicode_decode(metadata_bytes.get(
+ _unicode_encode("PF",
+ encoding=_encodings['repo.content']), ""),
+ encoding=_encodings['repo.content'], errors='replace')
+ slot = _unicode_decode(metadata_bytes.get(
+ _unicode_encode("SLOT",
+ encoding=_encodings['repo.content']), ""),
+ encoding=_encodings['repo.content'], errors='replace')
mypkg = myfile[:-5]
if not mycat or not mypf or not slot:
#old-style or corrupt package
reply other threads:[~2009-09-29 6:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1MsVpL-0000Qb-61@stork.gentoo.org \
--to=zmedico@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox