def main(input_args): """Parse input and run the program""" short_opts = "h" long_opts = ('help') try: module_opts, queries = gnu_getopt(input_args, short_opts, long_opts) except GetoptError as err: sys.stderr.write(pp.error("Module %s" % err)) print() print_help(with_description=False) sys.exit(2) parse_module_options(module_opts) if not queries or len(queries) > 1: print_help() sys.exit(2) # # Output # query = Query(queries[0]) matches = query.find(include_masked=True, in_installed=False) if not matches: raise errors.GentoolkitNoMatches(query) matches.sort() matches.reverse() if CONFIG['verbose']: print(matches[0].ebuild_path()) print() pkgdeps = matches[0].deps deps = pkgdeps.get_all_depends(raw=True) deps = paren_reduce(deps) if CONFIG['verbose']: print(deps) print() kwdict = parse_list(deps) if CONFIG['verbose']: print() if not kwdict == None: print(' '.join(kwdict.values())) else: print()
def main(input_args): """Parse input and run the program""" short_opts = "h" long_opts = ('help') try: module_opts, queries = gnu_getopt(input_args, short_opts, long_opts) except GetoptError as err: sys.stderr.write(pp.error("Module %s" % err)) print() print_help(with_description=False) sys.exit(2) parse_module_options(module_opts) if not queries or len(queries) > 1: print_help() sys.exit(2) # # Output # query = Query(queries[0]) matches = query.find(include_masked=True, in_installed=False) if not matches: raise errors.GentoolkitNoMatches(query) matches.sort() matches.reverse() if CONFIG['verbose']: print(matches[0].ebuild_path()) print() ebkw = matches[0].environment('KEYWORDS') uskw = [] for kw in ebkw.split(): if kw[0] != '-' and kw[0] != '~': uskw.append('~' + kw) else: uskw.append(kw) print(' '.join(uskw))
def parse_atom(tok, indent=0): """Parse dependency atom""" assert (not isinstance(tok, list)) if CONFIG['verbose']: print(' ' * indent, 'atom', tok) atom = Atom(tok) # Try to find matches for this atom query = Query(atom) matches = query.find(include_masked=True) # We didn't find any so raise an error if not matches: raise errors.GentoolkitNoMatches(query) # Loop through the matching packages combining their best arch keywords into a single dictionary matches.sort() kwdict = {} for pkg in matches: if CONFIG['verbose']: print(' ' * (indent + 2), pkg) keywords_str = pkg.environment(('KEYWORDS'), prefer_vdb=False) if keywords_str: if CONFIG['verbose']: print(' ' * (indent + 4), keywords_str) for keyword in keywords_str.split(): skw = make_stable(keyword) if skw not in kwdict: kwdict[skw] = keyword else: kwdict[skw] = best_keyword(kwdict[skw], keyword) if CONFIG['verbose']: print(' ' * indent, 'return', kwdict) return kwdict