atomicshop 2.18.12__py3-none-any.whl → 2.18.14__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/archiver/search_in_archive.py +2 -1
- atomicshop/filesystem.py +102 -0
- {atomicshop-2.18.12.dist-info → atomicshop-2.18.14.dist-info}/METADATA +1 -1
- {atomicshop-2.18.12.dist-info → atomicshop-2.18.14.dist-info}/RECORD +8 -8
- {atomicshop-2.18.12.dist-info → atomicshop-2.18.14.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.18.12.dist-info → atomicshop-2.18.14.dist-info}/WHEEL +0 -0
- {atomicshop-2.18.12.dist-info → atomicshop-2.18.14.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
|
@@ -13,7 +13,8 @@ SUPPORTED_ARCHIVE_MIMES: list = [
|
|
|
13
13
|
'application/x-7z-compressed',
|
|
14
14
|
'application/zip',
|
|
15
15
|
'application/x-dosexec', # SFX zip files.
|
|
16
|
-
'application/octet-stream' # There are some non-standard zip files that are not recognized by magic.
|
|
16
|
+
'application/octet-stream', # There are some non-standard zip files that are not recognized by magic.
|
|
17
|
+
'application/vnd.microsoft.portable-executable' # PE files. Some self extracting archives are PE files, But the zip module can handle them.
|
|
17
18
|
]
|
|
18
19
|
|
|
19
20
|
|
atomicshop/filesystem.py
CHANGED
|
@@ -329,6 +329,36 @@ def remove_directory(directory_path: str, force_readonly: bool = False, print_kw
|
|
|
329
329
|
return False
|
|
330
330
|
|
|
331
331
|
|
|
332
|
+
def remove_empty_directories(directory_path: str) -> list[str]:
|
|
333
|
+
"""
|
|
334
|
+
Recursively removes empty directories in the given path, including the given path if it is empty.
|
|
335
|
+
|
|
336
|
+
:param directory_path: The starting directory path to check and remove empty directories.
|
|
337
|
+
"""
|
|
338
|
+
if not os.path.isdir(directory_path):
|
|
339
|
+
# print(f"Path '{directory_path}' is not a directory or does not exist.")
|
|
340
|
+
return []
|
|
341
|
+
|
|
342
|
+
removed_directories: list = []
|
|
343
|
+
# Iterate through the directory contents
|
|
344
|
+
for root, dirs, files in os.walk(directory_path, topdown=False):
|
|
345
|
+
for directory in dirs:
|
|
346
|
+
dir_path = os.path.join(root, directory)
|
|
347
|
+
# Check if the directory is empty
|
|
348
|
+
if not os.listdir(dir_path):
|
|
349
|
+
os.rmdir(dir_path)
|
|
350
|
+
removed_directories.append(dir_path)
|
|
351
|
+
# print(f"Removed empty directory: {dir_path}")
|
|
352
|
+
|
|
353
|
+
# Finally, check if the top-level directory is empty
|
|
354
|
+
if not os.listdir(directory_path):
|
|
355
|
+
os.rmdir(directory_path)
|
|
356
|
+
removed_directories.append(directory_path)
|
|
357
|
+
# print(f"Removed top-level empty directory: {path}")
|
|
358
|
+
|
|
359
|
+
return removed_directories
|
|
360
|
+
|
|
361
|
+
|
|
332
362
|
def create_directory(directory_fullpath: str):
|
|
333
363
|
# Create directory if non-existent.
|
|
334
364
|
# The library is used to create folder if it doesn't exist and won't raise exception if it does
|
|
@@ -353,6 +383,78 @@ def rename_file(file_path: str, new_file_name: str) -> None:
|
|
|
353
383
|
os.rename(file_path, renamed_file_path)
|
|
354
384
|
|
|
355
385
|
|
|
386
|
+
def rename_file_with_special_characters(file_path: str) -> str:
|
|
387
|
+
"""
|
|
388
|
+
The function will rename the file to replace special characters from the file name with '_'.
|
|
389
|
+
If the file already exists, then the function will add a number to the end of the file name.
|
|
390
|
+
|
|
391
|
+
:param file_path: string, full path to file.
|
|
392
|
+
:return: string, full path to file with special characters renamed.
|
|
393
|
+
"""
|
|
394
|
+
|
|
395
|
+
# Get the file name without extension
|
|
396
|
+
file_stem: str = str(Path(file_path).stem)
|
|
397
|
+
file_extension: str = str(Path(file_path).suffix)
|
|
398
|
+
|
|
399
|
+
# Remove special characters from the file name
|
|
400
|
+
new_file_stem = strings.replace_strings_with_values_from_dict(
|
|
401
|
+
string_to_replace=file_stem, dictionary=FILE_NAME_REPLACEMENT_DICT)
|
|
402
|
+
|
|
403
|
+
# Rename the file
|
|
404
|
+
renamed_file_path = str(Path(file_path).parent) + os.sep + new_file_stem + file_extension
|
|
405
|
+
|
|
406
|
+
counter: int = 1
|
|
407
|
+
if os.path.isfile(renamed_file_path):
|
|
408
|
+
while True:
|
|
409
|
+
new_file_stem = f'{new_file_stem}_{counter}'
|
|
410
|
+
renamed_file_path = str(Path(file_path).parent) + os.sep + new_file_stem + file_extension
|
|
411
|
+
if not os.path.isfile(renamed_file_path):
|
|
412
|
+
break
|
|
413
|
+
counter += 1
|
|
414
|
+
|
|
415
|
+
os.rename(file_path, renamed_file_path)
|
|
416
|
+
|
|
417
|
+
return renamed_file_path
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def rename_files_and_directories_with_special_characters(base_path: str) -> None:
|
|
421
|
+
"""
|
|
422
|
+
Recursively renames all files and directories in the given directory to rename special characters.
|
|
423
|
+
|
|
424
|
+
:param base_path: str, the base directory to start processing.
|
|
425
|
+
"""
|
|
426
|
+
|
|
427
|
+
def sanitize_name(name: str) -> str:
|
|
428
|
+
"""
|
|
429
|
+
Helper function to replace special characters in a string using a dictionary.
|
|
430
|
+
"""
|
|
431
|
+
for key, value in FILE_NAME_REPLACEMENT_DICT.items():
|
|
432
|
+
name = name.replace(key, value)
|
|
433
|
+
return name
|
|
434
|
+
|
|
435
|
+
# Walk through the directory tree in reverse to ensure we rename files before directories
|
|
436
|
+
for root, dirs, files in os.walk(base_path, topdown=False):
|
|
437
|
+
# Rename files in the current directory
|
|
438
|
+
for file_name in files:
|
|
439
|
+
old_path = Path(root) / file_name
|
|
440
|
+
sanitized_name = sanitize_name(file_name)
|
|
441
|
+
new_path = Path(root) / sanitized_name
|
|
442
|
+
|
|
443
|
+
if sanitized_name != file_name: # Rename only if the name changed
|
|
444
|
+
# print(f"Renaming file: {old_path} -> {new_path}")
|
|
445
|
+
os.rename(old_path, new_path)
|
|
446
|
+
|
|
447
|
+
# Rename directories in the current directory
|
|
448
|
+
for dir_name in dirs:
|
|
449
|
+
old_path = Path(root) / dir_name
|
|
450
|
+
sanitized_name = sanitize_name(dir_name)
|
|
451
|
+
new_path = Path(root) / sanitized_name
|
|
452
|
+
|
|
453
|
+
if sanitized_name != dir_name: # Rename only if the name changed
|
|
454
|
+
# print(f"Renaming directory: {old_path} -> {new_path}")
|
|
455
|
+
os.rename(old_path, new_path)
|
|
456
|
+
|
|
457
|
+
|
|
356
458
|
@contextmanager
|
|
357
459
|
def temporary_rename(file_path: str, temp_file_path) -> None:
|
|
358
460
|
# noinspection GrazieInspection
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=iHkJnN-sgfMa_LmJTJIrfBMcqKRYbUYo7065JWRf6cM,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
|
|
@@ -14,7 +14,7 @@ atomicshop/dns.py,sha256=5Gimq_WY2arqg7BeGmR7P--fGfnH0Dsh8lrOt_H0jRY,6817
|
|
|
14
14
|
atomicshop/domains.py,sha256=Rxu6JhhMqFZRcoFs69IoEd1PtYca0lMCG6F1AomP7z4,3197
|
|
15
15
|
atomicshop/emails.py,sha256=I0KyODQpIMEsNRi9YWSOL8EUPBiWyon3HRdIuSj3AEU,1410
|
|
16
16
|
atomicshop/file_types.py,sha256=-0jzQMRlmU1AP9DARjk-HJm1tVE22E6ngP2mRblyEjY,763
|
|
17
|
-
atomicshop/filesystem.py,sha256=
|
|
17
|
+
atomicshop/filesystem.py,sha256=1m-_cDiio6f4KnyHNdn2NhS60RneB-jcmc4Tdc5RlU8,62368
|
|
18
18
|
atomicshop/functions.py,sha256=pK8hoCE9z61PtWCxQJsda7YAphrLH1wxU5x-1QJP-sY,499
|
|
19
19
|
atomicshop/get_process_list.py,sha256=8cxb7gKe9sl4R6H2yMi8J6oe-RkonTvCdKjRFqi-Fs4,6075
|
|
20
20
|
atomicshop/get_process_name_cmd_dll.py,sha256=CtaSp3mgxxJKCCVW8BLx6BJNx4giCklU_T7USiCEwfc,5162
|
|
@@ -77,7 +77,7 @@ atomicshop/addons/process_list/compiled/Win10x64/process_list.exp,sha256=cbvukIT
|
|
|
77
77
|
atomicshop/addons/process_list/compiled/Win10x64/process_list.lib,sha256=T2Ncs0MwKlAaCq8UKFMvfQAfcJdDx-nWiHVBfglrLIU,2112
|
|
78
78
|
atomicshop/archiver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
79
|
atomicshop/archiver/_search_in_zip.py,sha256=dd8qFSvIhcKmtnPj_uYNJFPmMwZp4tZys0kKgTw_ACw,8385
|
|
80
|
-
atomicshop/archiver/search_in_archive.py,sha256=
|
|
80
|
+
atomicshop/archiver/search_in_archive.py,sha256=iDIWS9G2pdz6QxGawGQJ1RSl33gdIRjpYrnP0brIDgU,12450
|
|
81
81
|
atomicshop/archiver/sevenz_app_w.py,sha256=BWcJb4f7jZEiETDBKyNLE0f5YLFPQx6B91_ObEIXWf8,3007
|
|
82
82
|
atomicshop/archiver/sevenzs.py,sha256=b9rI-nF36ZNawwKsPWOgsnm0p-jYDfD1NYV3eA8LoQ0,2491
|
|
83
83
|
atomicshop/archiver/shutils.py,sha256=BomnK7zT-nQXA1z0i2R2aTv8eu88wPx7tf2HtOdbmEc,1280
|
|
@@ -320,8 +320,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
|
|
|
320
320
|
atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
321
321
|
atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=on99OTT1_0g4KITAW5mSugUYgCAdVikhWjJ78a7JVIQ,1785
|
|
322
322
|
atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
|
|
323
|
-
atomicshop-2.18.
|
|
324
|
-
atomicshop-2.18.
|
|
325
|
-
atomicshop-2.18.
|
|
326
|
-
atomicshop-2.18.
|
|
327
|
-
atomicshop-2.18.
|
|
323
|
+
atomicshop-2.18.14.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
324
|
+
atomicshop-2.18.14.dist-info/METADATA,sha256=X2ETn4vvALQe0wRjZMQDSXT_yLd6WEL05seJ6cJpB_I,10577
|
|
325
|
+
atomicshop-2.18.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
326
|
+
atomicshop-2.18.14.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
327
|
+
atomicshop-2.18.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|