def t(self, s, expected): if expected is None: with assert_raises(ValueError): M.parse_bugspec(s) else: n = M.parse_bugspec(s) assert_is_instance(n, int) assert_equal(n, expected)
def run(options): bugs = [] for bugspec in options.bugs: try: bugs += [deblogic.parse_bugspec(bugspec)] except ValueError: options.error('{0!r} is not a valid bug number'.format(bugspec)) for bugno in bugs: run_one(bugno, options=options)
def run(options): utils.reset_SIGPIPE() bugs = [] for bugspec in options.bugs: try: bugs += [deblogic.parse_bugspec(bugspec)] except ValueError: options.error('{0!r} is not a valid bug number'.format(bugspec)) for bugno in bugs: run_one(bugno, options=options)
def run(options): debsoap_client = debsoap.Client(session=options.session) queries = [] for selection in options.selections: bugno = None try: bugno = deblogic.parse_bugspec(selection) except ValueError: pass if bugno is not None: queries += [bugno] elif ':' in selection: selector, value = selection.split(':', 1) selector = selectors[selector] if callable(selector): queries += selector(value) else: queries += [{selector: value}] elif deblogic.is_package_name(selection): queries += [dict(package=selection)] else: path = selection try: os.stat(path) except OSError: options.error('{0!r} is not a valid package name'.format(selection)) if os.path.isdir(path): queries += select_for_unpacked(path) elif path.endswith('.deb'): queries += select_for_deb(path) elif path.endswith('.dsc'): queries += select_for_dsc(path) else: options.error('{0!r} is not a valid package name'.format(selection)) bugs = debsoap_client.get_bugs(*queries) bugs = sorted(bugs, key=(lambda bug: -bug.id)) for bug in bugs: package = bug.package subject = bug.subject or '' default_severity = 'normal' if package == 'wnpp': for wnpp_tag in deblogic.wnpp_tags: if subject.startswith(wnpp_tag + ': '): if wnpp_tag[-1] == 'P': default_severity = 'wishlist' package = None break elif package == 'sponsorship-requests': if subject.startswith('RFS:'): package = None template = '' source = None subject_color = '{t.green}' if bug.done else '{t.bold}' if package is not None: if package.startswith('src:'): source = package[4:] new_subject = strip_package_prefix(subject, source) if subject != new_subject: subject = new_subject template += '[src:' + subject_color + '{src}{t.off}] ' else: template += '[src:{src}] ' else: new_subject = strip_package_prefix(subject, package) if subject != new_subject: subject = new_subject template += '[' + subject_color + '{pkg}{t.off}] ' else: template += '[{pkg}] ' if subject: template += subject_color + '{subject}{t.off}' else: template += '{t.red}(no subject){t.off}' colorterm.print(template, pkg=package, src=source, subject=subject, ) indent = ' ' template = indent + '{t.cyan}https://bugs.debian.org/{n}{t.off}' if bug.forwarded: template += ' -> {t.cyan}{forwarded}{t.off}' colorterm.print(template, n=bug.id, forwarded=bug.forwarded) template = indent + '{user}; {date}-00:00' user = bug.submitter if package == 'wnpp' and bug.owner is not None: user = bug.owner colorterm.print(template, user=user, date=bug.date, ) template = '' if bug.severity != default_severity: severity_color = ( '{t.bold}{t.red}' if bug.severity in deblogic.rc_severities else '' ) template = severity_color + '{severity}{t.off}' if bug.tags: if template: template += ' ' template += '{tags}' if template: template = indent + template colorterm.print(template, tags=' '.join('+' + t for t in bug.tags), severity=bug.severity, ) template = '' if bug.found_versions: template = 'found in {found}' if bug.fixed_versions: if template: template += '; ' template += 'fixed in {fixed}' if template: template = indent + template colorterm.print(template, found=', '.join(bug.found_versions), fixed=', '.join(bug.fixed_versions), ) print()
def run(options): utils.reset_SIGPIPE() debsoap_client = debsoap.Client(session=options.session) queries = [] for selection in options.selections: bugno = None try: bugno = deblogic.parse_bugspec(selection) except ValueError: pass if bugno is not None: queries += [bugno] elif utils.looks_like_path(selection): path = selection try: os.stat(path) except OSError: options.error('{0!r} is not a package'.format(path)) if os.path.isdir(path + '/debian'): queries += select_for_unpacked(path) elif path.endswith('.dsc'): queries += select_for_dsc(path) elif path.endswith('.deb'): queries += select_for_deb(path) else: options.error('{0!r} is not a package'.format(path)) elif ':' in selection: selector, value = selection.split(':', 1) try: selector = selectors[selector] except KeyError: options.error('{0!r} is not a valid selector'.format(selector)) if callable(selector): queries += selector(value) else: queries += [{selector: value}] elif deblogic.is_package_name(selection): queries += [dict(package=selection)] else: options.error( '{0!r} is not a valid package name'.format(selection)) bugs = debsoap_client.get_bugs(*queries) bugs = sorted(bugs, key=(lambda bug: -bug.id)) for bug in bugs: package = bug.package subject = bug.subject or '' default_severity = 'normal' if package == 'wnpp': for wnpp_tag in deblogic.wnpp_tags: if subject.startswith(wnpp_tag + ': '): if wnpp_tag[-1] == 'P': default_severity = 'wishlist' package = None break elif package == 'sponsorship-requests': if subject.startswith('RFS:'): package = None template = '' source = None subject_color = '{t.green}' if bug.done else '{t.bold}' if package is not None: if package.startswith('src:'): source = package[4:] new_subject = strip_package_prefix(subject, source) if subject != new_subject: subject = new_subject template += '[src:' + subject_color + '{src}{t.off}] ' else: template += '[src:{src}] ' else: new_subject = strip_package_prefix(subject, package) if subject != new_subject: subject = new_subject template += '[' + subject_color + '{pkg}{t.off}] ' else: template += '[{pkg}] ' if subject: template += subject_color + '{subject}{t.off}' else: template += '{t.red}(no subject){t.off}' colorterm.print( template, pkg=package, src=source, subject=subject, ) indent = ' ' template = indent + '{t.cyan}https://bugs.debian.org/{n}{t.off}' if bug.forwarded: template += ' -> {t.cyan}{forwarded}{t.off}' colorterm.print(template, n=bug.id, forwarded=bug.forwarded) template = indent + '{user}; {date}-00:00' user = bug.submitter if package == 'wnpp' and bug.owner is not None: user = bug.owner colorterm.print( template, user=user, date=bug.date, ) template = '' if bug.severity != default_severity: severity_color = ('{t.bold}{t.red}' if bug.severity in deblogic.rc_severities else '') template = severity_color + '{severity}{t.off}' if bug.tags: if template: template += ' ' template += '{tags}' if template: template = indent + template colorterm.print( template, tags=' '.join('+' + t for t in bug.tags), severity=bug.severity, ) template = '' if bug.found_versions: template = 'found in {found}' if bug.fixed_versions: if template: template += '; ' template += 'fixed in {fixed}' if template: template = indent + template colorterm.print( template, found=', '.join(bug.found_versions), fixed=', '.join(bug.fixed_versions), ) print()