'KEYWORDS', 'IUSE', 'UNUSED_00',
'PDEPEND', 'PROVIDE', 'EAPI', 'PROPERTIES', 'DEFINED_PHASES')
- def __init__(self, label, auxdbkeys, **config):
- super(database,self).__init__(label, auxdbkeys, **config)
- self._base = os.path.join(self._base,
+ def __init__(self, *args, **config):
+ super(database,self).__init__(*args, **config)
+ self.location = os.path.join(self.location,
self.label.lstrip(os.path.sep).rstrip(os.path.sep))
if len(self._known_keys) > len(self.auxdbkey_order) + 2:
raise Exception("less ordered keys then auxdbkeys")
- if not os.path.exists(self._base):
+ if not os.path.exists(self.location):
self._ensure_dirs()
def _getitem(self, cpv):
d = {}
try:
- myf = codecs.open(_unicode_encode(os.path.join(self._base, cpv),
+ myf = codecs.open(_unicode_encode(os.path.join(self.location, cpv),
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'],
errors='replace')
def _setitem(self, cpv, values):
s = cpv.rfind("/")
- fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
+ fp=os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
try:
myf = codecs.open(_unicode_encode(fp,
encoding=_encodings['fs'], errors='strict'),
myf.close()
self._ensure_access(fp, mtime=values["_mtime_"])
#update written. now we move it.
- new_fp = os.path.join(self._base,cpv)
+ new_fp = os.path.join(self.location,cpv)
try:
os.rename(fp, new_fp)
except (OSError, IOError) as e:
def _delitem(self, cpv):
try:
- os.remove(os.path.join(self._base,cpv))
+ os.remove(os.path.join(self.location,cpv))
except OSError as e:
if errno.ENOENT == e.errno:
raise KeyError(cpv)
def __contains__(self, cpv):
- return os.path.exists(os.path.join(self._base, cpv))
+ return os.path.exists(os.path.join(self.location, cpv))
def __iter__(self):
"""generator for walking the dir struct"""
- dirs = [self._base]
- len_base = len(self._base)
+ dirs = [self.location]
+ len_base = len(self.location)
while len(dirs):
for l in os.listdir(dirs[0]):
if l.endswith(".cpickle"):
def __init__(self, _unused_param=None, mysettings=None):
"""
- @param _unused_param: deprecated
+ @param _unused_param: deprecated, use mysettings['PORTDIR'] instead
@type _unused_param: None
@param mysettings: an immutable config instance
@type mysettings: portage.config
from portage import settings
self.mysettings = config(clone=settings)
- if _unused_param is not None:
+ porttree_root = self.mysettings['PORTDIR']
+
+ # always show this warning after this parameter
+ # is unused in stable portage
+ if _unused_param is not None and _unused_param != porttree_root:
warnings.warn("The first parameter of the " + \
"portage.dbapi.porttree.portdbapi" + \
" constructor is now unused. Use " + \
"mysettings['PORTDIR'] instead.",
DeprecationWarning)
- porttree_root = self.mysettings['PORTDIR']
-
# This is strictly for use in aux_get() doebuild calls when metadata
# is generated by the depend phase. It's safest to use a clone for
# this purpose because doebuild makes many changes to the config
return myhashdict
def _createManifestEntries(self):
+ valid_hashes = set(portage.const.MANIFEST2_HASH_FUNCTIONS)
+ valid_hashes.add('size')
mytypes = list(self.fhashdict)
mytypes.sort()
for t in mytypes:
for f in myfiles:
myentry = Manifest2Entry(
type=t, name=f, hashes=self.fhashdict[t][f].copy())
- myhashkeys = list(myentry.hashes)
- myhashkeys.sort()
- for h in myhashkeys:
- if h not in ["size"] + portage.const.MANIFEST2_HASH_FUNCTIONS:
+ for h in list(myentry.hashes):
+ if h not in valid_hashes:
del myentry.hashes[h]
yield myentry