From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SD69Y-0004TZ-GP for garchives@archives.gentoo.org; Thu, 29 Mar 2012 03:36:01 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EE67DE0D41; Thu, 29 Mar 2012 03:35:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A6D85E0D41 for ; Thu, 29 Mar 2012 03:35:41 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A87221B400F for ; Thu, 29 Mar 2012 03:35:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 41079E5402 for ; Thu, 29 Mar 2012 03:35:39 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1332991960.b8a5d5d288b6d4138ee81f4c24692bdcb5c2c189.vapier@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/xpak.py X-VCS-Directories: pym/portage/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: b8a5d5d288b6d4138ee81f4c24692bdcb5c2c189 X-VCS-Branch: master Date: Thu, 29 Mar 2012 03:35:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 77659858-5ce7-401b-9a64-c8e310c3b9a5 X-Archives-Hash: c4a265cf1ee38d84aeaf9feda695be74 commit: b8a5d5d288b6d4138ee81f4c24692bdcb5c2c189 Author: Mike Frysinger gentoo org> AuthorDate: Tue Mar 27 20:38:18 2012 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Thu Mar 29 03:32:40 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Db8a5d5d2 xpak: clean up style A few spaces here and there go a long way to making this readable. Signed-off-by: Mike Frysinger gentoo.org> --- pym/portage/xpak.py | 247 +++++++++++++++++++++++++--------------------= ------ 1 files changed, 123 insertions(+), 124 deletions(-) diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py index db2a2bc..8689737 100644 --- a/pym/portage/xpak.py +++ b/pym/portage/xpak.py @@ -62,12 +62,12 @@ def encodeint(myint): """Takes a 4 byte integer and converts it into a string of 4 characters= . Returns the characters in a string.""" a =3D array.array('B') - a.append((myint >> 24 ) & 0xff) - a.append((myint >> 16 ) & 0xff) - a.append((myint >> 8 ) & 0xff) + a.append((myint >> 24) & 0xff) + a.append((myint >> 16) & 0xff) + a.append((myint >> 8) & 0xff) a.append(myint & 0xff) try: - # Python >=3D3.2 + # Python >=3D 3.2 return a.tobytes() except AttributeError: return a.tostring() @@ -84,12 +84,12 @@ def decodeint(mystring): myint +=3D mystring[0] << 24 return myint =20 -def xpak(rootdir,outfile=3DNone): - """(rootdir,outfile) -- creates an xpak segment of the directory 'rootd= ir' +def xpak(rootdir, outfile=3DNone): + """(rootdir, outfile) -- creates an xpak segment of the directory 'root= dir' and under the name 'outfile' if it is specified. Otherwise it returns t= he xpak segment.""" =20 - mylist=3D[] + mylist =3D [] =20 addtolist(mylist, rootdir) mylist.sort() @@ -125,21 +125,21 @@ def xpak_mem(mydata): del mydata_encoded =20 indexglob =3D b'' - indexpos=3D0 + indexpos =3D 0 dataglob =3D b'' - datapos=3D0 + datapos =3D 0 for x, newglob in mydata.items(): - mydatasize=3Dlen(newglob) - indexglob=3Dindexglob+encodeint(len(x))+x+encodeint(datapos)+encodeint= (mydatasize) - indexpos=3Dindexpos+4+len(x)+4+4 - dataglob=3Ddataglob+newglob - datapos=3Ddatapos+mydatasize + mydatasize =3D len(newglob) + indexglob =3D indexglob + encodeint(len(x)) + x + encodeint(datapos) += encodeint(mydatasize) + indexpos =3D indexpos + 4 + len(x) + 4 + 4 + dataglob =3D dataglob + newglob + datapos =3D datapos + mydatasize return b'XPAKPACK' \ - + encodeint(len(indexglob)) \ - + encodeint(len(dataglob)) \ - + indexglob \ - + dataglob \ - + b'XPAKSTOP' + + encodeint(len(indexglob)) \ + + encodeint(len(dataglob)) \ + + indexglob \ + + dataglob \ + + b'XPAKSTOP' =20 def xsplit(infile): """(infile) -- Splits the infile into two files. @@ -149,7 +149,7 @@ def xsplit(infile): encoding=3D_encodings['fs'], errors=3D'strict') myfile =3D open(_unicode_encode(infile, encoding=3D_encodings['fs'], errors=3D'strict'), 'rb') - mydat=3Dmyfile.read() + mydat =3D myfile.read() myfile.close() =09 splits =3D xsplit_mem(mydat) @@ -171,35 +171,35 @@ def xsplit_mem(mydat): return None if mydat[-8:] !=3D b'XPAKSTOP': return None - indexsize=3Ddecodeint(mydat[8:12]) - return (mydat[16:indexsize+16], mydat[indexsize+16:-8]) + indexsize =3D decodeint(mydat[8:12]) + return (mydat[16:indexsize + 16], mydat[indexsize + 16:-8]) =20 def getindex(infile): """(infile) -- grabs the index segment from the infile and returns it."= "" myfile =3D open(_unicode_encode(infile, encoding=3D_encodings['fs'], errors=3D'strict'), 'rb') - myheader=3Dmyfile.read(16) + myheader =3D myfile.read(16) if myheader[0:8] !=3D b'XPAKPACK': myfile.close() return - indexsize=3Ddecodeint(myheader[8:12]) - myindex=3Dmyfile.read(indexsize) + indexsize =3D decodeint(myheader[8:12]) + myindex =3D myfile.read(indexsize) myfile.close() return myindex =20 def getboth(infile): """(infile) -- grabs the index and data segments from the infile. - Returns an array [indexSegment,dataSegment]""" + Returns an array [indexSegment, dataSegment]""" myfile =3D open(_unicode_encode(infile, encoding=3D_encodings['fs'], errors=3D'strict'), 'rb') - myheader=3Dmyfile.read(16) + myheader =3D myfile.read(16) if myheader[0:8] !=3D b'XPAKPACK': myfile.close() return - indexsize=3Ddecodeint(myheader[8:12]) - datasize=3Ddecodeint(myheader[12:16]) - myindex=3Dmyfile.read(indexsize) - mydata=3Dmyfile.read(datasize) + indexsize =3D decodeint(myheader[8:12]) + datasize =3D decodeint(myheader[12:16]) + myindex =3D myfile.read(indexsize) + mydata =3D myfile.read(datasize) myfile.close() return myindex, mydata =20 @@ -210,52 +210,52 @@ def listindex(myindex): =20 def getindex_mem(myindex): """Returns the filenames listed in the indexglob passed in.""" - myindexlen=3Dlen(myindex) - startpos=3D0 - myret=3D[] - while ((startpos+8)