aboutsummaryrefslogtreecommitdiff
path: root/file-tagger.py
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2023-03-31 03:27:21 +0200
committerLeonard Kugis <leonard@kug.is>2023-03-31 03:27:21 +0200
commit1433cd6f2dccb6b981209a2cc2a3ac6a45156387 (patch)
tree4ccdcf7aa650b746437fcb551f4e5d1806b655c2 /file-tagger.py
parenta76c7a1839573052ea7694ea63aea31a6cd137f7 (diff)
TMSU: Classified and added option to override default command.
Diffstat (limited to 'file-tagger.py')
-rw-r--r--file-tagger.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/file-tagger.py b/file-tagger.py
index 36953ec..9708dfa 100644
--- a/file-tagger.py
+++ b/file-tagger.py
@@ -16,7 +16,7 @@ Walk over all files for the given base directory and all subdirectories recursiv
Parameters:
args: Argument dict.
'''
-def walk(args):
+def walk(tmsu, args):
logger = logging.getLogger(__name__)
logger.info("Walking files ...")
@@ -43,7 +43,7 @@ def walk(args):
for i in range(args["index"], len(files)):
file_path = files[i]
logger.info("Handling file {}, {}".format(i, file_path))
- tags = tmsu_tags(args["base"], file_path)
+ tags = tmsu.tags(file_path)
not_empty = bool(tags)
logger.info("Existing tags: {}".format(tags))
@@ -97,7 +97,7 @@ def walk(args):
tags = set(input_with_prefill("\nTags for file {}:\n".format(file_path), ','.join(tags)).split(","))
logger.info("Tagging {}".format(tags))
- tmsu_tag(args["base"], file_path, tags, untag=not_empty)
+ tmsu.tag(file_path, tags, untag=not_empty)
if __name__ == "__main__":
@@ -105,6 +105,7 @@ if __name__ == "__main__":
parser.add_argument('-b', '--base', nargs='?', default='.', type=dir_path, help='Base directory with database (default: %(default)s)')
parser.add_argument('-f', '--file-dir', nargs='?', default='.', type=dir_path, help='File directory for walking (default: %(default)s)')
parser.add_argument('-g', '--gui', nargs='?', const=1, default=False, type=bool, help='Show main GUI (default: %(default)s)')
+ parser.add_argument('--tmsu-command', nargs='?', const=1, default="tmsu", type=str, help='TMSU command override (default: %(default)s)')
parser.add_argument('--predict-images', nargs='?', const=1, default=False, type=bool, help='Use prediction for image tagging (default: %(default)s)')
parser.add_argument('--predict-images-backend', nargs='?', const=1, choices=["torch", "tensorflow", "keras"], default="torch", type=str.lower, help='Determines which backend should be used for keyword prediction (default: %(default)s)')
parser.add_argument('--predict-images-top', nargs='?', const=1, default=10, type=int, help='Defines how many top prediction keywords should be used (default: %(default)s)')
@@ -133,6 +134,7 @@ if __name__ == "__main__":
"base": args.base,
"file_dir": args.file_dir,
"gui": args.gui,
+ "tmsu_command": args.tmsu_command,
"predict_images": args.predict_images,
"predict_images_backend": args.predict_images_backend,
"predict_images_top": args.predict_images_top,
@@ -153,5 +155,7 @@ if __name__ == "__main__":
logger.debug("Starting main GUI ...")
args = GuiMain(args).loop()
- if tmsu_init(args["base"]):
- walk(args)
+ tmsu = TMSU(args["base"], args["tmsu_command"])
+
+ if tmsu.status:
+ walk(tmsu, args)