YouTubeDownloader v1.1.2
YouTube content downloader
Loading...
Searching...
No Matches
Executable.check_included_packages Namespace Reference

Functions

list[str] check_included_packages ()
 Check included packages.
 

Variables

list L_ALLOWED_THIRD_PARTY_PACKAGES
 
 log = logging.getLogger("CheckIncludedPackages")
 
str S_RELATIVE_PATH = fr"build\{__title__}\xref-{__title__}.html"
 

Detailed Description


Function Documentation

◆ check_included_packages()

list[str] check_included_packages ( )

Check included packages.

Returns
status if included packages are okay

Definition at line 39 of file check_included_packages.py.

39def check_included_packages() -> list[str]:
40 """!
41 @brief Check included packages
42 @return status if included packages are okay
43 """
44 d_third_party = {}
45 d_buildin = {}
46 d_own_packs = {}
47
48 # Regular Expressions
49 regex_third_party = re.compile(r".venv\/lib\/site-packages.*.py", re.IGNORECASE)
50 regex_third_party_name = re.compile(r"(?<=site-packages\/).*", re.IGNORECASE)
51 regex_builtin = re.compile(r".venv\/lib\/.*.py", re.IGNORECASE)
52 regex_builtin_name = re.compile(r"(?<=lib\/).*", re.IGNORECASE)
53 regex_own_packs = re.compile(fr"{__title__}\/.*")
54
55 # read PyInstaller modulegraph cross reference HTML
56 with open(S_RELATIVE_PATH, mode="r", encoding="utf-8") as o_html_file:
57 soup = BeautifulSoup(o_html_file, "html.parser")
58
59 # parse HTML
60 l_nodes = soup.find_all("div", class_="node")
61 for o_node in l_nodes:
62 l_targets = o_node.find_all("a", target="code")
63 for o_target in l_targets:
64 s_package_path = o_target["href"]
65 if regex_third_party.search(s_package_path):
66 matches = regex_third_party_name.search(s_package_path)
67 if matches is not None:
68 d_third_party[matches.group().split("/", maxsplit=1)[0].replace(".py", "")] = ""
69 elif regex_builtin.search(s_package_path):
70 matches = regex_builtin_name.search(s_package_path)
71 if matches is not None:
72 d_buildin[matches.group().replace(".py", "")] = ""
73 elif regex_own_packs.search(s_package_path):
74 matches = regex_own_packs.search(s_package_path)
75 if matches is not None:
76 d_own_packs[matches.group()] = ""
77
78 # print included packages
79 log.debug("\nThird party packages:")
80 log.debug("\n".join(list(d_third_party.keys())))
81 log.debug("\nOwn packages:")
82 log.debug("\n".join(list(d_own_packs.keys())))
83 log.debug("\nPython buildin packages:")
84 log.debug("\n".join(list(d_buildin.keys())))
85
86 # check third party packages
87 l_not_allowed_packages = []
88 for s_package in list(d_third_party.keys()):
89 if s_package not in L_ALLOWED_THIRD_PARTY_PACKAGES:
90 l_not_allowed_packages.append(f"ERROR PyInstaller included an unknown package in the executable: \'{s_package}\'")
91 return l_not_allowed_packages

Variable Documentation

◆ L_ALLOWED_THIRD_PARTY_PACKAGES

list L_ALLOWED_THIRD_PARTY_PACKAGES
Initial value:
1= [
2 # not possible to exclude
3 "PyInstaller",
4 # clipboard
5 "clipboard",
6 "pyperclip",
7 # youtube downloader
8 "pytubefix",
9 "customtkinter",
10 "darkdetect",
11 "packaging",
12 "openpyxl",
13 "et_xmlfile",
14 # colored log
15 "colorama"
16]

Definition at line 19 of file check_included_packages.py.

◆ log

log = logging.getLogger("CheckIncludedPackages")

Definition at line 15 of file check_included_packages.py.

◆ S_RELATIVE_PATH

str S_RELATIVE_PATH = fr"build\{__title__}\xref-{__title__}.html"

Definition at line 36 of file check_included_packages.py.