🎨 Rename main file to git_annex_duplicates.py
This commit is contained in:
parent
4d069fb54c
commit
1e8ea44ba8
2 changed files with 5 additions and 1 deletions
31
main.py
31
main.py
|
|
@ -1,31 +0,0 @@
|
|||
import subprocess
|
||||
import collections
|
||||
import re
|
||||
import click
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--exclude", multiple=True, default=[])
|
||||
@click.argument("arguments", nargs=-1)
|
||||
def main(exclude, arguments):
|
||||
# build command
|
||||
find_cmd = ["git", "annex", "find", "--include", "*", "--format=${key}:${file}\n", *arguments]
|
||||
for e in exclude:
|
||||
find_cmd += ["--exclude", e]
|
||||
|
||||
# run
|
||||
result = subprocess.run(find_cmd, capture_output=True)
|
||||
|
||||
files = collections.defaultdict(list)
|
||||
for l in result.stdout.decode("utf-8").split("\n"):
|
||||
if l == "":
|
||||
continue
|
||||
key, file = l.split(":", maxsplit=1)
|
||||
|
||||
files[key].append(file)
|
||||
|
||||
for k in files:
|
||||
if len(files[k]) > 1:
|
||||
for f in files[k]:
|
||||
print(f)
|
||||
print()
|
||||
Loading…
Add table
Add a link
Reference in a new issue