diff options
author | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-04-11 01:09:25 -0500 |
---|---|---|
committer | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-04-11 01:09:25 -0500 |
commit | 3fb5f8efef231dd7784be880934cd106603ab6f1 (patch) | |
tree | b3f62a0fb712de3f0c5fea92f7171d6fbf3cd2b2 /mkpending.py | |
parent | 61ee5da8b31b44e80e008619a32ca886d8799646 (diff) |
bash-port ready for testing.
Diffstat (limited to 'mkpending.py')
-rw-r--r-- | mkpending.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/mkpending.py b/mkpending.py new file mode 100644 index 0000000..43a5fb2 --- /dev/null +++ b/mkpending.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +from repm.filter import * + +def make_pending(path_to_db): + """ Determine wich packages are pending for license auditing.""" + packages_iterable=pkginfo_from_db(path_to_db) + search = tuple(listado(config["blacklist"]) + + listado(config["whitelist"])) + + pkgs=[pkg for pkg in packages_iterable + if "custom" in pkg["license"] + and pkg["name"] not in search] + return pkgs + +def write_pending(packages_iterable, repo, prefix=config["pending"]): + """ Write a pending file with the info of the packages """ + filename=prefix + "-" + repo + ".txt" + try: + fsock=open(filename, "a") + except(IOError): + print("Can't read %s" % filename) + finally: + fsock.close() + if os.path.isfile(filename): + pkgs=[pkg for pkg in packages_iterable if pkg["name"] not in + listado(filename)] + fsock.write("\n".join([pkg["name"] + ":" + pkg["license"] + for pkg in pkgs]) + "\n") + fsock.close() + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Clean a repo db and packages") + parser.add_argument("-b", "--dababase", type=str, required=True + help="database to check") + parser.add_argument("-r", "--repo", type=str, required=True + help="repo of database") + args=parser.parse_args() + + if args.database and args.repo: + pkgs=make_pending(args.database) + write_pending(pkgs, args.repo) + else: + parser.print_help() |