atomicshop 2.18.27__py3-none-any.whl → 2.18.28__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/file_io/file_io.py +2 -1
- atomicshop/file_io/jsons.py +49 -0
- atomicshop/mitm/engines/__parent/recorder___parent.py +7 -23
- atomicshop/tempfiles.py +1 -2
- {atomicshop-2.18.27.dist-info → atomicshop-2.18.28.dist-info}/METADATA +1 -1
- {atomicshop-2.18.27.dist-info → atomicshop-2.18.28.dist-info}/RECORD +10 -10
- {atomicshop-2.18.27.dist-info → atomicshop-2.18.28.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.18.27.dist-info → atomicshop-2.18.28.dist-info}/WHEEL +0 -0
- {atomicshop-2.18.27.dist-info → atomicshop-2.18.28.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
atomicshop/file_io/file_io.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import Union
|
|
2
2
|
import functools
|
|
3
|
+
import os
|
|
3
4
|
|
|
4
5
|
from .. import print_api
|
|
5
6
|
from .. import inspect_wrapper
|
|
@@ -23,7 +24,7 @@ def write_file_decorator(function_name):
|
|
|
23
24
|
print_api.print_api(message=f"Writing file: {kwargs['file_path']}", **kwargs)
|
|
24
25
|
|
|
25
26
|
enable_long_file_path = kwargs.get('enable_long_file_path', False)
|
|
26
|
-
if enable_long_file_path:
|
|
27
|
+
if enable_long_file_path and os.name == 'nt':
|
|
27
28
|
# A simpler string method would be to add '\\?\' to the beginning of the file path.
|
|
28
29
|
# kwargs['file_path'] = rf"\\?\{kwargs['file_path']}"
|
|
29
30
|
|
atomicshop/file_io/jsons.py
CHANGED
|
@@ -133,3 +133,52 @@ def is_dict_json_serializable(
|
|
|
133
133
|
raise e
|
|
134
134
|
else:
|
|
135
135
|
return False, str(e)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def append_to_json(
|
|
139
|
+
dict_or_list: Union[dict, list],
|
|
140
|
+
json_file_path: str,
|
|
141
|
+
indent=None,
|
|
142
|
+
use_default_indent=False,
|
|
143
|
+
enable_long_file_path=False,
|
|
144
|
+
print_kwargs: dict = None
|
|
145
|
+
) -> None:
|
|
146
|
+
"""
|
|
147
|
+
Append dictionary or list of dictionaries to json file.
|
|
148
|
+
|
|
149
|
+
:param dict_or_list: dictionary or list of dictionaries to append.
|
|
150
|
+
:param json_file_path: full file path to the json file.
|
|
151
|
+
:param indent: integer number of spaces for indentation.
|
|
152
|
+
If 'ident=0' new lines still will be created. The most compact is 'indent=None' (from documentation)
|
|
153
|
+
So, using default as 'None' and not something else.
|
|
154
|
+
:param use_default_indent: boolean. Default indent for 'json' format in many places is '2'. So, if you don't want
|
|
155
|
+
to set 'indent=2', just set this to 'True'.
|
|
156
|
+
:param enable_long_file_path: Boolean, by default Windows has a limit of 260 characters for file path. If True,
|
|
157
|
+
the long file path will be enabled, and the limit will be 32,767 characters.
|
|
158
|
+
:param print_kwargs: dict, the print_api arguments.
|
|
159
|
+
:return:
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
# Read existing data from the file
|
|
163
|
+
try:
|
|
164
|
+
with open(json_file_path, 'r') as f:
|
|
165
|
+
current_json_file = json.load(f)
|
|
166
|
+
except FileNotFoundError:
|
|
167
|
+
current_json_file: list = []
|
|
168
|
+
|
|
169
|
+
# Append the new message to the existing data
|
|
170
|
+
final_json_list_of_dicts: list[dict] = []
|
|
171
|
+
if isinstance(current_json_file, list):
|
|
172
|
+
current_json_file.append(dict_or_list)
|
|
173
|
+
final_json_list_of_dicts = current_json_file
|
|
174
|
+
elif isinstance(current_json_file, dict):
|
|
175
|
+
final_json_list_of_dicts.append(current_json_file)
|
|
176
|
+
final_json_list_of_dicts.append(dict_or_list)
|
|
177
|
+
else:
|
|
178
|
+
error_message = "The current file is neither a list nor a dictionary."
|
|
179
|
+
raise TypeError(error_message)
|
|
180
|
+
|
|
181
|
+
# Write the data back to the file
|
|
182
|
+
write_json_file(
|
|
183
|
+
final_json_list_of_dicts, json_file_path, indent=indent, use_default_indent=use_default_indent,
|
|
184
|
+
enable_long_file_path=enable_long_file_path, **print_kwargs)
|
|
@@ -113,30 +113,14 @@ def save_message_worker(
|
|
|
113
113
|
if record_message_dict is None:
|
|
114
114
|
break
|
|
115
115
|
|
|
116
|
-
# Read existing data from the file
|
|
117
116
|
try:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if isinstance(current_json_file, list):
|
|
126
|
-
current_json_file.append(record_message_dict)
|
|
127
|
-
final_json_list_of_dicts = current_json_file
|
|
128
|
-
elif isinstance(current_json_file, dict):
|
|
129
|
-
final_json_list_of_dicts.append(current_json_file)
|
|
130
|
-
final_json_list_of_dicts.append(record_message_dict)
|
|
131
|
-
else:
|
|
132
|
-
error_message = "The current file is neither a list nor a dictionary."
|
|
133
|
-
print_api(error_message, logger_method="critical", logger=logger)
|
|
134
|
-
raise TypeError(error_message)
|
|
135
|
-
|
|
136
|
-
# Write the data back to the file
|
|
137
|
-
jsons.write_json_file(
|
|
138
|
-
final_json_list_of_dicts, record_file_path, indent=2,
|
|
139
|
-
enable_long_file_path=True, **{'logger': logger})
|
|
117
|
+
jsons.append_to_json(
|
|
118
|
+
record_message_dict, record_file_path, indent=2,
|
|
119
|
+
enable_long_file_path=True, print_kwargs={'logger': logger}
|
|
120
|
+
)
|
|
121
|
+
except TypeError as e:
|
|
122
|
+
print_api(str(e), logger_method="critical", logger=logger)
|
|
123
|
+
raise e
|
|
140
124
|
|
|
141
125
|
logger.info(f"Recorded to file: {record_file_path}")
|
|
142
126
|
|
atomicshop/tempfiles.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=NPXYaerttT8nwfrwAuSuQRk-VuX8kIyXrNdJ0gpi-e4,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
|
|
@@ -39,7 +39,7 @@ atomicshop/ssh_remote.py,sha256=Mxixqs2-xGy1bhbcP0LKqjxKTNPz1Gmzz8PzO8aLB4c,1734
|
|
|
39
39
|
atomicshop/sys_functions.py,sha256=MTBxRve5bh58SPvhX3gMiGqHlSBuI_rdNN1NnnBBWqI,906
|
|
40
40
|
atomicshop/system_resource_monitor.py,sha256=yHdBU4mAVqoVS0Nn_SM_H42i4PgsgXDaXaMxfnL5CgA,14588
|
|
41
41
|
atomicshop/system_resources.py,sha256=iKUvVSaXR47inmr3cTYsgNfclT38dRia2oupnlhIpK4,9290
|
|
42
|
-
atomicshop/tempfiles.py,sha256=
|
|
42
|
+
atomicshop/tempfiles.py,sha256=cI8IlINHAcqomBtLOQIedYDE--1J5GcUsFuOQ6fDn_Y,2484
|
|
43
43
|
atomicshop/timer.py,sha256=7Zw1KRV0acHCRATMnanyX2MLBb63Hc-6us3rCZ9dNlY,2345
|
|
44
44
|
atomicshop/urls.py,sha256=aJ0NGS9qqaKeqjkkWBs80jaBBg6MYBiPuLIyPGxscVc,1557
|
|
45
45
|
atomicshop/uuids.py,sha256=JSQdm3ZTJiwPQ1gYe6kU0TKS_7suwVrHc8JZDGYlydM,2214
|
|
@@ -119,8 +119,8 @@ atomicshop/etws/traces/trace_sysmon_process_creation.py,sha256=OM-bkK38uYMwWLZKN
|
|
|
119
119
|
atomicshop/file_io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
120
120
|
atomicshop/file_io/csvs.py,sha256=zv0kKjRT-ZWRi0WpMIUQ_FKyP9Dt0f5Bc98Qsj6ClPU,9495
|
|
121
121
|
atomicshop/file_io/docxs.py,sha256=Nyt3hSpzwqUKZEP5p5efqNpjFs9XqkK40Kp7BbbPo7E,6245
|
|
122
|
-
atomicshop/file_io/file_io.py,sha256=
|
|
123
|
-
atomicshop/file_io/jsons.py,sha256=
|
|
122
|
+
atomicshop/file_io/file_io.py,sha256=8pKH08ILN91gfeNC0hrtLCx7l9ZgmcPAYIcLydDtZ-k,7198
|
|
123
|
+
atomicshop/file_io/jsons.py,sha256=GJyVlGTcdhjZ-andfz7_dYVk1O74f-23Mc9PDmdjtPI,7424
|
|
124
124
|
atomicshop/file_io/tomls.py,sha256=ol8EvQPf9sryTmZUf1v55BYSUQ6ml7HVVBHpNKbsIlA,9768
|
|
125
125
|
atomicshop/file_io/xlsxs.py,sha256=v_dyg9GD4LqgWi6wA1QuWRZ8zG4ZwB6Dz52ytdcmmmI,2184
|
|
126
126
|
atomicshop/file_io/xmls.py,sha256=zh3SuK-dNaFq2NDNhx6ivcf4GYCfGM8M10PcEwDSpxk,2104
|
|
@@ -140,7 +140,7 @@ atomicshop/mitm/engines/create_module_template.py,sha256=TAzsA4eLD2wYr7auuL4Nf_7
|
|
|
140
140
|
atomicshop/mitm/engines/create_module_template_example.py,sha256=X5xhvbV6-g9jU_bQVhf_crZmaH50LRWz3bS-faQ18ds,489
|
|
141
141
|
atomicshop/mitm/engines/__parent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
142
142
|
atomicshop/mitm/engines/__parent/parser___parent.py,sha256=HHaCXhScl3OlPjz6eUxsDpJaZyk6BNuDMc9xCkeo2Ws,661
|
|
143
|
-
atomicshop/mitm/engines/__parent/recorder___parent.py,sha256=
|
|
143
|
+
atomicshop/mitm/engines/__parent/recorder___parent.py,sha256=vG2h46CojK4jIinXmME2VwJFSWKygh4ayMwZyejwwI0,4846
|
|
144
144
|
atomicshop/mitm/engines/__parent/responder___parent.py,sha256=yEgR33CkAd1b9jyH5E8I4E16upqjlcK3WLo3BFHdjyk,9157
|
|
145
145
|
atomicshop/mitm/engines/__reference_general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
146
146
|
atomicshop/mitm/engines/__reference_general/parser___reference_general.py,sha256=57MEPZMAjTO6xBDZ-yt6lgGJyqRrP0Do5Gk_cgCiPns,2998
|
|
@@ -321,8 +321,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
|
|
|
321
321
|
atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
322
322
|
atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
|
|
323
323
|
atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
|
|
324
|
-
atomicshop-2.18.
|
|
325
|
-
atomicshop-2.18.
|
|
326
|
-
atomicshop-2.18.
|
|
327
|
-
atomicshop-2.18.
|
|
328
|
-
atomicshop-2.18.
|
|
324
|
+
atomicshop-2.18.28.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
325
|
+
atomicshop-2.18.28.dist-info/METADATA,sha256=SsZ4Ze8vESp5LjMbbM8_MghpZ9WhVYHs36BxPg63-CE,10631
|
|
326
|
+
atomicshop-2.18.28.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
327
|
+
atomicshop-2.18.28.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
328
|
+
atomicshop-2.18.28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|