atomicshop 2.16.16__py3-none-any.whl → 2.16.17__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.16.16'
4
+ __version__ = '2.16.17'
@@ -5,7 +5,7 @@ from typing import Literal
5
5
  from ...print_api import print_api
6
6
  from ...wrappers.loggingw import reading, consts
7
7
  from ...file_io import csvs
8
- from ... import urls
8
+ from ... import urls, filesystem
9
9
 
10
10
 
11
11
  def calculate_moving_average(
@@ -43,7 +43,7 @@ def calculate_moving_average(
43
43
  date_format: str = consts.DEFAULT_ROTATING_SUFFIXES_FROM_WHEN['midnight']
44
44
 
45
45
  # Get all the file paths and their midnight rotations.
46
- logs_paths: list = reading.get_logs_paths(
46
+ logs_paths: list[filesystem.AtomicPath] = reading.get_logs_paths(
47
47
  log_file_path=file_path,
48
48
  date_format=date_format
49
49
  )
@@ -54,14 +54,14 @@ def calculate_moving_average(
54
54
 
55
55
  statistics_content: dict = {}
56
56
  # Read each file to its day.
57
- for log_path_dict in logs_paths:
58
- date_string = log_path_dict['date_string']
57
+ for log_atomic_path in logs_paths:
58
+ date_string = log_atomic_path.datetime_string
59
59
  statistics_content[date_string] = {}
60
60
 
61
- statistics_content[date_string]['file'] = log_path_dict
61
+ statistics_content[date_string]['file'] = log_atomic_path
62
62
 
63
63
  log_file_content, log_file_header = (
64
- csvs.read_csv_to_list_of_dicts_by_header(log_path_dict['file_path'], **(print_kwargs or {})))
64
+ csvs.read_csv_to_list_of_dicts_by_header(log_atomic_path.path, **(print_kwargs or {})))
65
65
  statistics_content[date_string]['content'] = log_file_content
66
66
  statistics_content[date_string]['header'] = log_file_header
67
67
 
@@ -14,6 +14,17 @@ import logging
14
14
  """
15
15
 
16
16
 
17
+ def is_logger_exists(
18
+ logger_name: str
19
+ ) -> bool:
20
+ """
21
+ Function to check if the logger exists.
22
+ :param logger_name: str, Name of the logger.
23
+ :return: bool, True if the logger exists, False otherwise.
24
+ """
25
+ return logger_name in logging.Logger.manager.loggerDict
26
+
27
+
17
28
  def get_logger(logger_name: str) -> logging.Logger:
18
29
  """
19
30
  Function to get a logger.
@@ -8,6 +8,7 @@ from . import loggers, handlers
8
8
  # noinspection PyPep8Naming
9
9
  def create_logger(
10
10
  logger_name: str,
11
+ get_existing_if_exists: bool = True,
11
12
  file_path: str = None,
12
13
  directory_path: str = None,
13
14
  add_stream: bool = False,
@@ -42,6 +43,8 @@ def create_logger(
42
43
  Function to get a logger and add StreamHandler and TimedRotatingFileHandler to it.
43
44
 
44
45
  :param logger_name: Name of the logger.
46
+ :param get_existing_if_exists: bool, If set to True, the logger will be returned if it already exists.
47
+ If set to False, the new stream/file handler will be added to existing logger again.
45
48
  :param file_path: full path to the log file. If you don't want to use the file, set it to None.
46
49
  You can set the directory_path only and then the 'logger_name' will be used as the file name with the
47
50
  'file_type' as the file extension.
@@ -173,8 +176,15 @@ def create_logger(
173
176
 
174
177
  file_path = f"{directory_path}{os.sep}{logger_name}.{file_type}"
175
178
 
179
+ # Check if the logger exists before creating it/getting the existing.
180
+ is_logger_exists = loggers.is_logger_exists(logger_name)
181
+
176
182
  logger = get_logger_with_level(logger_name, logging_level)
177
183
 
184
+ # If the logger already exists, and we don't want to add the handlers again, return the logger.
185
+ if get_existing_if_exists and is_logger_exists:
186
+ return logger
187
+
178
188
  if add_stream:
179
189
  handlers.add_stream_handler(
180
190
  logger=logger, logging_level=logging_level, formatter=formatter_streamhandler,
@@ -14,7 +14,7 @@ def get_logs_paths(
14
14
  latest_only: bool = False,
15
15
  previous_day_only: bool = False,
16
16
  specific_date: str = None
17
- ):
17
+ ) -> list[filesystem.AtomicPath]:
18
18
  """
19
19
  This function gets the logs file paths from the directory. Supports rotating files to get the logs by time.
20
20
 
@@ -61,7 +61,7 @@ def get_logs_paths(
61
61
  log_files_directory_path: str = str(Path(log_file_path).parent)
62
62
 
63
63
  # Get all the log file paths by the file_name_pattern and the date_format string.
64
- logs_files: list = filesystem.get_paths_from_directory(
64
+ logs_files: list[filesystem.AtomicPath] = filesystem.get_paths_from_directory(
65
65
  log_files_directory_path,
66
66
  get_file=True,
67
67
  file_name_check_pattern=file_name_pattern,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.16.16
3
+ Version: 2.16.17
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=43IIwVKubkBxqcW9co_kEzLRQCXqxLEBrGIx94aWzjg,124
1
+ atomicshop/__init__.py,sha256=8j7ZCpRQjA2znKZa29KoZQlCV-GjDBzWXCHWB8Kft3c,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
@@ -145,7 +145,7 @@ atomicshop/mitm/engines/__reference_general/recorder___reference_general.py,sha2
145
145
  atomicshop/mitm/engines/__reference_general/responder___reference_general.py,sha256=1AM49UaFTKA0AHw-k3SV3uH3QbG-o6ux0c-GoWkKNU0,6993
146
146
  atomicshop/mitm/statistic_analyzer_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
147
147
  atomicshop/mitm/statistic_analyzer_helper/analyzer_helper.py,sha256=pk6L1t1ea1kvlBoR9QEJptOmaX-mumhwLsP2GCKukbk,5920
148
- atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py,sha256=lsG_eSWf6M_3AfWqIYEBNwYAyVHJfBiRVKHhmWIOZ9A,16615
148
+ atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py,sha256=Wge-OfbbClfjeEWwOyksd-x9C5QZdRD3KRSjtP9VL9Q,16651
149
149
  atomicshop/monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
150
  atomicshop/monitor/change_monitor.py,sha256=K5NlVp99XIDDPnQQMdru4BDmua_DtcDIhVAzkTOvD5s,7673
151
151
  atomicshop/monitor/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -248,9 +248,9 @@ atomicshop/wrappers/loggingw/consts.py,sha256=JWiUJEydjhwatBxtIJsGTmDUSTLbmIRidt
248
248
  atomicshop/wrappers/loggingw/filters.py,sha256=CMs5PAMb68zxJgBcQobaOFDG5kLJBOVYnoBHjDgksO8,2859
249
249
  atomicshop/wrappers/loggingw/formatters.py,sha256=7XUJvlB0CK4DCkEp8NTL0S0dkyrZD0UTADgEwkStKOY,5483
250
250
  atomicshop/wrappers/loggingw/handlers.py,sha256=hAPFJQ-wFoNO8QzGrJRSvyuP09Q1F0Dl9_w7zzlgcW0,18155
251
- atomicshop/wrappers/loggingw/loggers.py,sha256=DHOOTAtqkwn1xgvLHSkOiBm6yFGNuQy1kvbhG-TDog8,2374
252
- atomicshop/wrappers/loggingw/loggingw.py,sha256=_VT5aqYgUVI6uurrnfm0_tAYO41Aavs1SSnlU6gfOiQ,11808
253
- atomicshop/wrappers/loggingw/reading.py,sha256=tplnJlQ7RMxWv2s782tWGOo1C7WNemk2SRTZCCgD9J0,16474
251
+ atomicshop/wrappers/loggingw/loggers.py,sha256=QH5QainlGLyrDpsDu4T1C8-WQQau3JW2OS5RgC-kXpM,2677
252
+ atomicshop/wrappers/loggingw/loggingw.py,sha256=6HUn2z4ZW8PgakPscosKx23qYwHlBQcLiZGw-VZHi-k,12374
253
+ atomicshop/wrappers/loggingw/reading.py,sha256=SZFE4d6IFoC1GveFf28oAuDQzHG8UnBHx3K3-dE5Mes,16528
254
254
  atomicshop/wrappers/mongodbw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
255
255
  atomicshop/wrappers/mongodbw/install_mongodb.py,sha256=3ZPqrXxj3lC-PnAKGXclylLuOqsbyXYeUpb5iGjdeUU,6626
256
256
  atomicshop/wrappers/mongodbw/mongo_infra.py,sha256=JO63ShbHYRBmUdFv-GeJxkPQdhRhq59ly6bxnn64fUM,1713
@@ -309,8 +309,8 @@ atomicshop/wrappers/socketw/ssl_base.py,sha256=kmiif84kMhBr5yjQW17p935sfjR5JKG0L
309
309
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=V_m1D0KpizQox3IEWp2AUcncwWy5kG25hbFrc-mBSJE,3029
310
310
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
311
311
  atomicshop/wrappers/winregw/winreg_network.py,sha256=bQ8Jql8bVGBJ0dt3VQ56lga_1LBOMLI3Km_otvvbU6c,7138
312
- atomicshop-2.16.16.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
313
- atomicshop-2.16.16.dist-info/METADATA,sha256=JpxLeyrTWZ_qfqn0SMMQtTi9nPcAOj3YLYkPeh-YAJw,10473
314
- atomicshop-2.16.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
315
- atomicshop-2.16.16.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
316
- atomicshop-2.16.16.dist-info/RECORD,,
312
+ atomicshop-2.16.17.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
313
+ atomicshop-2.16.17.dist-info/METADATA,sha256=hh2ElTNYbFQfLq_0PnD9wptNCmnlx06CLdEMgs-DWDo,10473
314
+ atomicshop-2.16.17.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
315
+ atomicshop-2.16.17.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
316
+ atomicshop-2.16.17.dist-info/RECORD,,