Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/
Date: Mon, 03 Oct 2011 17:42:46
Message-Id: 255e31ccb265fac768857da3ee6d966151a1e561.zmedico@gentoo
1 commit: 255e31ccb265fac768857da3ee6d966151a1e561
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Mon Oct 3 17:42:25 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Mon Oct 3 17:42:25 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=255e31cc
7
8 manfest.py: import constants directly
9
10 ---
11 pym/portage/manifest.py | 37 ++++++++++++++++++++-----------------
12 1 files changed, 20 insertions(+), 17 deletions(-)
13
14 diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
15 index 78153c0..da40ae1 100644
16 --- a/pym/portage/manifest.py
17 +++ b/pym/portage/manifest.py
18 @@ -18,8 +18,8 @@ from portage import _unicode_encode
19 from portage.exception import DigestException, FileNotFound, \
20 InvalidDataType, MissingParameter, PermissionDenied, \
21 PortageException, PortagePackageException
22 -from portage.const import (MANIFEST2_HASH_DEFAULTS,
23 - MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH)
24 +from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
25 + MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
26 from portage.localization import _
27
28 class FileNotInManifestException(PortageException):
29 @@ -60,7 +60,7 @@ def guessThinManifestFileType(filename):
30
31 def parseManifest2(mysplit):
32 myentry = None
33 - if len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS:
34 + if len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS:
35 mytype = mysplit[0]
36 myname = mysplit[1]
37 try:
38 @@ -127,8 +127,8 @@ class Manifest(object):
39 self.hashes.difference_update(hashname for hashname in \
40 list(self.hashes) if hashname not in hashfunc_map)
41 self.hashes.add("size")
42 - self.hashes.add(portage.const.MANIFEST2_REQUIRED_HASH)
43 - for t in portage.const.MANIFEST2_IDENTIFIERS:
44 + self.hashes.add(MANIFEST2_REQUIRED_HASH)
45 + for t in MANIFEST2_IDENTIFIERS:
46 self.fhashdict[t] = {}
47 if not from_scratch:
48 self._read()
49 @@ -152,7 +152,7 @@ class Manifest(object):
50 def getDigests(self):
51 """ Compability function for old digest/manifest code, returns dict of filename:{hashfunction:hashvalue} """
52 rval = {}
53 - for t in portage.const.MANIFEST2_IDENTIFIERS:
54 + for t in MANIFEST2_IDENTIFIERS:
55 rval.update(self.fhashdict[t])
56 return rval
57
58 @@ -223,7 +223,7 @@ class Manifest(object):
59 return myhashdict
60
61 def _createManifestEntries(self):
62 - valid_hashes = set(portage.const.MANIFEST2_HASH_FUNCTIONS)
63 + valid_hashes = set(MANIFEST2_HASH_FUNCTIONS)
64 valid_hashes.add('size')
65 mytypes = list(self.fhashdict)
66 mytypes.sort()
67 @@ -241,8 +241,9 @@ class Manifest(object):
68 def checkIntegrity(self):
69 for t in self.fhashdict:
70 for f in self.fhashdict[t]:
71 - if portage.const.MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
72 - raise MissingParameter(_("Missing %s checksum: %s %s") % (portage.const.MANIFEST2_REQUIRED_HASH, t, f))
73 + if MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
74 + raise MissingParameter(_("Missing %s checksum: %s %s") %
75 + (MANIFEST2_REQUIRED_HASH, t, f))
76
77 def write(self, sign=False, force=False):
78 """ Write Manifest instance to disk, optionally signing it """
79 @@ -310,14 +311,14 @@ class Manifest(object):
80 fname = os.path.join("files", fname)
81 if not os.path.exists(self.pkgdir+fname) and not ignoreMissing:
82 raise FileNotFound(fname)
83 - if not ftype in portage.const.MANIFEST2_IDENTIFIERS:
84 + if not ftype in MANIFEST2_IDENTIFIERS:
85 raise InvalidDataType(ftype)
86 if ftype == "AUX" and fname.startswith("files"):
87 fname = fname[6:]
88 self.fhashdict[ftype][fname] = {}
89 if hashdict != None:
90 self.fhashdict[ftype][fname].update(hashdict)
91 - if not portage.const.MANIFEST2_REQUIRED_HASH in self.fhashdict[ftype][fname]:
92 + if not MANIFEST2_REQUIRED_HASH in self.fhashdict[ftype][fname]:
93 self.updateFileHashes(ftype, fname, checkExisting=False, ignoreMissing=ignoreMissing)
94
95 def removeFile(self, ftype, fname):
96 @@ -330,7 +331,7 @@ class Manifest(object):
97
98 def findFile(self, fname):
99 """ Return entrytype of the given file if present in Manifest or None if not present """
100 - for t in portage.const.MANIFEST2_IDENTIFIERS:
101 + for t in MANIFEST2_IDENTIFIERS:
102 if fname in self.fhashdict[t]:
103 return t
104 return None
105 @@ -380,7 +381,7 @@ class Manifest(object):
106 requiredDistfiles = distlist.copy()
107 required_hash_types = set()
108 required_hash_types.add("size")
109 - required_hash_types.add(portage.const.MANIFEST2_REQUIRED_HASH)
110 + required_hash_types.add(MANIFEST2_REQUIRED_HASH)
111 for f in distlist:
112 fname = os.path.join(self.distdir, f)
113 mystat = None
114 @@ -489,7 +490,7 @@ class Manifest(object):
115 return absname
116
117 def checkAllHashes(self, ignoreMissingFiles=False):
118 - for t in portage.const.MANIFEST2_IDENTIFIERS:
119 + for t in MANIFEST2_IDENTIFIERS:
120 self.checkTypeHashes(t, ignoreMissingFiles=ignoreMissingFiles)
121
122 def checkTypeHashes(self, idtype, ignoreMissingFiles=False):
123 @@ -553,7 +554,7 @@ class Manifest(object):
124
125 def updateAllHashes(self, checkExisting=False, ignoreMissingFiles=True):
126 """ Regenerate all hashes for all files in this Manifest. """
127 - for idtype in portage.const.MANIFEST2_IDENTIFIERS:
128 + for idtype in MANIFEST2_IDENTIFIERS:
129 self.updateTypeHashes(idtype, checkExisting=checkExisting,
130 ignoreMissingFiles=ignoreMissingFiles)
131
132 @@ -598,9 +599,11 @@ class Manifest(object):
133 myfile.close()
134 for l in lines:
135 mysplit = l.split()
136 - if len(mysplit) == 4 and mysplit[0] in portage.const.MANIFEST1_HASH_FUNCTIONS and not 1 in rVal:
137 + if len(mysplit) == 4 and mysplit[0] in MANIFEST1_HASH_FUNCTIONS \
138 + and 1 not in rVal:
139 rVal.append(1)
140 - elif len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS and ((len(mysplit) - 3) % 2) == 0 and not 2 in rVal:
141 + elif len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS \
142 + and ((len(mysplit) - 3) % 2) == 0 and not 2 in rVal:
143 rVal.append(2)
144 return rVal