update for current dev-python/over

This commit is contained in:
Martin Sekera 2022-03-21 12:51:00 +01:00
parent ce5ebd7d97
commit 5ddb61237d
2 changed files with 15 additions and 15 deletions

View file

@ -16,19 +16,19 @@ import version
# --------------------------------------------------
if __name__ == "__main__":
main = over.app.Main("Find Orhpans", version.str, "AO-JSL", features={"config_file": True})
main = over.app.Main("find-orhpans", version.str, "AO-JSL", features={"config_file": True})
#main.add_option("filter", "Shell globs that should be filtered out.", over.callback.strings, abbr="f", count=1)
main.add_option("filter", "Shell globs that should be filtered out.", over.callback.strings, abbr="f", count=1, overwrite=False)
main.add_option("null-separated", "Output each filename separated with a null character. Otherwise use a newline.", bool, [False], abbr="0", count=1)
main.add_doc("Description", ["Finds files on Gentoo systems that aren\"t owned by any installed package and lists them."])
main.add_doc("Description", ["Finds files on Gentoo systems that aren't owned by any installed package and lists them."])
main.setup()
# works around bug over:#15 (https://git.covalent.cz/overwatch/over/issues/15)
if not main.cfg.filter:
main.cfg.filter = ["*.pyc", "/lib*/modules/*", "*.pyo", "/usr/share/mime/*", "/usr/local/*", "/usr/src/*"]
main.cfg.filter = ["*/.keep", "*.pyc", "/lib*/modules/*", "*.pyo", "/usr/share/mime/*", "/usr/local/*", "/usr/src/*"]
if not main.targets:
main.print("specify at least one directory to work on, e.g. <M>/usr<.> or <M>/lib64<.>", main.print.tl.fail)
main.log.fail("specify at least one directory to work on, e.g. <M>/usr<.> or <M>/lib64<.>")
main.exit(1)
# --------------------------------------------------
@ -40,7 +40,7 @@ if __name__ == "__main__":
proc.run()
threads.append({"proc": proc, "output_buffer": [], "root": root})
main.print("gathering a list of all files using %d processes" %(len(threads)), main.print.tl.start)
main.log.begin("gathering a list of all files using %d processes", len(threads))
while True:
at_least_one_lives = False
@ -57,7 +57,7 @@ if __name__ == "__main__":
else:
break
main.print("post-processing file list")
main.log.begin("post-processing file list")
all_files = set()
@ -67,16 +67,16 @@ if __name__ == "__main__":
try:
name = raw_name.decode("utf-8")
except UnicodeDecodeError:
main.print("UTF-8 decoding failed: <R>%s<.>" %(repr(raw_name)), main.print.tl.fail)
main.log.fail("UTF-8 decoding failed: <R>%s<.>", repr(raw_name))
all_files.add(os.path.normpath(os.path.join(os.path.abspath(thread["root"]), name)))
main.print("found %d files" %(len(all_files)), main.print.tl.done)
main.log.done("found %d files", len(all_files))
# --------------------------------------------------
# create a list of owned files
main.print("gathering a list of files owned by installed packages", main.print.tl.start)
main.log.begin("gathering a list of files owned by installed packages")
owned_files = set()
@ -85,22 +85,22 @@ if __name__ == "__main__":
unowned_files = all_files - owned_files
main.print("found %d owned files" %(len(owned_files)), main.print.tl.done)
main.print("there are %d unowned files" %(len(unowned_files)))
main.log.done("found %d owned files", len(owned_files))
main.log.info("there are %d unowned files", len(unowned_files))
# --------------------------------------------------
# apply filters
main.print("applying filters", main.print.tl.start)
main.log.begin("applying filters")
unowned_files_ignored = set()
for filter in main.cfg.filter:
for filter in main.cfg.filter + main.targets:
unowned_files_ignored.update(fnmatch.filter(unowned_files, filter))
files_to_output = unowned_files - unowned_files_ignored
color = "y" if files_to_output else "g"
main.print("found <%s>%d unowned files<.>" %(color, len(files_to_output)), main.print.tl.done)
main.log.done("found <%s>%d unowned files<.>", color, len(files_to_output))
# --------------------------------------------------
# output

View file

@ -4,5 +4,5 @@
major = 0 # VERSION_MAJOR_IDENTIFIER
minor = 2 # VERSION_MINOR_IDENTIFIER
# VERSION_LAST_MM 0.2
patch = 3 # VERSION_PATCH_IDENTIFIER
patch = 4 # VERSION_PATCH_IDENTIFIER
str = ".".join(str(v) for v in (major, minor, patch))