atomicshop 2.19.14__py3-none-any.whl → 2.19.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of atomicshop might be problematic. Click here for more details.
- atomicshop/__init__.py +1 -1
- atomicshop/a_mains/update_config_toml.py +38 -0
- atomicshop/file_io/tomls.py +21 -15
- {atomicshop-2.19.14.dist-info → atomicshop-2.19.16.dist-info}/METADATA +1 -1
- {atomicshop-2.19.14.dist-info → atomicshop-2.19.16.dist-info}/RECORD +8 -7
- {atomicshop-2.19.14.dist-info → atomicshop-2.19.16.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.19.14.dist-info → atomicshop-2.19.16.dist-info}/WHEEL +0 -0
- {atomicshop-2.19.14.dist-info → atomicshop-2.19.16.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import os.path
|
|
2
|
+
import sys
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
from atomicshop.file_io import tomls
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def parse_args():
|
|
9
|
+
parser = argparse.ArgumentParser(
|
|
10
|
+
description='Update the config.toml file.\n'
|
|
11
|
+
'This script will update the current config.toml file with the keys from the target config.toml file.\n'
|
|
12
|
+
'If the key is not present in the current config.toml file, it will be added.\n'
|
|
13
|
+
'If the key is present in the current config.toml file, its value will be left unchanged.\n')
|
|
14
|
+
parser.add_argument('current_config_file', type=str, help="Path to the current config.toml file that will be updated.")
|
|
15
|
+
parser.add_argument('target_config_file', type=str, help="Path to the target config.toml file that we'll get the updates from.")
|
|
16
|
+
parser.add_argument('-n', '--new_file_path', type=str, help="(OPTIONAL) Path to the new config.toml file that will be created with the updates.", default=None)
|
|
17
|
+
return parser.parse_args()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main():
|
|
21
|
+
args = parse_args()
|
|
22
|
+
|
|
23
|
+
if os.path.isfile(args.current_config_file) is False:
|
|
24
|
+
print(f"Error: The current config file '{args.current_config_file}' does not exist.")
|
|
25
|
+
return 1
|
|
26
|
+
if os.path.isfile(args.target_config_file) is False:
|
|
27
|
+
print(f"Error: The target config file '{args.target_config_file}' does not exist.")
|
|
28
|
+
return 1
|
|
29
|
+
|
|
30
|
+
tomls.update_toml_file_with_new_config(
|
|
31
|
+
main_config_file_path=args.current_config_file,
|
|
32
|
+
changes_config_file_path=args.target_config_file,
|
|
33
|
+
new_config_file_path=args.new_file_path)
|
|
34
|
+
return 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if __name__ == '__main__':
|
|
38
|
+
sys.exit(main())
|
atomicshop/file_io/tomls.py
CHANGED
|
@@ -5,6 +5,7 @@ try:
|
|
|
5
5
|
import tomllib
|
|
6
6
|
except ModuleNotFoundError:
|
|
7
7
|
# This is library from pypi.
|
|
8
|
+
# noinspection PyPackageRequirements
|
|
8
9
|
import tomli as tomllib
|
|
9
10
|
|
|
10
11
|
from . import file_io
|
|
@@ -14,6 +15,7 @@ class TomlValueNotImplementedError(Exception):
|
|
|
14
15
|
pass
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
# noinspection PyUnusedLocal
|
|
17
19
|
@file_io.read_file_decorator
|
|
18
20
|
def read_toml_file(file_path: str,
|
|
19
21
|
file_mode: str = 'rb',
|
|
@@ -35,6 +37,7 @@ def read_toml_file(file_path: str,
|
|
|
35
37
|
return tomllib.load(file_object)
|
|
36
38
|
|
|
37
39
|
|
|
40
|
+
# noinspection PyUnusedLocal
|
|
38
41
|
@file_io.write_file_decorator
|
|
39
42
|
def write_toml_file(
|
|
40
43
|
toml_content: dict,
|
|
@@ -112,7 +115,11 @@ def update_toml_file_with_new_config(
|
|
|
112
115
|
If not, the changes will be written to the 'main_config_file_path'.
|
|
113
116
|
"""
|
|
114
117
|
|
|
115
|
-
|
|
118
|
+
if not changes_config_file_path and not changes_dict:
|
|
119
|
+
raise ValueError("You must provide either 'changes_config_file_path' or 'changes_dict'.")
|
|
120
|
+
if changes_config_file_path and changes_dict:
|
|
121
|
+
raise ValueError("You can't provide both 'changes_config_file_path' and 'changes_dict'.")
|
|
122
|
+
|
|
116
123
|
with open(main_config_file_path, 'r') as file:
|
|
117
124
|
main_config_file_text_lines: list = file.readlines()
|
|
118
125
|
|
|
@@ -121,30 +128,29 @@ def update_toml_file_with_new_config(
|
|
|
121
128
|
# Read the new config file.
|
|
122
129
|
main_config_file_dict: dict = read_toml_file(main_config_file_path)
|
|
123
130
|
|
|
124
|
-
if changes_dict:
|
|
125
|
-
|
|
126
|
-
else:
|
|
127
|
-
changes_config_file_dict: dict = read_toml_file(changes_config_file_path)
|
|
131
|
+
if not changes_dict:
|
|
132
|
+
changes_dict: dict = read_toml_file(changes_config_file_path)
|
|
128
133
|
|
|
129
134
|
# Update the config text lines.
|
|
130
135
|
for category, settings in main_config_file_dict.items():
|
|
131
|
-
if category not in
|
|
136
|
+
if category not in changes_dict:
|
|
132
137
|
continue
|
|
133
138
|
|
|
134
139
|
for key, value in settings.items():
|
|
135
140
|
# If the key is in the old config file, use the old value.
|
|
136
|
-
if key not in
|
|
141
|
+
if key not in changes_dict[category]:
|
|
137
142
|
continue
|
|
138
143
|
|
|
139
|
-
if main_config_file_dict[category][key] !=
|
|
144
|
+
if main_config_file_dict[category][key] != changes_dict[category][key]:
|
|
140
145
|
# Get the line of the current category line.
|
|
141
146
|
current_category_line_index_in_text = None
|
|
142
147
|
for current_category_line_index_in_text, line in enumerate(main_config_file_text_lines):
|
|
143
148
|
if f"[{category}]" in line:
|
|
144
149
|
break
|
|
145
150
|
|
|
146
|
-
#
|
|
147
|
-
|
|
151
|
+
# Get the index inside the main config file dictionary of the current category.
|
|
152
|
+
main_config_list_of_keys: list = list(main_config_file_dict.keys())
|
|
153
|
+
current_category_index_in_main_config_dict = main_config_list_of_keys.index(category)
|
|
148
154
|
|
|
149
155
|
try:
|
|
150
156
|
next_category_name = list(
|
|
@@ -191,20 +197,20 @@ def update_toml_file_with_new_config(
|
|
|
191
197
|
# noinspection PyUnboundLocalVariable
|
|
192
198
|
comment = main_config_file_text_lines[line_index].replace(string_to_check, '')
|
|
193
199
|
|
|
194
|
-
object_type = type(
|
|
200
|
+
object_type = type(changes_dict[category][key])
|
|
195
201
|
if object_type == bool:
|
|
196
|
-
value_string_to_set = str(
|
|
202
|
+
value_string_to_set = str(changes_dict[category][key]).lower()
|
|
197
203
|
elif object_type == str:
|
|
198
|
-
value_string_to_set = f"'{
|
|
204
|
+
value_string_to_set = f"'{changes_dict[category][key]}'"
|
|
199
205
|
elif object_type == int:
|
|
200
|
-
value_string_to_set = str(
|
|
206
|
+
value_string_to_set = str(changes_dict[category][key])
|
|
201
207
|
|
|
202
208
|
# noinspection PyUnboundLocalVariable
|
|
203
209
|
line_to_set = f"{key} = {value_string_to_set}{comment}"
|
|
204
210
|
# Replace the line with the old value.
|
|
205
211
|
main_config_file_text_lines[line_index] = line_to_set
|
|
206
212
|
|
|
207
|
-
main_config_file_dict[category][key] =
|
|
213
|
+
main_config_file_dict[category][key] = changes_dict[category][key]
|
|
208
214
|
|
|
209
215
|
if new_config_file_path:
|
|
210
216
|
file_path_to_write = new_config_file_path
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=iSWSvU0vNJjZowFs0TPAYg5UgE0d7XERSmYHkUprfXg,124
|
|
2
2
|
atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
|
|
3
3
|
atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
|
|
4
4
|
atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
|
|
@@ -64,6 +64,7 @@ atomicshop/a_mains/dns_gateway_setting.py,sha256=ncc2rFQCChxlNP59UshwmTonLqC6MWb
|
|
|
64
64
|
atomicshop/a_mains/github_wrapper.py,sha256=F-PoZknVCxWPN0PTO6l7ZNiaYvo7OVFKFI_zlPt56ps,169
|
|
65
65
|
atomicshop/a_mains/msi_unpacker.py,sha256=5hrkqETYt9HIqR_3PMf32_q06kCrIcsdm_RJV9oY438,188
|
|
66
66
|
atomicshop/a_mains/search_for_hyperlinks_in_docx.py,sha256=HkIdo_Sz9nPbbbJf1mwfwFkyI7vkvpH8qiIkuYopN4w,529
|
|
67
|
+
atomicshop/a_mains/update_config_toml.py,sha256=s-x_vmWCbB7jljNhR7rviM0IM1_CyxvybMpAwNjkBto,1664
|
|
67
68
|
atomicshop/a_mains/FACT/factw_fact_extractor_docker_image_main_sudo.py,sha256=DDKX3Wp2SmzMCEtCIEOUbEKMob2ZQ7VEQGLEf9uYXrs,320
|
|
68
69
|
atomicshop/a_mains/FACT/update_extract.py,sha256=atNIBKDeGAM1XNymDjnEHq7Ke3i_rXlAfrT-1pDdz_Q,544
|
|
69
70
|
atomicshop/addons/PlayWrightCodegen.cmd,sha256=Z5cnllsyXD4F1W2h-WLEnyFkg5nZy0-hTGHRWXVOuW4,173
|
|
@@ -128,7 +129,7 @@ atomicshop/file_io/csvs.py,sha256=zv0kKjRT-ZWRi0WpMIUQ_FKyP9Dt0f5Bc98Qsj6ClPU,94
|
|
|
128
129
|
atomicshop/file_io/docxs.py,sha256=Nyt3hSpzwqUKZEP5p5efqNpjFs9XqkK40Kp7BbbPo7E,6245
|
|
129
130
|
atomicshop/file_io/file_io.py,sha256=8pKH08ILN91gfeNC0hrtLCx7l9ZgmcPAYIcLydDtZ-k,7198
|
|
130
131
|
atomicshop/file_io/jsons.py,sha256=GJyVlGTcdhjZ-andfz7_dYVk1O74f-23Mc9PDmdjtPI,7424
|
|
131
|
-
atomicshop/file_io/tomls.py,sha256=
|
|
132
|
+
atomicshop/file_io/tomls.py,sha256=vZ_Wng5alLf8z6HSEZj7PS0XKDA-Iies9ihVWOkTcKo,10048
|
|
132
133
|
atomicshop/file_io/xlsxs.py,sha256=v_dyg9GD4LqgWi6wA1QuWRZ8zG4ZwB6Dz52ytdcmmmI,2184
|
|
133
134
|
atomicshop/file_io/xmls.py,sha256=zh3SuK-dNaFq2NDNhx6ivcf4GYCfGM8M10PcEwDSpxk,2104
|
|
134
135
|
atomicshop/mitm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -329,8 +330,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
|
|
|
329
330
|
atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
330
331
|
atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
|
|
331
332
|
atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
|
|
332
|
-
atomicshop-2.19.
|
|
333
|
-
atomicshop-2.19.
|
|
334
|
-
atomicshop-2.19.
|
|
335
|
-
atomicshop-2.19.
|
|
336
|
-
atomicshop-2.19.
|
|
333
|
+
atomicshop-2.19.16.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
334
|
+
atomicshop-2.19.16.dist-info/METADATA,sha256=uDnHTYzOlT54oM3QgJckEUYc5iDwE6wBipRH9S1aUB8,10631
|
|
335
|
+
atomicshop-2.19.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
336
|
+
atomicshop-2.19.16.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
337
|
+
atomicshop-2.19.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|