def display_useflags(output): """Print USE flag descriptions and statuses. @type output: list @param output: [(inuse, inused, flag, desc, restrict), ...] inuse (int) = 0 or 1; if 1, flag is set in make.conf inused (int) = 0 or 1; if 1, package is installed with flag enabled flag (str) = the name of the USE flag desc (str) = the flag's description restrict (str) = corresponds to the text of restrict in metadata """ maxflag_len = len(max([t[2] for t in output], key=len)) twrap = TextWrapper() twrap.width = CONFIG['termWidth'] twrap.subsequent_indent = " " * (maxflag_len + 8) markers = ("-", "+") color = (partial(pp.useflag, enabled=False), partial(pp.useflag, enabled=True)) for in_makeconf, in_installed, flag, desc, restrict in output: if CONFIG['verbose']: flag_name = "" if in_makeconf != in_installed: flag_name += pp.emph( " %s %s" % (markers[in_makeconf], markers[in_installed])) else: flag_name += (" %s %s" % (markers[in_makeconf], markers[in_installed])) flag_name += " " + color[in_makeconf](flag.ljust(maxflag_len)) flag_name += " : " # Strip initial whitespace at the start of the description # Bug 432530 if desc: desc = desc.lstrip() # print description if restrict: restrict = "(%s %s)" % (pp.emph("Restricted to"), pp.cpv(restrict)) twrap.initial_indent = flag_name pp.uprint(twrap.fill(restrict)) if desc: twrap.initial_indent = twrap.subsequent_indent pp.uprint(twrap.fill(desc)) else: print(" : <unknown>") else: if desc: twrap.initial_indent = flag_name desc = twrap.fill(desc) pp.uprint(desc) else: twrap.initial_indent = flag_name print(twrap.fill("<unknown>")) else: pp.uprint(markers[in_makeconf] + flag)
def format_options_respect_newline(options, indent_c=25): """Like format_options, but respects newlines.""" wrapper = TextWrapper(width=gentoolkit.CONFIG['termWidth']) result = [] opts, descs = zip(*options) for opt, desc in zip(opts, descs): wrapper.initial_indent = gentoolkit.pprinter.emph(opt.ljust(indent_c)) wrapper.subsequent_indent = " " * indent_c for line in desc.splitlines(): result.append(wrapper.fill(line)) wrapper.initial_indent = ''.ljust(indent_c) return '\n'.join(result)
def format_options(options): """Format module options. @type options: list @param options: [('option 1', 'description 1'), ('option 2', 'des... )] @rtype: str @return: formatted options string """ result = [] twrap = TextWrapper(width=gentoolkit.CONFIG["termWidth"]) opts = (x[0] for x in options) descs = (x[1] for x in options) for opt, desc in zip(opts, descs): twrap.initial_indent = pp.emph(opt.ljust(25)) twrap.subsequent_indent = " " * 25 result.append(twrap.fill(desc)) return "\n".join(result)
def format_options(options): """Format module options. @type options: list @param options: [('option 1', 'description 1'), ('option 2', 'des... )] @rtype: str @return: formatted options string """ result = [] twrap = TextWrapper(width=gentoolkit.CONFIG['termWidth']) opts = (x[0] for x in options) descs = (x[1] for x in options) for opt, desc in zip(opts, descs): twrap.initial_indent = pp.emph(opt.ljust(25)) twrap.subsequent_indent = " " * 25 result.append(twrap.fill(desc)) return '\n'.join(result)
def display_useflags(output): """Print USE flag descriptions and statuses. @type output: list @param output: [(inuse, inused, flag, desc, restrict), ...] inuse (int) = 0 or 1; if 1, flag is set in make.conf inused (int) = 0 or 1; if 1, package is installed with flag enabled flag (str) = the name of the USE flag desc (str) = the flag's description restrict (str) = corresponds to the text of restrict in metadata """ maxflag_len = len(max([t[2] for t in output], key=len)) twrap = TextWrapper() twrap.width = CONFIG['termWidth'] twrap.subsequent_indent = " " * (maxflag_len + 8) markers = ("-", "+") color = ( partial(pp.useflag, enabled=False), partial(pp.useflag, enabled=True) ) for in_makeconf, in_installed, flag, desc, restrict in output: if CONFIG['verbose']: flag_name = "" if in_makeconf != in_installed: flag_name += pp.emph(" %s %s" % (markers[in_makeconf], markers[in_installed])) else: flag_name += (" %s %s" % (markers[in_makeconf], markers[in_installed])) flag_name += " " + color[in_makeconf](flag.ljust(maxflag_len)) flag_name += " : " # Strip initial whitespace at the start of the description # Bug 432530 if desc: desc = desc.lstrip() # print description if restrict: restrict = "(%s %s)" % (pp.emph("Restricted to"), pp.cpv(restrict)) twrap.initial_indent = flag_name pp.uprint(twrap.fill(restrict)) if desc: twrap.initial_indent = twrap.subsequent_indent pp.uprint(twrap.fill(desc)) else: print(" : <unknown>") else: if desc: twrap.initial_indent = flag_name desc = twrap.fill(desc) pp.uprint(desc) else: twrap.initial_indent = flag_name print(twrap.fill("<unknown>")) else: pp.uprint(markers[in_makeconf] + flag)