ParUtils 1.2.0__py3-none-any.whl → 1.2.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: ParUtils
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: This package contains a bunch of Python utils developed for Support, Test and Automation IT Engineers
5
5
  Home-page: https://github.com/paularnaud2/ParUtils
6
6
  Author: Paul ARNAUD
@@ -1,5 +1,5 @@
1
1
  parutils/__init__.py,sha256=EaFtUmU0kYgnjvAFwPmoKt7I5zn9bxY02R7TUtcE6M4,1434
2
- parutils/changelog.py,sha256=TzbgcMIo79cZeYx_i8uOMLhPsZaagge78lZt6KmeQ3Q,1406
2
+ parutils/changelog.py,sha256=FRy4UkSbAPMgv4bnES4tYjs8_j-u8pl9Kq26keg0ygs,1591
3
3
  parutils/csvl.py,sha256=UBqw0lyhTNqFLSNIE-JM7TAQYCRgHftYQmHi21ru8-A,2874
4
4
  parutils/dq.py,sha256=kdvzOo5FLCumXagY05kGSseYlbR-zvjjmsMtGVliVc8,2302
5
5
  parutils/file.py,sha256=-OPfMhTjHDqubZLWJquY-FOv3W_k9GWoMq_rNgtdU9Y,2881
@@ -9,15 +9,15 @@ parutils/strg.py,sha256=_8NQJ1iY58Z_xACTDVcyonvRHDRuy9Ai3Kv3CvVXRh4,5563
9
9
  parutils/testing.py,sha256=kXrMz8Kze4mZejaePmV_OIca4iuNcG_dhGVHCgVuF-k,610
10
10
  parutils/wrap.py,sha256=PqMyKodgEjWDXoIVZZXRaBSdkGFL5OWmVJttl2Crrg8,421
11
11
  parutils/logging/__init__.py,sha256=rSNpgjuYer-Hhn6zKzKwKSn_KfcajEXlk6cJnPC9eJU,461
12
- parutils/logging/cl.py,sha256=L40SkNdrdAT-7hfXAcFPHdB73PVqAhKVlMGC7Awtx1w,2079
12
+ parutils/logging/cl.py,sha256=NCLuxLHvqRTypZlAgwnegkByLTnTirKntnwguJHBelA,2086
13
13
  parutils/logging/const.py,sha256=L2OppBDAZYKUTIjsLPt6hTUh8UWH_1mX9YaGWlwzpj4,135
14
14
  parutils/logging/core.py,sha256=vBwZnpM2GRNSSABPdzEM9SRpqr_YNqdPlG3T3lNPSiY,843
15
15
  parutils/logging/g.py,sha256=ZSrgZw63kwxIW66A7-9_iYeDt4AstNZ_XXQgK8MglyQ,47
16
- parutils/logging/logger.py,sha256=TOEj65xZjKZm9toAG2NDSbby_gUVtCV33VH0jFNMWTY,3764
17
- parutils/logging/main.py,sha256=Z-ooY43PUk36nwVB_D9c9ZF7HUGngrFyVS8yBUVsTXA,1908
16
+ parutils/logging/logger.py,sha256=Blt-loNbEyVo83E4viX1kDeY__6_bbwzWlIyDNPFLHU,4689
17
+ parutils/logging/main.py,sha256=arUvgB0YTZpidt4wl2GZsR4bRUj_rrSYMrTnCMKt4gA,2127
18
18
  parutils/logging/sl.py,sha256=3-sj_o33cZmOqeFxlTl5HyHOvSAhn9glYcc-BmTUpZc,1164
19
- ParUtils-1.2.0.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
20
- ParUtils-1.2.0.dist-info/METADATA,sha256=8xvOeEu0qBMQtzMAm-KzAF54FJzNuYoMbL7w40r1dIg,5285
21
- ParUtils-1.2.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
22
- ParUtils-1.2.0.dist-info/top_level.txt,sha256=1MDobUcroeYEvdupZCAFvA5hJjm7LSDUV5A4jHySNis,9
23
- ParUtils-1.2.0.dist-info/RECORD,,
19
+ ParUtils-1.2.2.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
20
+ ParUtils-1.2.2.dist-info/METADATA,sha256=s80O3PPMMmB_xSHMq4hhmYnPqqwYylAqrzbcCZLpnUs,5285
21
+ ParUtils-1.2.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
22
+ ParUtils-1.2.2.dist-info/top_level.txt,sha256=1MDobUcroeYEvdupZCAFvA5hJjm7LSDUV5A4jHySNis,9
23
+ ParUtils-1.2.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
parutils/changelog.py CHANGED
@@ -1,5 +1,12 @@
1
- __VERSION__ = '1.2.0'
2
- # logging - error handling
1
+ __VERSION__ = '1.2.2'
2
+ # log_every
3
+
4
+ # __VERSION__ = '1.2.1'
5
+ # # log_dict + log_array - only one log_print -> better perfs
6
+ # # Improved check_log logs - name appears when nok
7
+
8
+ # __VERSION__ = '1.2.0'
9
+ # # logging - error handling
3
10
 
4
11
  # __VERSION__ = '1.1.9'
5
12
  # # check_log - name appears when check_log ok
parutils/logging/cl.py CHANGED
@@ -65,8 +65,8 @@ def check_warn(n_w, max_warn, name):
65
65
  if n_w == 0:
66
66
  log(f'check_log{s} ok')
67
67
  elif n_w <= max_warn:
68
- log(f'check_log ended with {n_w} warnings')
68
+ log(f'check_log{s} ended with {n_w} warnings')
69
69
  else:
70
- s = f'check_log ko, too many warnings ({n_w} warnings)'
70
+ s = f'check_log{s} nok, too many warnings ({n_w} warnings)'
71
71
  log(s)
72
72
  raise Exception(s)
@@ -21,6 +21,7 @@ class Logger:
21
21
  file_write=True,
22
22
  dir=None,
23
23
  file_format=None,
24
+ log_every=1,
24
25
  ) -> None:
25
26
  from . import g
26
27
 
@@ -35,9 +36,13 @@ class Logger:
35
36
  self.log_format = log_format if log_format else const.DEFAULT_LOG_FORMAT
36
37
  self.file_write = file_write
37
38
  self.start_time = time()
39
+
40
+ self.log_every = log_every
41
+ self.log_every_counter = 0
42
+ self.log_every_buffer = ''
43
+
38
44
  if not file_write:
39
45
  return
40
-
41
46
  self.file_label = file_label
42
47
  self.dir = dir if dir else const.DEFAULT_DIR
43
48
  self.file_format = file_format if file_format else const.DEFAULT_FILE_FORMAT
@@ -52,14 +57,18 @@ class Logger:
52
57
  s = (f"Log file initialised ({self.log_path})\n"
53
58
  f"CWD: {os.getcwd()}\n"
54
59
  f"Python interpreter path: {sys.executable}\n"
55
- f"Python version: {sys.version }\n"
60
+ f"Python version: {sys.version}\n"
56
61
  f"ParUtils version: {u.__VERSION__}\n")
57
62
  self.log_print(s)
58
63
  g.logger = self
59
64
 
60
- @staticmethod
61
- def close():
65
+ def close(self):
62
66
  from . import g
67
+ if self.log_every_buffer:
68
+ self.log_every = 1
69
+ self.log_every_counter = 0
70
+ self._write_log(self.log_every_buffer, c_out=False)
71
+ self.log_every_buffer = ''
63
72
  g.logger = None
64
73
 
65
74
  def log(self, *args, level=0, c_out=True):
@@ -72,7 +81,7 @@ class Logger:
72
81
  s = f"{fdate}{msg}"
73
82
  self.log_print(s, c_out=c_out)
74
83
 
75
- def log_print(self, *args, level=0, c_out=True, nb_tab=0, dashes=0, tab_char=' '):
84
+ def log_print(self, *args, level=0, c_out=True, nb_tab=0, dashes=0, tab_char=' ', str_out=False):
76
85
  if self.level < level:
77
86
  return
78
87
 
@@ -85,6 +94,24 @@ class Logger:
85
94
  if dashes > 0:
86
95
  s = u.extend_str(s, '-', dashes)
87
96
 
97
+ if str_out:
98
+ return s + '\n'
99
+
100
+ if self.log_every > 1:
101
+ self.log_every_counter += 1
102
+ if self.log_every_counter % self.log_every == 0:
103
+ self._write_log(self.log_every_buffer + s, c_out=False)
104
+ if c_out:
105
+ print(s)
106
+ self.log_every_buffer = ''
107
+ self.log_every_counter = 0
108
+ return
109
+ else:
110
+ self.log_every_buffer += s + '\n'
111
+ if c_out:
112
+ print(s)
113
+ return
114
+
88
115
  with lock:
89
116
  self._write_log(s, c_out)
90
117
 
parutils/logging/main.py CHANGED
@@ -12,7 +12,7 @@ def log(*args, level=0, c_out=True):
12
12
 
13
13
 
14
14
  @logger_methode
15
- def log_print(*args, level=0, c_out=True, nb_tab=0, dashes=0, tab_char=' '):
15
+ def log_print(*args, level=0, c_out=True, nb_tab=0, dashes=0, tab_char=' ', str_out=False):
16
16
  """Prints something in the current log file (log_path)
17
17
 
18
18
  - level: log level. Current log level is the attribute level of the current logger.
@@ -33,17 +33,23 @@ def log_input(str_in):
33
33
 
34
34
 
35
35
  def log_array(array, nb_tab=0, tab_char=' '):
36
+ out = ''
36
37
  for elt in array:
37
- log_print(elt, nb_tab=nb_tab, tab_char=tab_char)
38
+ out += log_print(elt, nb_tab=nb_tab, tab_char=tab_char, str_out=True)
39
+ log_print(out)
38
40
 
39
41
 
40
- def log_dict(d, nb_tab=0, depth=0, tab_char=' '):
42
+ def log_dict(d, nb_tab=0, depth=0, tab_char=' ', str_out=False):
43
+ out = ''
41
44
  for key in d:
42
45
  if isinstance(d[key], dict) and depth > 0:
43
- log_print(f'{key}:', nb_tab=nb_tab, tab_char=tab_char)
44
- log_dict(d[key], nb_tab + 1, depth - 1, tab_char=tab_char)
46
+ out += log_print(f'{key}:', nb_tab=nb_tab, tab_char=tab_char, str_out=True)
47
+ out += log_dict(d[key], nb_tab + 1, depth - 1, tab_char=tab_char, str_out=True)
45
48
  else:
46
- log_print(f'{key}: {d[key]}', nb_tab=nb_tab, tab_char=tab_char)
49
+ out += log_print(f'{key}: {d[key]}', nb_tab=nb_tab, tab_char=tab_char, str_out=True)
50
+ if str_out:
51
+ return out
52
+ log_print(out)
47
53
 
48
54
 
49
55
  def log_example(list_in, what="duplicates", n_print=5):