atomicshop 2.12.15__py3-none-any.whl → 2.12.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 CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '2.12.15'
4
+ __version__ = '2.12.16'
@@ -7,6 +7,7 @@ from ...file_io import csvs
7
7
 
8
8
 
9
9
  READING_EXISTING_LINES: list = []
10
+ EXISTING_LOGS_FILE_COUNT: int = 0
10
11
 
11
12
 
12
13
  def get_logs_paths(
@@ -80,7 +81,8 @@ def get_logs_paths(
80
81
  current_file_name: str = Path(single_file['file_path']).name
81
82
  # Get the datetime object from the file name by the date pattern.
82
83
  try:
83
- datetime_object = datetimes.get_datetime_from_complex_string_by_pattern(current_file_name, date_pattern)
84
+ datetime_object = datetimes.get_datetime_from_complex_string_by_pattern(
85
+ current_file_name, date_pattern)
84
86
  timestamp_float = datetime_object.timestamp()
85
87
  # ValueError will be raised if the date pattern does not match the file name.
86
88
  except ValueError:
@@ -249,6 +251,31 @@ def get_latest_lines(
249
251
  time.sleep(1)
250
252
  """
251
253
 
254
+ def extract_new_lines_only(content_lines: list):
255
+ new_lines: list = []
256
+ for row in content_lines:
257
+ # If the row is not in the existing lines, then add it to the new lines.
258
+ if row not in READING_EXISTING_LINES:
259
+ new_lines.append(row)
260
+
261
+ if new_lines:
262
+ READING_EXISTING_LINES.extend(new_lines)
263
+
264
+ return new_lines
265
+
266
+ global EXISTING_LOGS_FILE_COUNT
267
+
268
+ # If the existing logs file count is 0, it means that this is the first check. We need to get the current count.
269
+ if EXISTING_LOGS_FILE_COUNT == 0:
270
+ EXISTING_LOGS_FILE_COUNT = len(get_logs_paths(
271
+ log_file_path=log_file_path,
272
+ log_type='csv'
273
+ ))
274
+
275
+ # If the count is still 0, then there are no logs to read.
276
+ if EXISTING_LOGS_FILE_COUNT == 0:
277
+ return [], [], header
278
+
252
279
  if log_type != 'csv':
253
280
  raise ValueError('Only "csv" log type is supported.')
254
281
 
@@ -262,9 +289,6 @@ def get_latest_lines(
262
289
  latest_only=True
263
290
  )
264
291
 
265
- if not latest_statistics_file_path_object:
266
- return [], [], [], []
267
-
268
292
  latest_statistics_file_path: str = latest_statistics_file_path_object[0]['file_path']
269
293
 
270
294
  # Get the previous day statistics file path.
@@ -279,33 +303,36 @@ def get_latest_lines(
279
303
  except KeyError:
280
304
  pass
281
305
 
282
- current_lines, header = csvs.read_csv_to_list_of_dicts_by_header(
283
- latest_statistics_file_path, header=header, stdout=False)
284
- if len(current_lines) > len(READING_EXISTING_LINES):
285
- # return current_lines
286
- pass
287
- elif len(current_lines) == len(READING_EXISTING_LINES):
288
- # return None
289
- pass
290
- elif len(current_lines) < len(READING_EXISTING_LINES):
306
+ # Count all the rotated files.
307
+ current_log_files_count: int = len(get_logs_paths(
308
+ log_file_path=log_file_path,
309
+ log_type='csv'
310
+ ))
311
+
312
+ # If the count of the log files is greater than the existing logs file count, it means that the rotation happened.
313
+ # We will read the previous day statistics file.
314
+ new_lines_from_previous_file: list = []
315
+ if current_log_files_count > EXISTING_LOGS_FILE_COUNT:
291
316
  current_lines, header = csvs.read_csv_to_list_of_dicts_by_header(
292
317
  previous_day_statistics_file_path, header=header, stdout=False)
293
- # Handle case where source CSV is empty (rotation period)
294
- READING_EXISTING_LINES.clear() # Clear existing lines to start fresh after rotation
295
318
 
296
319
  if get_previous_file:
297
320
  previous_file_lines = current_lines
298
321
 
299
- # return current_lines
322
+ EXISTING_LOGS_FILE_COUNT = current_log_files_count
300
323
 
301
- new_lines: list = []
302
- if current_lines:
303
- for row in current_lines:
304
- # If the row is not in the existing lines, then add it to the new lines.
305
- if row not in READING_EXISTING_LINES:
306
- new_lines.append(row)
324
+ new_lines_from_previous_file = extract_new_lines_only(current_lines)
307
325
 
308
- if new_lines:
309
- READING_EXISTING_LINES.extend(new_lines)
326
+ # empty the previous file lines, since the file is rotated.
327
+ READING_EXISTING_LINES.clear()
328
+
329
+ current_lines, header = csvs.read_csv_to_list_of_dicts_by_header(
330
+ latest_statistics_file_path, header=header, stdout=False)
331
+
332
+ new_lines = extract_new_lines_only(current_lines)
333
+
334
+ # If we have new lines from the previous file, we will add the new lines from the latest file.
335
+ if new_lines_from_previous_file:
336
+ new_lines = new_lines_from_previous_file + new_lines
310
337
 
311
- return new_lines, current_lines, READING_EXISTING_LINES, previous_file_lines, header
338
+ return new_lines, previous_file_lines, header
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.12.15
3
+ Version: 2.12.16
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=irfB8lK9cOngD6YC1kQbNIWYjaADA5biLnI9LD1TntY,124
1
+ atomicshop/__init__.py,sha256=Z-gJW-h7oTdZn_6KXbNYPQPfdC6kDWJvf5xxT1uoArA,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
@@ -216,7 +216,7 @@ atomicshop/wrappers/loggingw/formatters.py,sha256=mUtcJJfmhLNrwUVYShXTmdu40dBaJu
216
216
  atomicshop/wrappers/loggingw/handlers.py,sha256=qm5Fbu8eDmlstMduUe5nKUlJU5IazFkSnQizz8Qt2os,5479
217
217
  atomicshop/wrappers/loggingw/loggers.py,sha256=DHOOTAtqkwn1xgvLHSkOiBm6yFGNuQy1kvbhG-TDog8,2374
218
218
  atomicshop/wrappers/loggingw/loggingw.py,sha256=v9WAseZXB50LluT9rIUcRvvevg2nLVKPgz3dbGejfV0,12151
219
- atomicshop/wrappers/loggingw/reading.py,sha256=k5XAnklLs97HQYkmF72-RzfNgBGsIx6mgogLugBpd7c,13992
219
+ atomicshop/wrappers/loggingw/reading.py,sha256=CtYOwOLFHj_hqYyZx-dKUo5ZDrn3cO-f7vU4EX515xI,14980
220
220
  atomicshop/wrappers/nodejsw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
221
221
  atomicshop/wrappers/nodejsw/install_nodejs.py,sha256=QZg-R2iTQt7kFb8wNtnTmwraSGwvUs34JIasdbNa7ZU,5154
222
222
  atomicshop/wrappers/playwrightw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -251,8 +251,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
251
251
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
252
252
  atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
253
253
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
254
- atomicshop-2.12.15.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
255
- atomicshop-2.12.15.dist-info/METADATA,sha256=LvzJt1ZpIyBFDgSjWVcopOaMbDsSgRJTYMKuohIXP0o,10479
256
- atomicshop-2.12.15.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
257
- atomicshop-2.12.15.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
258
- atomicshop-2.12.15.dist-info/RECORD,,
254
+ atomicshop-2.12.16.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
255
+ atomicshop-2.12.16.dist-info/METADATA,sha256=Sxe0EOSeHGX8jfjldfji7N3m_tORqIzRpxLiy7npPCY,10479
256
+ atomicshop-2.12.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
257
+ atomicshop-2.12.16.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
258
+ atomicshop-2.12.16.dist-info/RECORD,,