atomicshop 2.19.12__py3-none-any.whl → 2.19.13__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.19.12'
4
+ __version__ = '2.19.13'
@@ -10,6 +10,8 @@ from ..file_io.file_io import read_file
10
10
 
11
11
 
12
12
  """
13
+ Using logger in the class only once during the import of the module.
14
+
13
15
  class ParserParent:
14
16
  # Initializing the logger in the "class variable" section will leave the instance of the logger initiated
15
17
  # and the rest of the instances of the class will use the same logger.
@@ -28,6 +30,58 @@ class ParserParent:
28
30
  """
29
31
 
30
32
 
33
+ """
34
+ Using Base class for easier interfacing on subclasses.
35
+
36
+ recognition/recognition_base.py:
37
+ from abc import abstractmethod
38
+
39
+
40
+ class Recognizer:
41
+ @abstractmethod
42
+ def recognize_vendor(self, file_path: str) -> str:
43
+ pass
44
+
45
+ @abstractmethod
46
+ def recognize_family(self, bytes_list: list[str]]) -> str:
47
+ pass
48
+
49
+
50
+ recognition/super_vendor.py:
51
+ from .recognition_base import Recognizer
52
+
53
+ class SupervendorRecognizer(Recognizer):
54
+ def recognize_vendor(self, file_path: str) -> str:
55
+ classification_string: str = <Some logic to classify the SuperVendor>
56
+ return classification_string
57
+
58
+ def recognize_family(self, bytes_list: list[str]]) -> str:
59
+ family_classification_string: str = <Some logic to classify the family of the SuperVendor>
60
+ return family_classification_string
61
+
62
+
63
+ main_script.py:
64
+ from . import recognition
65
+ from .recognition.recognition_base import Recognizer
66
+
67
+ # Get the list of all the recognizers in the recognition package.
68
+ recognizers_list: list = classes.get_list_of_classes_in_module(
69
+ imported_package=recognition, imported_base_class=Recognizer)
70
+
71
+ # Get the list of all the vendors from the file.
72
+ vendors_list: list = list()
73
+ for recognizer in recognizers_list:
74
+ recognizer_instance = recognizer()
75
+ vendor_name: str = recognizer_instance.recognize_vendor(file_object=file_path)
76
+ if vendor_name:
77
+ vendors_list.append((vendor_name, recognizer_instance))
78
+
79
+ # Get the families of the vendors.
80
+ for vendor_name, recognizer_instance in vendors_list:
81
+ family_name: str = recognizer_instance.recognize_family(bytes_list=file_bytes_list)
82
+ print(f"Vendor: {vendor_name}, Family: {family_name}")
83
+ """
84
+
31
85
  def get_list_of_classes_in_module(
32
86
  imported_package,
33
87
  imported_base_class
@@ -66,6 +120,22 @@ def get_list_of_classes_in_module(
66
120
  # Get the list of classes
67
121
  unpacker_classes = get_list_of_classes_in_module(imported_package=unpackers, imported_base_class=Unpacker)
68
122
 
123
+ # Initialize the classes
124
+ for unpacker_class in unpacker_classes:
125
+ unpacker_instance = unpacker_class()
126
+ unpacker_instance.unpack("file_path")
127
+ ----------------------------
128
+ # You can also initialize the list of classes dynamically and after that execute methods.
129
+ # Example:
130
+ unpacker_classes = get_list_of_classes_in_module(imported_package=unpackers, imported_base_class=Unpacker)
131
+
132
+ instance_list: list = []
133
+ for unpacker_class in unpacker_classes:
134
+ instance_list.append(unpacker_class())
135
+
136
+ for instance in instance_list:
137
+ instance.unpack("file_path")
138
+
69
139
  :param imported_package:
70
140
  :param imported_base_class:
71
141
  :return:
@@ -207,7 +207,9 @@ def _fetch_content(
207
207
  'playwright_text',
208
208
  'js_text',
209
209
  'playwright_html',
210
+ 'playwright_html_to_text',
210
211
  'js_html',
212
+ 'js_html_to_text',
211
213
  'playwright_copypaste'
212
214
  ],
213
215
  headless: bool = True):
@@ -260,18 +262,12 @@ def _fetch_content(
260
262
  elif text_fetch_method == "js_text":
261
263
  # Use JavaScript to extract only the visible text from the page
262
264
  text_content: str = page.evaluate("document.body.innerText")
263
- elif text_fetch_method == "playwright_html":
265
+ elif "playwright_html" in text_fetch_method:
264
266
  # Get the full HTML content of the page
265
- html = page.content()
266
- # Parse the HTML using BeautifulSoup and extract the text
267
- soup = BeautifulSoup(html, 'html.parser')
268
- text_content = soup.get_text()
269
- elif text_fetch_method == "js_html":
267
+ text_content = page.content()
268
+ elif "js_html" in text_fetch_method:
270
269
  # Use JavaScript to extract the full text from the page
271
- html = page.evaluate('document.documentElement.outerHTML')
272
- # Parse the HTML using BeautifulSoup and extract the text
273
- soup = BeautifulSoup(html, 'html.parser')
274
- text_content = soup.get_text()
270
+ text_content = page.evaluate('document.documentElement.outerHTML')
275
271
  elif text_fetch_method == "playwright_copypaste":
276
272
  # Focus the page and simulate Ctrl+A and Ctrl+C
277
273
  page.keyboard.press("Control+a") # Select all text
@@ -281,6 +277,11 @@ def _fetch_content(
281
277
  else:
282
278
  raise ValueError(f"Invalid text_fetch_method: {text_fetch_method}")
283
279
 
280
+ if "to_text" in text_fetch_method:
281
+ # Convert HTML to plain text using BeautifulSoup
282
+ soup = BeautifulSoup(text_content, "html.parser")
283
+ text_content = soup.get_text()
284
+
284
285
  # text = page.evaluate('document.body.textContent')
285
286
  # text = page.eval_on_selector('body', 'element => element.innerText')
286
287
  # text = page.eval_on_selector('body', 'element => element.textContent')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.19.12
3
+ Version: 2.19.13
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=XtGdtCQBXBDdG8_6wWA54tuzPJ5IE_hCw_e_N2FoXLM,124
1
+ atomicshop/__init__.py,sha256=eRHmU5tHbd8diqaPTRFDlAasPNcCSvV7P_hocFodM0M,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
@@ -92,7 +92,7 @@ atomicshop/basics/ansi_escape_codes.py,sha256=uGVRW01v2O052701sOfAdCaM_GLF_cu_jr
92
92
  atomicshop/basics/argparse_template.py,sha256=horwgSf3MX1ZgRnYxtmmQuz9OU_vKrKggF65gmjlmfg,5836
93
93
  atomicshop/basics/booleans.py,sha256=V36NaMf8AffhCom_ovQeOZlYcdtGyIcQwWKki6h7O0M,1745
94
94
  atomicshop/basics/bytes_arrays.py,sha256=xfFW9CBQyzf0iXNWpx-EfrxtN3-tiKzuczPzOb6cOdU,7190
95
- atomicshop/basics/classes.py,sha256=UayCzPs3eynI3wOzSu-2IJSmTwOB4HwPwgVI2F-7_lQ,12648
95
+ atomicshop/basics/classes.py,sha256=dBSQktjc1GmphpD_qOGYNDl-mQcmwg8OkhSqtXPfHEU,15301
96
96
  atomicshop/basics/dicts.py,sha256=DeYHIh940pMMBrFhpXt4dsigFVYzTrlqWymNo4Pq_Js,14049
97
97
  atomicshop/basics/dicts_nested.py,sha256=StYxYnYPa0SEJr1lmEwAv5zfERWWqoULeyG8e0zRAwE,4107
98
98
  atomicshop/basics/enumerations.py,sha256=41VVQYh_vnVapggxKg2IRU5e_EiMpZzX1n1mtxvoSzM,1364
@@ -284,7 +284,7 @@ atomicshop/wrappers/playwrightw/javascript.py,sha256=_bW7CAtm0Y8IHYrAalg5HpPFnk6
284
284
  atomicshop/wrappers/playwrightw/keyboard.py,sha256=zN3YddGO-qUkn6C0CRVFejP4cTuaUwXLDNFhFREjERY,422
285
285
  atomicshop/wrappers/playwrightw/locators.py,sha256=6wsLywZxDuii7mwv-zQsRbqQC8r7j96Bma5b5_7ZoVo,2411
286
286
  atomicshop/wrappers/playwrightw/mouse.py,sha256=-2FZbQtjgH7tdXWld6ZPGqlKFUdf5in0ujN0hewxa50,656
287
- atomicshop/wrappers/playwrightw/scenarios.py,sha256=Xvl1jUmQhd4l0MmOUgQKfgGleblIyE-qC3wuoyx16tU,11531
287
+ atomicshop/wrappers/playwrightw/scenarios.py,sha256=oLrZiWnIc09I0Zvh3IxPVDPsQ-Kbr4QM0TeyXGvlsaY,11494
288
288
  atomicshop/wrappers/playwrightw/waits.py,sha256=PBFdz_PoM7Fo7O8hLqMrxNPzBEYgPoXwZceFFCGGeu8,7182
289
289
  atomicshop/wrappers/psutilw/cpus.py,sha256=w6LPBMINqS-T_X8vzdYkLS2Wzuve28Ydp_GafTCngrc,236
290
290
  atomicshop/wrappers/psutilw/disks.py,sha256=3ZSVoommKH1TWo37j_83frB-NqXF4Nf5q5mBCX8G4jE,9221
@@ -329,8 +329,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
329
329
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
330
330
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
331
331
  atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
332
- atomicshop-2.19.12.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
333
- atomicshop-2.19.12.dist-info/METADATA,sha256=IjBkWX6cc09byHYWcjX8hdW_eEmXddbKu1h0hNYUybM,10631
334
- atomicshop-2.19.12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
335
- atomicshop-2.19.12.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
336
- atomicshop-2.19.12.dist-info/RECORD,,
332
+ atomicshop-2.19.13.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
333
+ atomicshop-2.19.13.dist-info/METADATA,sha256=w6lD6Ue1Ffz4syR_hzVwv9PF65O42HFgdkvH3adb7PU,10631
334
+ atomicshop-2.19.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
335
+ atomicshop-2.19.13.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
336
+ atomicshop-2.19.13.dist-info/RECORD,,