summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-02-19 23:28:14 +0000
committerZac Medico <zmedico@gentoo.org>2006-02-19 23:28:14 +0000
commitfb4c9c58095c0a78cf065c2b59ba75e374667a1f (patch)
treef46a92c87b6e4e426e818bf1998094d79783b2b8
parent1b7593526b974ab1c6acdd39b105a68f5864483a (diff)
downloadportage-fb4c9c58095c0a78cf065c2b59ba75e374667a1f.tar.gz
portage-fb4c9c58095c0a78cf065c2b59ba75e374667a1f.tar.bz2
portage-fb4c9c58095c0a78cf065c2b59ba75e374667a1f.zip
Add a tbz2.get_data() method that returns the xpak segment data as a dict.
svn path=/main/trunk/; revision=2751
-rw-r--r--pym/xpak.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/pym/xpak.py b/pym/xpak.py
index 9e918801c..c5c487e0a 100644
--- a/pym/xpak.py
+++ b/pym/xpak.py
@@ -389,6 +389,24 @@ class tbz2:
os.chdir(origdir)
return 1
+ def get_data(self):
+ """Returns all the files from the dataSegment as a map object."""
+ if not self.scan():
+ return 0
+ a = open(self.file, "r")
+ mydata = {}
+ startpos=0
+ while ((startpos+8)<self.indexsize):
+ namelen=decodeint(self.index[startpos:startpos+4])
+ datapos=decodeint(self.index[startpos+4+namelen:startpos+8+namelen]);
+ datalen=decodeint(self.index[startpos+8+namelen:startpos+12+namelen]);
+ myname=self.index[startpos+4:startpos+4+namelen]
+ a.seek(self.datapos+datapos)
+ mydata[myname] = a.read(datalen)
+ startpos=startpos+namelen+12
+ a.close()
+ return mydata
+
def getboth(self):
"""Returns an array [indexSegment,dataSegment]"""
if not self.scan():