Elborated rename function to recommend
This commit is contained in:
@@ -28,13 +28,19 @@ def print_recommendation(path: str | None, text: str, ctx: InferenceContext,
|
|||||||
print(f"- {i}: {r} ({cat}-{subcat})")
|
print(f"- {i}: {r} ({cat}-{subcat})")
|
||||||
|
|
||||||
if interactive_rename and path is not None:
|
if interactive_rename and path is not None:
|
||||||
response = input("Enter number, or any key to skip: ")
|
response = input("Enter number, t <text> for alternate text, or "
|
||||||
if match(r'^[0-9]+\n', response):
|
"return to skip: ")
|
||||||
selection = int(response)
|
|
||||||
|
if m := match(r'^([0-9]+)', response):
|
||||||
|
selection = int(m.group(1))
|
||||||
if 0 <= selection < len(recs):
|
if 0 <= selection < len(recs):
|
||||||
new_name = recs[selection] + '_' + os.path.basename(path)
|
new_name = recs[selection] + '_' + os.path.basename(path)
|
||||||
new_path = os.path.join(os.path.dirname(path), new_name)
|
new_path = os.path.join(os.path.dirname(path), new_name)
|
||||||
os.rename(path, new_path)
|
os.rename(path, new_path)
|
||||||
|
elif m := match(r'^t (.*)', response):
|
||||||
|
print("searching for new matches")
|
||||||
|
text = m.group(1)
|
||||||
|
print_recommendation(path, text, ctx, True)
|
||||||
|
|
||||||
|
|
||||||
@click.group(epilog="For more information see "
|
@click.group(epilog="For more information see "
|
||||||
|
Reference in New Issue
Block a user