--- mga-gnome/trunk/mga-gnome 2012/03/21 16:16:55 3648 +++ mga-gnome/trunk/mga-gnome 2012/03/21 19:17:35 3649 @@ -484,22 +484,29 @@ return self._svn_author -def get_upstream_names(): - urlopen = urllib2.build_opener() - good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') +class Upstream(object): - # Get the files - usock = urlopen.open(URL) - parser = urllister() - parser.feed(usock.read()) - usock.close() - parser.close() - files = parser.urls + limit = None - tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) + def __init__(self): + urlopen = urllib2.build_opener() - return tarballs + good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') + + # Get the files + usock = urlopen.open(URL) + parser = urllister() + parser.feed(usock.read()) + usock.close() + parser.close() + files = parser.urls + + tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) + if self.limit is not None: + tarballs.intersection_update(self.limit) + + self.names = tarballs def get_downstream_names(): re_file = re.compile(r'^(?P.*?)[_-](?:(?P([0-9]+[\.])*[0-9]+)-)?(?P([0-9]+[\.\-])*[0-9]+)\.(?P(?:tar\.|diff\.)?[a-z][a-z0-9]*)$') @@ -591,7 +598,7 @@ def join_streams(show_version=False, only_diff_version=False): root = os.path.expanduser(PKGROOT) - upstream = get_upstream_names() + upstream = Upstream().names downstream, downstream_files = get_downstream_names() matches = upstream & set(downstream.keys()) @@ -615,7 +622,7 @@ for package, module, package_version, spec_version, downstream_files in sorted(join_streams(show_version=options.show_version, only_diff_version=options.diff)): sys.stdout.write(package) if options.upstream: sys.stdout.write("\t%s" % module) - if options.show_version: sys.stdout.write("\t%s\t%s".join((spec_version, package_version))) + if options.show_version: sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) print def cmd_patches(options, parser): @@ -783,6 +790,9 @@ description = """Mageia GNOME commands.""" epilog="""Report bugs to Olav Vitters""" parser = argparse.ArgumentParser(description=description,epilog=epilog) + parser.add_argument("-l", "--limit", type=argparse.FileType('r', 0), + dest="limit_upstream", metavar="FILE", + help="File containing upstream names") # SUBPARSERS subparsers = parser.add_subparsers(title='subcommands') @@ -849,6 +859,8 @@ sys.exit(2) options = parser.parse_args() + if options.limit_upstream: + Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines()) try: options.func(options, parser)