first commit

This commit is contained in:
teasiu
2025-11-03 15:27:16 +08:00
commit 125598252c
1115 changed files with 60648 additions and 0 deletions

58
pyutils/nv_compare.py Normal file
View File

@@ -0,0 +1,58 @@
def parse_config(file_path):
config = {}
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
if '=' in line:
key, value = line.strip().split('=', 1)
config[key] = value
#else:
# print(f"Ignoring line: {line.strip()} as it does not contain a key-value pair.")
return config
def compare_configs(file1, file2):
result = {
'unique_in_file1': {},
'unique_in_file2': {},
'different_values': {}
}
config1 = parse_config(file1)
config2 = parse_config(file2)
for key, value in config1.items():
if key in config2:
if config2[key] != value:
result['different_values'][key] = (value, config2[key])
else:
result['unique_in_file1'][key] = value
for key, value in config2.items():
if key not in config1:
result['unique_in_file2'][key] = value
return result
def main(config_file1, config_file2):
result = compare_configs(config_file1, config_file2)
print("Keys unique to first file:")
for key in sorted(result['unique_in_file1'].keys(), key=lambda x: (x.split('_')[0], *x.split('_')[1:])):
print(f"{key.replace(':', '=')}: {result['unique_in_file1'][key]}")
print("\nKeys unique to second file:")
for key in sorted(result['unique_in_file2'].keys(), key=lambda x: (x.split('_')[0], *x.split('_')[1:])):
print(f"{key.replace(':', '=')}: {result['unique_in_file2'][key]}")
print("\nKeys with different values:")
for key in sorted(result['different_values'].keys(), key=lambda x: (x.split('_')[0], *x.split('_')[1:])):
value = result['different_values'][key]
print(f"{key.replace(':', '=')}: {value[0]} vs {value[1]}")
if __name__ == "__main__":
config_file1 = r'D:\wifi\随身wifi助手\TQ\f231zc_v1.0_jd\info\nv1.txt'
config_file2 = r'D:\wifi\随身wifi助手\TQ\f231zc_v1.0_jd\pull\etc_ro\default\default_parameter_user'
main()