Created
August 16, 2022 13:11
-
-
Save achilleas-k/e44d1af64df906cca6c7dbe3aef0e706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def read_and_trim(fname: str): | |
with open(fname, "r", encoding="utf-8") as modulesfile: | |
data = modulesfile.read() | |
lines = data.split("\n") | |
return [line.split("/")[-1] for line in lines] | |
a = sys.argv[1] | |
b = sys.argv[2] | |
adata = set(read_and_trim(a)) | |
bdata = set(read_and_trim(b)) | |
bdiff = set(bdata) | |
for amod in adata: | |
try: | |
bdiff.remove(amod) | |
except KeyError: | |
pass | |
adiff = set(adata) | |
for bmod in bdata: | |
try: | |
adiff.remove(bmod) | |
except KeyError: | |
pass | |
if len(adiff) == 0: | |
print("No unique elements in A") | |
else: | |
print(f"Only in A ({len(adiff)}/{len(adata)})") | |
print(sorted(adiff)) | |
if len(bdiff) == 0: | |
print("No unique elements in B") | |
else: | |
print(f"Only in B ({len(bdiff)}/{len(bdata)})") | |
print(sorted(bdiff)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment