Example #1
0
def print_legend():
	"""Print a legend to explain the output format."""

	print("[ Legend : %s - final flag setting for installation]" % pp.emph("U"))
	print("[        : %s - package is installed with flag     ]" % pp.emph("I"))
	print("[ Colors : %s, %s                             ]" % (
		pp.useflag("set", enabled=True), pp.useflag("unset", enabled=False)))
Example #2
0
def print_legend():
	"""Print a legend to explain the output format."""

	print("[ Legend : %s - final flag setting for installation]" % pp.emph("U"))
	print("[        : %s - package is installed with flag     ]" % pp.emph("I"))
	print("[ Colors : %s, %s                             ]" % (
		pp.useflag("set", enabled=True), pp.useflag("unset", enabled=False)))
Example #3
0
    def format_depend(self, dep, dep_is_displayed):
        """Format a dependency for printing.

		@type dep: L{gentoolkit.dependencies.Dependencies}
		@param dep: the dependency to display
		"""

        # Don't print blank lines
        if dep_is_displayed and not self.verbose:
            return

        depth = getattr(dep, 'depth', 0)
        indent = " " * depth
        mdep = dep.matching_dep
        use_conditional = ""
        if mdep.use_conditional:
            use_conditional = " & ".join(
                pp.useflag(u) for u in mdep.use_conditional.split())
        if mdep.operator == '=*':
            formatted_dep = '=%s*' % str(mdep.cpv)
        else:
            formatted_dep = mdep.operator + str(mdep.cpv)
        if mdep.slot:
            formatted_dep += pp.emph(':') + pp.slot(mdep.slot)
        if mdep.use:
            useflags = pp.useflag(','.join(mdep.use.tokens))
            formatted_dep += (pp.emph('[') + useflags + pp.emph(']'))

        if dep_is_displayed:
            indent = indent + " " * len(str(dep.cpv))
            self.print_fn(indent, '', use_conditional, formatted_dep)
        else:
            self.print_fn(indent, str(dep.cpv), use_conditional, formatted_dep)
Example #4
0
	def format_depend(self, dep, dep_is_displayed):
		"""Format a dependency for printing.

		@type dep: L{gentoolkit.dependencies.Dependencies}
		@param dep: the dependency to display
		"""

		# Don't print blank lines
		if dep_is_displayed and not self.verbose:
			return

		depth = getattr(dep, 'depth', 0)
		indent = " " * depth
		mdep = dep.matching_dep
		use_conditional = ""
		if mdep.use_conditional:
			use_conditional = " & ".join(
				pp.useflag(u) for u in mdep.use_conditional.split()
			)
		if mdep.operator == '=*':
			formatted_dep = '=%s*' % str(mdep.cpv)
		else:
			formatted_dep = mdep.operator + str(mdep.cpv)
		if mdep.slot:
			formatted_dep += pp.emph(':') + pp.slot(mdep.slot)
		if mdep.use:
			useflags = pp.useflag(','.join(mdep.use.tokens))
			formatted_dep += (pp.emph('[') + useflags + pp.emph(']'))

		if dep_is_displayed:
			indent = indent + " " * len(str(dep.cpv))
			self.print_fn(indent, '', use_conditional, formatted_dep)
		else:
			self.print_fn(indent, str(dep.cpv), use_conditional, formatted_dep)
Example #5
0
    def print_pkg_quiet(self, cpv, flags):
        """Verbosely prints the pkg's use flag info."""
        (plus, minus, unset) = flags
        _flags = []
        for flag in plus:
            _flags.append(pp.useflag((flag), True))
        for flag in minus:
            _flags.append(pp.useflag(("-" + flag), False))
        for flag in unset:
            _flags.append(pp.globaloption("-" + flag))

        print(self._format_values(cpv, ", ".join(_flags)))
Example #6
0
    def print_pkg_quiet(self, cpv, flags):
        """Verbosely prints the pkg's use flag info.
		"""
        (plus, minus, unset) = flags
        _flags = []
        for flag in plus:
            _flags.append(pp.useflag((flag), True))
        for flag in minus:
            _flags.append(pp.useflag(("-" + flag), False))
        for flag in unset:
            _flags.append(pp.globaloption("-" + flag))

        print(self._format_values(cpv, ", ".join(_flags)))
Example #7
0
    def print_use_quiet(key, active, default, count, pkgs):
        """Quietly prints a subset set of USE flag info..
		"""
        if active in ["+", "-"]:
            _key = pp.useflag((active + key), active == "+")
        else:
            _key = (" " + key)
        print(_key, '.' * (35 - len(key)), default, pp.number(count))
Example #8
0
    def print_use_quiet(key, active, default, count, pkgs):
        """Quietly prints a subset set of USE flag info..
		"""
        if active in ["+", "-"]:
            _key = pp.useflag((active + key), active == "+")
        else:
            _key = " " + key
        print(_key, "." * (35 - len(key)), default, pp.number(count))
Example #9
0
def depgraph_printer(depth,
                     pkg,
                     dep,
                     no_use=False,
                     no_atom=False,
                     no_indent=False,
                     initial_pkg=False,
                     no_mask=False):
    """Display L{gentoolkit.dependencies.Dependencies.graph_depends} results.

	@type depth: int
	@param depth: depth of indirection, used to calculate indent
	@type pkg: L{gentoolkit.package.Package}
	@param pkg: "best match" package matched by B{dep}
	@type dep: L{gentoolkit.atom.Atom}
	@param dep: dependency that matched B{pkg}
	@type no_use: bool
	@param no_use: don't output USE flags
	@type no_atom: bool
	@param no_atom: don't output dep atom
	@type no_indent: bool
	@param no_indent: don't output indent based on B{depth}
	@type initial_pkg: bool
	@param initial_pkg: somewhat of a hack used to print the root package of
		the graph with absolutely no indent
	"""
    indent = '' if no_indent or initial_pkg else ' ' + (' ' * depth)
    decorator = '[%3d] ' % depth if no_indent else '`-- '
    use = ''
    atom = ''
    mask = ''
    try:
        if not no_atom:
            if dep.operator == '=*':
                atom += ' (=%s*)' % dep.cpv
            else:
                atom += ' (%s%s)' % (dep.operator, dep.cpv)
        if not no_use and dep is not None and dep.use:
            use = ' [%s]' % ' '.join(
                pp.useflag(x, enabled=True) for x in dep.use.tokens)
    except AttributeError:
        # 'NoneType' object has no attribute 'atom'
        pass
    if pkg and not no_mask:
        mask = pkg.mask_status()
        if not mask:
            mask = [
                determine_keyword(portage.settings["ARCH"],
                                  portage.settings["ACCEPT_KEYWORDS"],
                                  pkg.environment('KEYWORDS'))
            ]
        mask = pp.masking(mask)
    try:
        pp.uprint(' '.join(
            (indent, decorator, pp.cpv(str(pkg.cpv)), atom, mask, use)))
    except AttributeError:
        # 'NoneType' object has no attribute 'cpv'
        pp.uprint(''.join((indent, decorator, "(no match for %r)" % dep.atom)))
Example #10
0
def format_useflags(useflags):
    """Format USE flag information for display."""

    result = []
    for flag in useflags:
        result.append(pp.useflag(flag.name))
        result.append(flag.description)
        result.append("")

    return result
Example #11
0
def format_useflags(useflags):
	"""Format USE flag information for display."""

	result = []
	for flag in useflags:
		result.append(pp.useflag(flag.name))
		result.append(flag.description)
		result.append("")

	return result
Example #12
0
 def print_use(self, key, atom=None, values=None):
     """Prints a USE flag string."""
     if atom and not values:
         values = atom.use
     if self.pretend:
         flags = []
         for flag in values:
             flags.append(pp.useflag(flag, (flag[0] != "-")))
         print(self._format_values(self.spacer + key, " ".join(flags)))
     else:
         line = " ".join([key, " ".join(values)])
         self.lines.append(line)
Example #13
0
    def print_use(self, key, atom=None, values=None):
        """Prints a USE flag string.
		"""
        if atom and not values:
            values = atom.use
        if self.pretend:
            flags = []
            for flag in values:
                flags.append(pp.useflag(flag, (flag[0] != "-")))
            print(self._format_values(self.spacer + key, " ".join(flags)))
        else:
            line = " ".join([key, " ".join(values)])
            self.lines.append(line)
Example #14
0
    def print_use_verbose(key, active, default, count, pkgs):
        """Verbosely prints a set of use flag info. including the pkgs
		using them.
		"""
        _pkgs = pkgs[:]
        if active in ["+", "-"]:
            _key = pp.useflag((active + key), active == "+")
        else:
            _key = " " + key
        cpv = _pkgs.pop(0)
        print(_key, "." * (35 - len(key)), default, pp.number(count), pp.cpv(cpv))
        while _pkgs:
            cpv = _pkgs.pop(0)
            print(" " * 52 + pp.cpv(cpv))
Example #15
0
def depgraph_printer(depth, pkg, dep, no_use=False, no_atom=False, no_indent=False, initial_pkg=False, no_mask=False):
    """Display L{gentoolkit.dependencies.Dependencies.graph_depends} results.

	@type depth: int
	@param depth: depth of indirection, used to calculate indent
	@type pkg: L{gentoolkit.package.Package}
	@param pkg: "best match" package matched by B{dep}
	@type dep: L{gentoolkit.atom.Atom}
	@param dep: dependency that matched B{pkg}
	@type no_use: bool
	@param no_use: don't output USE flags
	@type no_atom: bool
	@param no_atom: don't output dep atom
	@type no_indent: bool
	@param no_indent: don't output indent based on B{depth}
	@type initial_pkg: bool
	@param initial_pkg: somewhat of a hack used to print the root package of
		the graph with absolutely no indent
	"""
    indent = "" if no_indent or initial_pkg else " " + (" " * depth)
    decorator = "[%3d] " % depth if no_indent else "`-- "
    use = ""
    atom = ""
    mask = ""
    try:
        if not no_atom:
            if dep.operator == "=*":
                atom += " (=%s*)" % dep.cpv
            else:
                atom += " (%s%s)" % (dep.operator, dep.cpv)
        if not no_use and dep is not None and dep.use:
            use = " [%s]" % " ".join(pp.useflag(x, enabled=True) for x in dep.use.tokens)
    except AttributeError:
        # 'NoneType' object has no attribute 'atom'
        pass
    if pkg and not no_mask:
        mask = pkg.mask_status()
        if not mask:
            mask = [
                determine_keyword(
                    portage.settings["ARCH"], portage.settings["ACCEPT_KEYWORDS"], pkg.environment("KEYWORDS")
                )
            ]
        mask = pp.masking(mask)
    try:
        pp.uprint(" ".join((indent, decorator, pp.cpv(str(pkg.cpv)), atom, mask, use)))
    except AttributeError:
        # 'NoneType' object has no attribute 'cpv'
        pp.uprint("".join((indent, decorator, "(no match for %r)" % dep.atom)))
Example #16
0
    def print_use_verbose(key, active, default, count, pkgs):
        """Verbosely prints a set of use flag info. including the pkgs
		using them.
		"""
        _pkgs = pkgs[:]
        if active in ["+", "-"]:
            _key = pp.useflag((active + key), active == "+")
        else:
            _key = (" " + key)
        cpv = _pkgs.pop(0)
        print(_key, '.' * (35 - len(key)), default, pp.number(count),
              pp.cpv(cpv))
        while _pkgs:
            cpv = _pkgs.pop(0)
            print(' ' * 52 + pp.cpv(cpv))