Created
October 6, 2022 00:48
-
-
Save hughesjj/4482e4b9143b2c801ed43c6174ab4dda 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
def open_file(filename: str) -> str: | |
with open(filename) as fin: | |
return fin.read() | |
docker = open_file("redis-config-docker-default.txt") | |
local = open_file("redis-config-local-default.txt") | |
def to_datastructure(file_contents:str): | |
tokens = file_contents.split('\n') | |
if not tokens[-1]: | |
tokens.pop() | |
print(tokens) | |
i = 0 | |
ds = {} | |
while i < len(tokens): | |
t = tokens[i] | |
# print(f"{t} {i}") | |
i += 1 | |
v = tokens[i] | |
# print(f"{v} {i}") | |
i += 1 | |
ds[t] = v | |
return ds | |
docker_config = to_datastructure(docker) | |
local_config = to_datastructure(local) | |
FILLER = 3*'\t' | |
values_mismatch = [ | |
#(key, docker_config[key], local_config[key]) | |
f"{key}{FILLER}{docker_config[key]}{FILLER}{local_config[key]}" | |
for key in docker_config.keys() & local_config.keys() | |
if docker_config[key] != local_config[key] | |
] | |
print(f"Keys in DOCKER but not in LOCAL: {','.join(docker_config.keys() - local_config.keys())}") | |
print(f"Keys in LOCAL but not in DOCKER: {','.join(local_config.keys() - docker_config.keys())}") | |
print(f"MISMATCHED VALUES: {','.join(local_config.keys() - docker_config.keys())}") | |
print("Key Docker Local\n" + '==='.join(3*[FILLER])+ "\n" +'\n'.join(values_mismatch)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Diff: