summaryrefslogtreecommitdiff
path: root/clean_repo.py
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-04-13 00:52:10 -0500
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-04-13 00:52:10 -0500
commit36c0426277b03c3af60e94458c11d70a32a2030c (patch)
tree532bfb100863f31664b3747d74bb31aeeeb93823 /clean_repo.py
parent3e27d11f68571bce92138f6cbfcaecac75fa1644 (diff)
parent748600bf8dfba34b336ad642a6b26dae674db85f (diff)
Fixed more errors and refactoring
Diffstat (limited to 'clean_repo.py')
-rwxr-xr-xclean_repo.py44
1 files changed, 40 insertions, 4 deletions
diff --git a/clean_repo.py b/clean_repo.py
index d4e06fc..eccfd01 100755
--- a/clean_repo.py
+++ b/clean_repo.py
@@ -3,6 +3,37 @@
from repm.filter import *
import argparse
+def mkpending(path_to_db, repo, prefix=config["pending"]):
+ """ Determine wich packages are pending for license auditing."""
+ if "~" in path_to_db:
+ path_to_db=(os.path.expanduser(path_to_db))
+
+ search = tuple(listado(config["blacklist"]) +
+ listado(config["whitelist"]))
+
+ pkgs=list(pkginfo_from_db(path_to_db))
+
+ filename=prefix + "-" + repo + ".txt"
+ try:
+ fsock=open(filename, "rw")
+ pkgs=[pkg for pkg in pkginfo_from_db(path_to_db)
+ if pkg["name"] not in listado(filename)]
+ for line in fsock.readlines():
+ if line:
+ pkg=Package()
+ pkg["name"]=line.split(":")[0]
+ pkg["license"]=":".join(line.split(":")[1:])
+ pkgs.append(pkg)
+ pkgs=[pkg for pkg in pkgs if pkg["name"] not in search
+ and "custom" in pkg["license"]]
+ fsock.write("\n".join([pkg["name"] + ":" + pkg["license"]
+ for pkg in pkgs]) + "\n")
+ except(IOError):
+ raise NonValidFile("Can't read or write %s" % filename)
+ finally:
+ fsock.close()
+ return pkgs
+
def remove_from_blacklist(path_to_db, blacklisted_names,
debug=config["debug"]):
""" Check the blacklist and remove packages on the db"""
@@ -37,13 +68,18 @@ if __name__ == "__main__":
help="directory to clean")
args=parser.parse_args()
- if args.directory:
- cleanup_nonfree_in_dir(args.directory, listado(config["blacklist"]))
-
if args.database:
+ repo=os.path.basename(args.database).split(".")[0]
pkgs=pkginfo_from_db(args.database)
remove_from_blacklist(args.database, pkgs,
tuple(listado(config["blacklist"]) +
- listado(config["pending"])))
+ listado(config["pending"] +
+ "-" + repo + ".txt")))
+ mkpending(args.database, args.repo)
+
+ if args.directory:
+ cleanup_nonfree_in_dir(args.directory,
+ listado(config["blacklist"]))
+
if not args.directory and not args.database:
parser.print_help()