atomicshop 2.15.3__py3-none-any.whl → 2.15.5__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/csvs.py +101 -2
- atomicshop/mitm/statistic_analyzer.py +1 -1
- atomicshop/wrappers/factw/postgresql/firmware.py +1 -1
- atomicshop/wrappers/factw/rest/firmware.py +1 -1
- {atomicshop-2.15.3.dist-info → atomicshop-2.15.5.dist-info}/METADATA +1 -1
- {atomicshop-2.15.3.dist-info → atomicshop-2.15.5.dist-info}/RECORD +10 -10
- {atomicshop-2.15.3.dist-info → atomicshop-2.15.5.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.15.3.dist-info → atomicshop-2.15.5.dist-info}/WHEEL +0 -0
- {atomicshop-2.15.3.dist-info → atomicshop-2.15.5.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
atomicshop/file_io/csvs.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import csv
|
|
2
|
+
import io
|
|
2
3
|
from typing import Tuple, List
|
|
3
4
|
|
|
4
5
|
from .file_io import read_file_decorator
|
|
@@ -100,8 +101,8 @@ def read_csv_to_list_of_lists(
|
|
|
100
101
|
|
|
101
102
|
|
|
102
103
|
def write_list_to_csv(
|
|
103
|
-
file_path: str,
|
|
104
104
|
content_list: list,
|
|
105
|
+
file_path: str,
|
|
105
106
|
mode: str = 'w'
|
|
106
107
|
) -> None:
|
|
107
108
|
"""
|
|
@@ -111,8 +112,8 @@ def write_list_to_csv(
|
|
|
111
112
|
The dictionary inside the function will be identified by the first iteration of the list.
|
|
112
113
|
Other objects (inside the provided list) than dictionary will be identified as regular objects.
|
|
113
114
|
|
|
114
|
-
:param file_path: Full file path to CSV file.
|
|
115
115
|
:param content_list: List object that each iteration contains dictionary with same keys and different values.
|
|
116
|
+
:param file_path: Full file path to CSV file.
|
|
116
117
|
:param mode: String, file writing mode. Default is 'w'.
|
|
117
118
|
:return: None.
|
|
118
119
|
"""
|
|
@@ -155,3 +156,101 @@ def get_header(file_path: str, print_kwargs: dict = None) -> list:
|
|
|
155
156
|
# Split the header to list of keys.
|
|
156
157
|
header = header.split(',')
|
|
157
158
|
return header
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _escape_csv_value_ref(text):
|
|
162
|
+
"""
|
|
163
|
+
FOR REFERENCE ONLY, better use csv module to do it natively.
|
|
164
|
+
Function to escape text for CSV file.
|
|
165
|
+
This function escapes commas (,) and double quotes (") for csv cell (between commas).
|
|
166
|
+
|
|
167
|
+
Example:
|
|
168
|
+
test1 = 'test1'
|
|
169
|
+
test2 = 'test,2'
|
|
170
|
+
test3 = 'test3,"3",3'
|
|
171
|
+
|
|
172
|
+
csv_line = f'{escape_csv_value(test1)},{escape_csv_value(test2)},{escape_csv_value(test3)}'
|
|
173
|
+
|
|
174
|
+
Output: 'test1,"test,2","test3,""3"",3"'
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
if '"' in text:
|
|
178
|
+
text = text.replace('"', '""') # Escape double quotes
|
|
179
|
+
if ',' in text or '"' in text:
|
|
180
|
+
text = f'"{text}"' # Enclose in double quotes if there are commas or double quotes
|
|
181
|
+
return text
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def escape_csv_value(value):
|
|
185
|
+
"""
|
|
186
|
+
Function to escape text for CSV file.
|
|
187
|
+
This function escapes commas (,) and double quotes (") for csv cell (between commas).
|
|
188
|
+
|
|
189
|
+
Example:
|
|
190
|
+
test1 = 'test1'
|
|
191
|
+
test2 = 'test,2'
|
|
192
|
+
test3 = 'test3,"3",3'
|
|
193
|
+
|
|
194
|
+
csv_line = f'{escape_csv_value(test1)},{escape_csv_value(test2)},{escape_csv_value(test3)}'
|
|
195
|
+
|
|
196
|
+
Output: 'test1,"test,2","test3,""3"",3"'
|
|
197
|
+
"""
|
|
198
|
+
output = io.StringIO()
|
|
199
|
+
writer = csv.writer(output, quoting=csv.QUOTE_MINIMAL)
|
|
200
|
+
writer.writerow([value])
|
|
201
|
+
return output.getvalue().strip()
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def escape_csv_line_to_string(csv_line: list) -> str:
|
|
205
|
+
"""
|
|
206
|
+
Function to escape list of strings for CSV file.
|
|
207
|
+
This function escapes commas (,) and double quotes (") for csv cell (between commas).
|
|
208
|
+
|
|
209
|
+
Example:
|
|
210
|
+
test1 = 'test1'
|
|
211
|
+
test2 = 'test,2'
|
|
212
|
+
test3 = 'test3,"3",3'
|
|
213
|
+
|
|
214
|
+
csv_line = escape_csv_line_to_string([test1, test2, test3])
|
|
215
|
+
|
|
216
|
+
Output:
|
|
217
|
+
csv_line == 'test1,"test,2","test3,""3"",3"'
|
|
218
|
+
"""
|
|
219
|
+
|
|
220
|
+
# Prepare the data as a list of lists
|
|
221
|
+
data = [csv_line]
|
|
222
|
+
|
|
223
|
+
# Use StringIO to create an in-memory file-like object
|
|
224
|
+
output = io.StringIO()
|
|
225
|
+
writer = csv.writer(output, quoting=csv.QUOTE_MINIMAL)
|
|
226
|
+
|
|
227
|
+
# Write the data to the CSV writer
|
|
228
|
+
writer.writerows(data)
|
|
229
|
+
|
|
230
|
+
# Get the CSV string from the StringIO object, Strip to remove any trailing newlines.
|
|
231
|
+
csv_line = output.getvalue().strip()
|
|
232
|
+
|
|
233
|
+
return csv_line
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def escape_csv_line_to_list(csv_line: list) -> list:
|
|
237
|
+
"""
|
|
238
|
+
Function to escape list of strings for CSV file.
|
|
239
|
+
This function escapes commas (,) and double quotes (") for csv cell (between commas).
|
|
240
|
+
|
|
241
|
+
Example:
|
|
242
|
+
test1 = 'test1'
|
|
243
|
+
test2 = 'test,2'
|
|
244
|
+
test3 = 'test3,"3",3'
|
|
245
|
+
|
|
246
|
+
csv_entries_list = escape_csv_line_to_list([test1, test2, test3])
|
|
247
|
+
|
|
248
|
+
Output:
|
|
249
|
+
csv_entries_list == ['test1', '"test,2"', '"test3,""3"",3"']
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
result_csv_entries: list = []
|
|
253
|
+
for entry in csv_line:
|
|
254
|
+
result_csv_entries.append(escape_csv_value(entry))
|
|
255
|
+
|
|
256
|
+
return result_csv_entries
|
|
@@ -450,7 +450,7 @@ def deviation_calculator_by_moving_average_main(
|
|
|
450
450
|
print_api(f'Deviation Found, saving to file: {output_file_path}', color='blue')
|
|
451
451
|
|
|
452
452
|
if output_file_type == 'csv':
|
|
453
|
-
csvs.write_list_to_csv(
|
|
453
|
+
csvs.write_list_to_csv(deviation_list, output_file_path)
|
|
454
454
|
elif output_file_type == 'json':
|
|
455
455
|
jsons.write_json_file(deviation_list, output_file_path, use_default_indent=True)
|
|
456
456
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=wv9rbZlxTZ5q_oeV6eNTIAmbZBcHrjaJyAJaNjKcU78,123
|
|
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
|
|
@@ -113,7 +113,7 @@ atomicshop/etws/traces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
|
113
113
|
atomicshop/etws/traces/trace_dns.py,sha256=WvOZm7KNdP4r6ofkZhUGi9WjtYlkV3mUp_yxita3Qg4,6399
|
|
114
114
|
atomicshop/etws/traces/trace_sysmon_process_creation.py,sha256=OM-bkK38uYMwWLZKNOTDa0Xdk3sO6sqsxoMUIiPvm5g,4656
|
|
115
115
|
atomicshop/file_io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
116
|
-
atomicshop/file_io/csvs.py,sha256=
|
|
116
|
+
atomicshop/file_io/csvs.py,sha256=oZiaIEd1q50ypNdd9mlHWb-f7HAdGa_D6jLd3T_4sWU,8777
|
|
117
117
|
atomicshop/file_io/docxs.py,sha256=yNlNXKLIvPkHQNF544VvCrbxcXsHX6G-6_V-8Ixp2zI,5111
|
|
118
118
|
atomicshop/file_io/file_io.py,sha256=FOZ6_PjOASxSDHESe4fwDv5miXYR10OHTxkxtEHoZYQ,6555
|
|
119
119
|
atomicshop/file_io/jsons.py,sha256=q9ZU8slBKnHLrtn3TnbK1qxrRpj5ZvCm6AlsFzoANjo,5303
|
|
@@ -128,7 +128,7 @@ atomicshop/mitm/initialize_engines.py,sha256=YnXPK1UKrmULnfL4zLo2LOpKWq-aGKzc9p3
|
|
|
128
128
|
atomicshop/mitm/initialize_mitm_server.py,sha256=j1yMUbHsnFh9l5rFiUgBQA0mRZqREOKviP0frRzYikM,14611
|
|
129
129
|
atomicshop/mitm/message.py,sha256=u2U2f2SOHdBNU-6r1Ik2W14ai2EOwxUV4wVfGZA098k,1732
|
|
130
130
|
atomicshop/mitm/shared_functions.py,sha256=PaK_sbnEA5zo9k2ktEOKLmvo-6wRUunxzSNRr41uXIQ,1924
|
|
131
|
-
atomicshop/mitm/statistic_analyzer.py,sha256=
|
|
131
|
+
atomicshop/mitm/statistic_analyzer.py,sha256=4uCpibb5tLhHv2Sv4jqL8kCldjdRgI5W10Ia9D_LwMk,23750
|
|
132
132
|
atomicshop/mitm/engines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
133
133
|
atomicshop/mitm/engines/create_module_template.py,sha256=tRjVSm1sD6FzML71Qbuwvita0qsusdFGm8NZLsZ-XMs,4853
|
|
134
134
|
atomicshop/mitm/engines/create_module_template_example.py,sha256=X5xhvbV6-g9jU_bQVhf_crZmaH50LRWz3bS-faQ18ds,489
|
|
@@ -225,14 +225,14 @@ atomicshop/wrappers/factw/install/pre_install_and_install_before_restart.py,sha2
|
|
|
225
225
|
atomicshop/wrappers/factw/postgresql/__init__.py,sha256=xMBn2d3Exo23IPP2F_9-SXmOlhFbwWDgS9KwozSTjA0,162
|
|
226
226
|
atomicshop/wrappers/factw/postgresql/analysis.py,sha256=2Rxzy2jyq3zEKIo53z8VkjuslKE_i5mq2ZpmJAvyd6U,716
|
|
227
227
|
atomicshop/wrappers/factw/postgresql/file_object.py,sha256=VRiCXnsd6yDbnsE-TEKYPC-gkAgFVkE6rygRrJLQShI,713
|
|
228
|
-
atomicshop/wrappers/factw/postgresql/firmware.py,sha256=
|
|
228
|
+
atomicshop/wrappers/factw/postgresql/firmware.py,sha256=HAOS3ynFrIJ2nkzFj39Cn9HDb7apCIouvz3BAzF0q24,10668
|
|
229
229
|
atomicshop/wrappers/factw/postgresql/fw_files.py,sha256=P1jq4AAZa7fygWdEZtFJOnfz4tyqmPpvFzEMDKrCRkU,1291
|
|
230
230
|
atomicshop/wrappers/factw/postgresql/included_files.py,sha256=sn5YhLkrsvjhrVSA8O8YUNfbqR9STprSuQGEnHsK0jE,1025
|
|
231
231
|
atomicshop/wrappers/factw/postgresql/virtual_file_path.py,sha256=iR68A_My_ohgRcYdueMaQF9EHOgBRN3bIi8Nq59g3kc,1098
|
|
232
232
|
atomicshop/wrappers/factw/rest/__init__.py,sha256=MuzZDJ38myxmwLhNhHIsDk0DXkcNbsB_t4R4SSYl--Y,150
|
|
233
233
|
atomicshop/wrappers/factw/rest/binary_search.py,sha256=AXMFTma3awymrSlE8T1MSV8Q-PCqk586WBDlBr4TbR4,826
|
|
234
234
|
atomicshop/wrappers/factw/rest/file_object.py,sha256=E_CA9lYpUqpxPDJ8c9dAqQAkJq8NafTecKa3q3EKr40,3218
|
|
235
|
-
atomicshop/wrappers/factw/rest/firmware.py,sha256=
|
|
235
|
+
atomicshop/wrappers/factw/rest/firmware.py,sha256=FezneouU1lUO9uZ6_8ZQNxr4MDlFIoTbBgjIZiNo3_k,20387
|
|
236
236
|
atomicshop/wrappers/factw/rest/router.py,sha256=fdGok5ESBxcZHIBgM93l4yTPRGoeooQNsrPWIETieGk,710
|
|
237
237
|
atomicshop/wrappers/factw/rest/statistics.py,sha256=vznwzKP1gEF7uXz3HsuV66BU9wrp73N_eFqpFpye9Qw,653
|
|
238
238
|
atomicshop/wrappers/factw/rest/status.py,sha256=4O3xS1poafwyUiLDkhyx4oMMe4PBwABuRPpOMnMKgIU,641
|
|
@@ -294,8 +294,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
|
|
|
294
294
|
atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
|
|
295
295
|
atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
|
|
296
296
|
atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
|
|
297
|
-
atomicshop-2.15.
|
|
298
|
-
atomicshop-2.15.
|
|
299
|
-
atomicshop-2.15.
|
|
300
|
-
atomicshop-2.15.
|
|
301
|
-
atomicshop-2.15.
|
|
297
|
+
atomicshop-2.15.5.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
298
|
+
atomicshop-2.15.5.dist-info/METADATA,sha256=4AbSJ0FMia7X1hepHPSyzyT8uzUPfZd96LkVe1br2Y4,10502
|
|
299
|
+
atomicshop-2.15.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
300
|
+
atomicshop-2.15.5.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
301
|
+
atomicshop-2.15.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|