Skip to content

Commit

Permalink
fixup! fixup! fixup! Complete pip-tools setup (aio-libs#5486)
Browse files Browse the repository at this point in the history
  • Loading branch information
greshilov committed Mar 3, 2021
1 parent 4f846d7 commit e0dd4c9
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions tools/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,23 @@ def install_dependencies(in_name):
def replace_duplicates_with_symlinks():
hash_to_file = collections.defaultdict(list)

for txt_file_name in PIN_FOLDER.glob("*.txt"):
if not txt_file_name.is_symlink():
with open(txt_file_name, "rb") as f:
digest = hashlib.sha1(f.read()).hexdigest()
hash_to_file[digest].append(txt_file_name)

for digest, files in hash_to_file.items():
if len(files) > 1:
base_file, *other_files = files
for other_file in other_files:
os.unlink(other_file)
os.symlink(base_file, other_file)
orig_dir = os.getcwd()
os.chdir(PIN_FOLDER)
try:
for txt_fname in pathlib.Path(".").glob("*.txt"):
if not txt_fname.is_symlink():
with open(txt_fname, "rb") as f:
digest = hashlib.sha1(f.read()).hexdigest()
hash_to_file[digest].append(txt_fname)

for digest, files in hash_to_file.items():
if len(files) > 1:
base_file, *other_files = files
for other_file in other_files:
os.unlink(other_file)
os.symlink(base_file, other_file)
finally:
os.chdir(orig_dir)


if __name__ == "__main__":
Expand Down

0 comments on commit e0dd4c9

Please sign in to comment.