kenenet 1.1.9__py3-none-any.whl → 1.2.0__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.
kenenet/__init__.py CHANGED
@@ -183,7 +183,7 @@ def pp(msg='caca', subdir=None, pps=3):
183
183
 
184
184
  def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
185
185
  global ospid
186
- # Ensure directory exists or clean if needed
186
+ # Ensure target directory exists or is cleaned once
187
187
  if os.path.exists(file):
188
188
  if reset and ospid is None:
189
189
  zhmiscellany.fileio.empty_directory(file)
@@ -191,8 +191,9 @@ def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
191
191
  else:
192
192
  quick_print(f'New folder created {file}')
193
193
  zhmiscellany.fileio.create_folder(file)
194
-
195
194
  ospid = True
195
+
196
+ # Determine caller line number for logging
196
197
  frame = inspect.currentframe().f_back
197
198
  lineno = frame.f_lineno
198
199
 
@@ -200,23 +201,23 @@ def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
200
201
  # Detect mask arrays: floating-point, single-channel
201
202
  is_mask = img.dtype.kind == 'f' and (img.ndim == 2 or (img.ndim == 3 and img.shape[-1] == 1))
202
203
 
203
- # Construct timestamped, sanitized filename
204
- timestamp = time.time()
205
- # Sanitize the provided name to remove invalid filesystem chars
206
- safe_name = re.sub(r'[^A-Za-z0-9._-]', '_', name)
207
- save_name = f"{safe_name}{timestamp}"
204
+ # Sanitize name to avoid invalid filename characters
205
+ raw_name = str(name).strip()
206
+ safe_name = re.sub(r'[^A-Za-z0-9_-]+', '_', raw_name)
207
+ timestamp = f'{time.time():.6f}' # more compact timestamp
208
+ save_name = f"{safe_name}_{timestamp}"
208
209
 
209
- # Prepare image to save
210
+ # Prepare image for saving
210
211
  if is_mask:
211
- # Scale mask [0.0,1.0] to [0,255] grayscale
212
+ # Scale mask values [0.0,1.0] to [0,255] grayscale
212
213
  mask_uint8 = (img.squeeze() * 255).clip(0, 255).astype(np.uint8)
213
214
  img_to_save = Image.fromarray(mask_uint8)
214
215
  else:
215
216
  img_to_save = Image.fromarray(img)
216
217
 
217
- # Save file
218
- save_path = os.path.join(file, f"{save_name}.png")
219
- img_to_save.save(save_path)
218
+ # Save to disk
219
+ filepath = os.path.join(file, f"{save_name}.png")
220
+ img_to_save.save(filepath)
220
221
 
221
222
  if not mute:
222
223
  quick_print(f'Saved image as {save_name}', lineno)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kenenet
3
- Version: 1.1.9
3
+ Version: 1.2.0
4
4
  Summary: dude what the fuck even is this package
5
5
  Home-page: https://www.youtube.com/@KiddyKene
6
6
  Author: kiddykene
@@ -0,0 +1,5 @@
1
+ kenenet/__init__.py,sha256=oy4f42bfvN-UX-T7r9zViybxIHsGXhGvcTIPqdnTFMo,22026
2
+ kenenet-1.2.0.dist-info/METADATA,sha256=CqZ5DO_3bxTDMSbtLuBv_11h_Bk_c_X3SZGp6kO0wk8,1693
3
+ kenenet-1.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
+ kenenet-1.2.0.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
+ kenenet-1.2.0.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- kenenet/__init__.py,sha256=1uA-m7NkdOIPdcZOpr4Zb7caDcrwbnXhqY0eR6AsM2U,21946
2
- kenenet-1.1.9.dist-info/METADATA,sha256=OIAT4qSfUC1S_I_VZQsz2qU00812VTSFLaw1TuUJ2yA,1693
3
- kenenet-1.1.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
- kenenet-1.1.9.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
- kenenet-1.1.9.dist-info/RECORD,,