-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmp-server-properties.py
More file actions
executable file
·41 lines (33 loc) · 1.08 KB
/
cmp-server-properties.py
File metadata and controls
executable file
·41 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/env python3
import sys
def get_file_content(filename):
with open(filename, "r") as filehandle:
return filehandle.read()
def get_data(filename):
data = {}
content = get_file_content(filename)
lines = content.split("\n")
for line in lines:
parts = line.split("=")
if len(parts) == 2:
key = parts[0]
value = parts[1]
data[key] = value
return data
def compare(filename1, filename2):
data1 = get_data(filename1)
data2 = get_data(filename2)
for key, value in data1.items():
if key not in data2:
print ("Key '" + key + "' is not exists in '" + filename2 + "'")
elif data2[key] != value:
print ("Value of key '" + key + "' differs: '" + value + "' vs. '" + data2[key] + "'")
for key, value in data2.items():
if key not in data1:
print ("Key '" + key + "' is not exists in '" + filename1 + "'")
def main():
filename1 = sys.argv[1]
filename2 = sys.argv[2]
compare(filename1, filename2)
if __name__ == "__main__":
main()