+depgraph
For Next Release:
- - allow passing VERSION='123' in front of setup.py sdist and do version
- mangling at dist creation time.
- find all commits to main gentoolkit svn after rc7 push and merge where
appropriate
+ - write a docstring for Package which details especially the change in have
+ cpv as an object, not a string.
def __repr__(self):
return "<%s %r>" % (self.__class__.__name__, self.atom)
- def get_env_vars(self, envvars):
+ def environment(self, envvars):
"""Returns predefined env vars DEPEND, SRC_URI, etc."""
# Try to use the Portage tree first, since emerge only uses the tree
"""Get the contents of DEPEND and parse it with self.parser."""
try:
- return self.parser(self.get_env_vars(('DEPEND',))[0])
+ return self.parser(self.environment(('DEPEND',))[0])
except portage.exception.InvalidPackageName, err:
raise errors.GentoolkitInvalidCPV(err)
"""Get the contents of PDEPEND and parse it with self.parser."""
try:
- return self.parser(self.get_env_vars(('PDEPEND',))[0])
+ return self.parser(self.environment(('PDEPEND',))[0])
except portage.exception.InvalidPackageName, err:
raise errors.GentoolkitInvalidCPV(err)
"""Get the contents of RDEPEND and parse it with self.parser."""
try:
- return self.parser(self.get_env_vars(('RDEPEND',))[0])
+ return self.parser(self.environment(('RDEPEND',))[0])
except portage.exception.InvalidPackageName, err:
raise errors.GentoolkitInvalidCPV(err)
env_vars = ('DEPEND', 'PDEPEND', 'RDEPEND')
try:
- return self.parser(' '.join(self.get_env_vars(env_vars)))
+ return self.parser(' '.join(self.environment(env_vars)))
except portage.exception.InvalidPackageName, err:
raise errors.GentoolkitInvalidCPV(err)
"""Display USE flag information for a given package."""
try:
- useflags = [x.lstrip("+-") for x in pkg.get_env_var("IUSE").split()]
+ useflags = [x.lstrip("+-") for x in pkg.environment("IUSE").split()]
except errors.GentoolkitFatalError:
# aux_get KeyError or other unexpected result
return
# Start from the newest
rev_matches = reversed(matches)
for pkg in rev_matches:
- keywords_str, slot = pkg.get_env_vars(('KEYWORDS', 'SLOT'))
+ keywords_str, slot = pkg.environment(('KEYWORDS', 'SLOT'))
keywords = keywords_str.split()
result[pkg] = [x for x in keywords if x not in slot_map.get(slot, [])]
try:
def format_keywords_line(pkg, fmtd_keywords):
"""Format the entire keywords line for display."""
- slot = pkg.get_env_var('SLOT')
+ slot = pkg.environment('SLOT')
ver = pkg.cpv.fullversion
verstr_len = len(ver) + 1 + len(slot) # +1 for ':'
print keywords_line
else:
# FIXME: duplicate code
- slot = match.get_env_var('SLOT')
+ slot = match.environment('SLOT')
verstr_len = len(match.cpv.fullversion) + len(slot)
indent = " " * (16 + verstr_len)
print format_line(keywords_line, "Keywords: ", indent)
"""Prepare descriptions and usage information for each USE flag."""
local_usedesc = pkg.metadata.get_useflags()
- iuse = pkg.get_env_var("IUSE")
+ iuse = pkg.environment("IUSE")
if iuse:
usevar = uniqify([x.lstrip('+-') for x in iuse.split()])
return self._deps
+ def environment(self, envvars, tree=None):
+ """Returns one or more of the predefined environment variables.
+
+ Example usage:
+ >>> pkg = Package('sys-apps/portage-2.1.6.13')
+ >>> pkg.environment('USE')
+ 'elibc_glibc kernel_linux userland_GNU x86'
+ >>> pkg.environment(('USE', 'IUSE'))
+ ['elibc_glibc kernel_linux userland_GNU x86',
+ 'build doc epydoc selinux linguas_pl']
+
+ @type envvars: str or array
+ @param envvars: one or more of (DEPEND, SRC_URI, etc.)
+ @rtype: str or list
+ @return: str if envvars is str, list if envvars is array
+ """
+
+ if tree is None:
+ tree = self._get_trees()[0]
+ got_string = False
+ if isinstance(envvars, basestring):
+ got_string = True
+ envvars = (envvars,)
+ try:
+ result = tree.aux_get(str(self.cpv), envvars)
+ except (KeyError, errors.GentoolkitFatalError):
+ err = "aux_get returned unexpected results"
+ raise errors.GentoolkitFatalError(err)
+
+ if got_string:
+ return result[0]
+ return result
+
+ # Namespace compatibility 2009, djanderson
+ get_env_var = environment
+
def exists(self):
"""Return True if package exists in the Portage tree, else False"""
return self.get_package_path().split(os.sep)[-3]
- def get_env_vars(self, envvars, tree=None):
- """Returns one or more of the predefined environment variables.
-
- @type envvars: array
- @param envvars: one or more of (DEPEND, SRC_URI, etc.)"""
-
- if tree is None:
- tree = self._get_trees()[0]
- try:
- result = tree.aux_get(str(self.cpv), envvars)
- except (KeyError, errors.GentoolkitFatalError):
- err = "aux_get returned unexpected results"
- raise errors.GentoolkitFatalError(err)
- return result
-
- def get_env_var(self, *args, **kwargs):
- """Returns one of the predefined environment variables."""
-
- return self.get_env_vars(args, **kwargs)[0]
-
def get_use_flags(self):
"""Returns the USE flags active at time of installation."""
'location': self.location,
'mask': pp.maskflag(maskmodes[self.format_mask_status()[0]]),
'package': pp.cpv(str(self.pkg.cpv)),
- 'slot': self.pkg.get_env_var("SLOT")
+ 'slot': self.pkg.environment("SLOT")
}
else:
return str(self.pkg.cpv)