atomicshop 2.11.45__py3-none-any.whl → 2.11.47__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.
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.11.45'
4
+ __version__ = '2.11.47'
atomicshop/filesystem.py CHANGED
@@ -1178,3 +1178,54 @@ def create_dict_of_path(
1178
1178
  # If it's not the last part and the entry exists, navigate deeper
1179
1179
  if not is_last_part:
1180
1180
  current_level = existing_entry["included"]
1181
+
1182
+
1183
+ def is_any_file_in_directory_locked(directory_path: str) -> bool:
1184
+ """
1185
+ The function checks if any file in the directory is locked (if the file is currently being written to that directory
1186
+ it will be locked for reading). Basically it opens a handle for read and write and if it fails, then the file is
1187
+ locked.
1188
+
1189
+ :param directory_path: string, full path to directory.
1190
+ :return: boolean, if 'True', then at least one file in the directory is locked.
1191
+ """
1192
+
1193
+ for filename in os.listdir(directory_path):
1194
+ file_path = os.path.join(directory_path, filename)
1195
+ if os.path.isfile(file_path):
1196
+ return is_file_locked(file_path)
1197
+ return False
1198
+
1199
+
1200
+ def is_any_file_locked_in_list(file_paths_list: list[str]) -> bool:
1201
+ """
1202
+ The function checks if any file in the list is locked (if the file is currently being written to it will be locked
1203
+ for reading). Basically it opens a handle for read and write and if it fails, then the file is locked.
1204
+
1205
+ :param file_paths_list: list of strings, full paths to files.
1206
+ :return: boolean, if 'True', then at least one file in the list is locked.
1207
+ """
1208
+
1209
+ for file_path in file_paths_list:
1210
+ if is_file_locked(file_path):
1211
+ return True
1212
+ return False
1213
+
1214
+
1215
+ def is_file_locked(file_path: str) -> bool:
1216
+ """
1217
+ The function checks if the file is locked (if the file is currently being written to it will be locked for reading).
1218
+ Basically it opens a handle for read and write and if it fails, then the file is locked.
1219
+
1220
+ :param file_path: string, full path to file.
1221
+ :return: boolean, if 'True', then the file is locked.
1222
+ """
1223
+
1224
+ try:
1225
+ # Attempt to open the file exclusively
1226
+ with open(file_path, 'rb+') as f:
1227
+ pass
1228
+ except IOError:
1229
+ # If we can't open the file, it might be in the process of being copied
1230
+ return True
1231
+ return False
atomicshop/permissions.py CHANGED
@@ -1,12 +1,12 @@
1
1
  import os
2
- import pwd
3
2
  import stat
4
3
  import ctypes
5
4
  import contextlib
6
5
  import subprocess
7
6
 
8
- from . import process
9
- from .print_api import print_api
7
+ # Import pwd only on linux.
8
+ if os.name == 'posix':
9
+ import pwd
10
10
 
11
11
 
12
12
  def is_admin() -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.11.45
3
+ Version: 2.11.47
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=mpH3qhCaSQmRvuHHeLe65x8vSjvJ-_SFZ4b0HI-hcuc,124
1
+ atomicshop/__init__.py,sha256=iicioUVwuMXQSs-gY_TniBemm3mIn4HWv1LaKkaK9JU,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=bNZOo5jVPzq7OT2qCPukXoK3zb1oOsyaelUwQEyK1SA,2500
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=I72yd_-G1y7aWtD7IzgUQn5BBg8Dpri8o7Jrb_-kfW4,44060
17
+ atomicshop/filesystem.py,sha256=1KjRxsUVwtKwu87LheM6Tj1Wr2FLRmLA1YjLK-NpoUI,46010
18
18
  atomicshop/functions.py,sha256=pK8hoCE9z61PtWCxQJsda7YAphrLH1wxU5x-1QJP-sY,499
19
19
  atomicshop/hashing.py,sha256=Le8qGFyt3_wX-zGTeQShz7L2HL_b6nVv9PnawjglyHo,3474
20
20
  atomicshop/http_parse.py,sha256=nrf2rZcprLqtW8HVrV7TCZ1iTBcWRRy-mXIlAOzcaJs,9703
@@ -22,7 +22,7 @@ atomicshop/inspect_wrapper.py,sha256=sGRVQhrJovNygHTydqJj0hxES-aB2Eg9KbIk3G31apw
22
22
  atomicshop/ip_addresses.py,sha256=Hvi4TumEFoTEpKWaq5WNF-YzcRzt24IxmNgv-Mgax1s,1190
23
23
  atomicshop/keyboard_press.py,sha256=1W5kRtOB75fulVx-uF2yarBhW0_IzdI1k73AnvXstk0,452
24
24
  atomicshop/pbtkmultifile_argparse.py,sha256=aEk8nhvoQVu-xyfZosK3ma17CwIgOjzO1erXXdjwtS4,4574
25
- atomicshop/permissions.py,sha256=tKIluW-p3ThLh1H3QEFgPFRVzw5hafAHk9QJ5OOT_0M,3047
25
+ atomicshop/permissions.py,sha256=441sSs7QBX3cuFIEG8U-RiiDwXE5XL-PESpRbZLKqqw,3047
26
26
  atomicshop/print_api.py,sha256=DhbCQd0MWZZ5GYEk4oTu1opRFC-b31g1VWZgTGewG2Y,11568
27
27
  atomicshop/process.py,sha256=kOLrpUb5T5QN9ZvpGOjXyo7Kivrc14A9gcw9lvNMidI,15670
28
28
  atomicshop/process_name_cmd.py,sha256=TNAK6kQZm5JKWzEW6QLqVHEG98ZLNDQiSS4YwDk8V8c,3830
@@ -244,8 +244,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
244
244
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
245
245
  atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
246
246
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
247
- atomicshop-2.11.45.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
248
- atomicshop-2.11.45.dist-info/METADATA,sha256=t7wGnrCcHTPSHv7R-pERzYThnJwXXeZ3_hHArgX4BtE,10448
249
- atomicshop-2.11.45.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
250
- atomicshop-2.11.45.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
251
- atomicshop-2.11.45.dist-info/RECORD,,
247
+ atomicshop-2.11.47.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
248
+ atomicshop-2.11.47.dist-info/METADATA,sha256=Cv2ibrVF1l6qxqTF4UDs3Q5M3JuuC6wq_ISHxyxuoZ0,10448
249
+ atomicshop-2.11.47.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
250
+ atomicshop-2.11.47.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
251
+ atomicshop-2.11.47.dist-info/RECORD,,