mirror of
https://github.com/aclist/dztui.git
synced 2026-11-01 15:42:51 +01:00
chore: restructure as class
This commit is contained in:
1 parent
ad1598ee0d
commit
3b35d75b72
1 file changed
+44
-8
@@ -1,16 +1,52 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
BOILERPLATE = """
|
||||||
|
This file includes the combined licenses to the following components:
|
||||||
|
|
||||||
|
1) The DZGUI utility
|
||||||
|
2) The Python interpreter
|
||||||
|
3) Third-party dependencies
|
||||||
|
- dayzquery
|
||||||
|
- requests
|
||||||
|
- packaging
|
||||||
|
- psutil
|
||||||
|
- PyGObject
|
||||||
|
- python-a2s
|
||||||
|
|
||||||
|
which are collectively bundled as a turnkey application and used to run the DZGUI utility.\n\n
|
||||||
|
"""
|
||||||
|
DZGUI_HEADER = "DZGUI application"
|
||||||
|
LICENSE_FILE = "LICENSE"
|
||||||
|
|
||||||
|
class CombinedLicense:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self.text = BOILERPLATE
|
||||||
|
|
||||||
|
def append(self, text: str) -> None:
|
||||||
|
self.text += text + "\n\n"
|
||||||
|
|
||||||
|
def add_header(self, text: str) -> None:
|
||||||
|
self.append(f"--- License for the component '{text}' follows ---")
|
||||||
|
|
||||||
|
def add_dependency(self, dep: str) -> None:
|
||||||
|
self.add_header(dep)
|
||||||
|
|
||||||
|
def get_text(self) -> str:
|
||||||
|
return self.text
|
||||||
|
|
||||||
def concat_license() -> str:
|
def concat_license() -> str:
|
||||||
combined = ""
|
combined = CombinedLicense()
|
||||||
root = Path(__file__).resolve().parents[1]
|
root = Path(__file__).resolve().parents[1]
|
||||||
licenses = root.joinpath("licenses")
|
licenses = root.joinpath("licenses")
|
||||||
self_license = root.joinpath("LICENSE")
|
|
||||||
combined += "--- DZGUI application license ---\n\n"
|
main_license = root.joinpath(LICENSE_FILE)
|
||||||
combined += self_license.read_text()
|
combined.add_header(DZGUI_HEADER)
|
||||||
|
combined.append(main_license.read_text())
|
||||||
|
|
||||||
for _dir in licenses.iterdir():
|
for _dir in licenses.iterdir():
|
||||||
|
# NOTE: expects a single file
|
||||||
docs = _dir.glob("*")
|
docs = _dir.glob("*")
|
||||||
doc = list(docs)[0]
|
doc = list(docs)[0]
|
||||||
header = f"\n--- The verbatim license for bundled dependency '{_dir.name}' follows ---\n\n"
|
combined.add_dependency(_dir.name)
|
||||||
combined += header
|
combined.append(doc.read_text())
|
||||||
combined += doc.read_text()
|
return combined.get_text()
|
||||||
return combined
|
|
||||||
Reference in new issue
Block a user