diff options
Diffstat (limited to 'BuildManager/clean.py')
-rw-r--r-- | BuildManager/clean.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/BuildManager/clean.py b/BuildManager/clean.py new file mode 100644 index 0000000..e0e3f93 --- /dev/null +++ b/BuildManager/clean.py @@ -0,0 +1,37 @@ +from BuildManager.fileutil import * +from BuildManager.package import * +from BuildManager import * +import os + +class PackageCleaner: + def __init__(self, opts): + self.opts = opts + + def run(self): + pkglist = PackageList() + pkglist_check = PackageList() + logger.info("creating package list") + for filename in self.opts.args: + pkglist.append(Package(filename)) + if self.opts.check: + for dir in self.opts.check: + logger.info("creating package check list for "+dir) + for entry in os.listdir(dir): + entrypath = os.path.join(dir, entry) + if os.path.isfile(entrypath): + pkglist_check.append(Package(entrypath)) + logger.info("processing package list") + for pkg in pkglist[:]: + if pkglist.has_gt(pkg) or pkglist_check.has_gt(pkg): + pkglist.remove(pkg) + if self.opts.move: + move_file(pkg.file, self.opts.move, + dryrun=self.opts.dryrun) + elif self.opts.copy: + copy_file(pkg.file, self.opts.copy, + dryrun=self.opts.dryrun) + else: + logger.info("removing "+pkg.file) + if not self.opts.dryrun: + os.unlink(pkg.file) + return True |