effectual 0.5.2__py3-none-any.whl → 0.5.4__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.
- effectual/build.py +9 -10
- effectual/config.py +43 -21
- effectual/developer.py +1 -0
- {effectual-0.5.2.dist-info → effectual-0.5.4.dist-info}/METADATA +1 -1
- effectual-0.5.4.dist-info/RECORD +11 -0
- effectual/fileHash.py +0 -34
- effectual-0.5.2.dist-info/RECORD +0 -12
- {effectual-0.5.2.dist-info → effectual-0.5.4.dist-info}/WHEEL +0 -0
- {effectual-0.5.2.dist-info → effectual-0.5.4.dist-info}/entry_points.txt +0 -0
- {effectual-0.5.2.dist-info → effectual-0.5.4.dist-info}/licenses/LICENSE +0 -0
effectual/build.py
CHANGED
@@ -5,12 +5,11 @@ import zipfile
|
|
5
5
|
from pathlib import Path
|
6
6
|
from time import perf_counter
|
7
7
|
from typing import Any
|
8
|
-
from watch_lite import getHash
|
9
8
|
|
10
|
-
import
|
9
|
+
from watch_lite import getHash
|
11
10
|
|
12
11
|
from .colors import completeColor, fileColor, folderColor, tagColor
|
13
|
-
from .config import loadConfig
|
12
|
+
from .config import dumpHashes, loadConfig, loadToml
|
14
13
|
from .minifier import minifyFile, minifyToString
|
15
14
|
|
16
15
|
|
@@ -66,8 +65,9 @@ def bundleFiles(
|
|
66
65
|
|
67
66
|
|
68
67
|
def dependencies(minify: bool) -> None:
|
69
|
-
|
70
|
-
|
68
|
+
packages: list[str] = (
|
69
|
+
loadToml("./pyproject.toml").get("project").get("dependencies")
|
70
|
+
) # type: ignore
|
71
71
|
|
72
72
|
arguments: list[str] = ["--no-compile", "--quiet", "--no-binary=none", "--no-cache"]
|
73
73
|
|
@@ -112,7 +112,7 @@ def main() -> None:
|
|
112
112
|
RuntimeError: In the event there is no source directory
|
113
113
|
"""
|
114
114
|
|
115
|
-
configData: dict[
|
115
|
+
configData: dict[str, Any] = loadConfig("./pyproject.toml")
|
116
116
|
|
117
117
|
sourceDirectory: Path = Path(configData.get("sourceDirectory", "src/"))
|
118
118
|
outputDirectory: Path = Path(configData.get("outputDirectory", "out/"))
|
@@ -139,15 +139,14 @@ def main() -> None:
|
|
139
139
|
currentHash["hashes"]["lock"] = getHash("./uv.lock")
|
140
140
|
|
141
141
|
if uvHashPath.exists():
|
142
|
-
|
143
|
-
lastHash: dict[Any, Any] = dict(rtoml.load(file)).get("hashes")
|
142
|
+
lastHash: dict[str, Any] = loadToml(uvHashPath).get("hashes")
|
144
143
|
if currentHash["hashes"] != lastHash:
|
145
144
|
with open(uvHashPath, "w") as file:
|
146
|
-
|
145
|
+
dumpHashes(currentHash, file)
|
147
146
|
dependencies(minify=minification)
|
148
147
|
else:
|
149
148
|
with open(uvHashPath, "x") as file:
|
150
|
-
|
149
|
+
dumpHashes(currentHash, file)
|
151
150
|
dependencies(minify=minification)
|
152
151
|
|
153
152
|
bundleFiles(
|
effectual/config.py
CHANGED
@@ -1,38 +1,60 @@
|
|
1
|
+
import io
|
1
2
|
from typing import Any
|
2
3
|
|
3
4
|
import rtoml
|
4
5
|
|
5
6
|
|
6
|
-
def
|
7
|
-
"""Loads
|
7
|
+
def loadToml(tomlFile: str) -> dict[str, Any]:
|
8
|
+
"""Loads a toml file from a specific path to a dictionary
|
8
9
|
|
9
10
|
Args:
|
10
|
-
|
11
|
+
pathToToml (str): Path of a toml file
|
11
12
|
|
12
13
|
Raises:
|
13
|
-
RuntimeError:
|
14
|
-
RuntimeError:
|
14
|
+
RuntimeError: Toml file is incorrectly configured
|
15
|
+
RuntimeError: Toml file is can't be located
|
15
16
|
|
16
17
|
Returns:
|
17
|
-
dict:
|
18
|
+
dict[Any, Any]: Dictionary of toml file contents
|
18
19
|
"""
|
19
20
|
try:
|
20
|
-
with open(
|
21
|
-
|
22
|
-
if configData is None:
|
23
|
-
configData = {
|
24
|
-
"sourceDirectory": "./src/",
|
25
|
-
"outputDirectory": "./dist/",
|
26
|
-
"outputFileName": "bundle.pyz",
|
27
|
-
"minification": True,
|
28
|
-
"compressionLevel": 5,
|
29
|
-
}
|
30
|
-
else:
|
31
|
-
configData = configData.get("tool").get("effectual") # type: ignore
|
32
|
-
|
21
|
+
with open(tomlFile, "r", encoding="utf-8") as file:
|
22
|
+
return dict(rtoml.load(file)) # type: ignore
|
33
23
|
except ValueError as e:
|
34
|
-
raise RuntimeError(f"Invalid TOML in {
|
24
|
+
raise RuntimeError(f"Invalid TOML in {tomlFile}: {e}")
|
35
25
|
except FileNotFoundError:
|
36
|
-
raise RuntimeError(f"
|
26
|
+
raise RuntimeError(f"TOML file {tomlFile} not found.")
|
27
|
+
|
28
|
+
|
29
|
+
def loadConfig(configPath: str) -> dict[Any, Any]:
|
30
|
+
"""Loads effectual config from a file
|
31
|
+
|
32
|
+
Args:
|
33
|
+
configPath (str): Path to the config file
|
34
|
+
|
35
|
+
Returns:
|
36
|
+
dict: Dictionary containing effectual config
|
37
|
+
"""
|
38
|
+
configData: dict[str, Any] = loadToml(configPath)
|
39
|
+
if configData is None:
|
40
|
+
configData = {
|
41
|
+
"sourceDirectory": "./src/",
|
42
|
+
"outputDirectory": "./dist/",
|
43
|
+
"outputFileName": "bundle.pyz",
|
44
|
+
"minification": True,
|
45
|
+
"compressionLevel": 5,
|
46
|
+
}
|
47
|
+
else:
|
48
|
+
configData = configData.get("tool").get("effectual")
|
37
49
|
|
38
50
|
return configData
|
51
|
+
|
52
|
+
|
53
|
+
def dumpHashes(hashesToDump: dict[str, dict[str, str]], file: io.TextIOWrapper) -> None:
|
54
|
+
"""Dumps hashes in a specific format to a toml file
|
55
|
+
|
56
|
+
Args:
|
57
|
+
hashesToDump (dict[str, dict[str, str]]): Dictionary of hashes to dump as toml
|
58
|
+
file (_type_): File object
|
59
|
+
"""
|
60
|
+
return rtoml.dump(hashesToDump, file, pretty=False)
|
effectual/developer.py
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
effectual/__init__.py,sha256=9hA5S-390BtY7m-NojGHioaBJJ8vEM3IXuMvmzWBv0E,407
|
2
|
+
effectual/build.py,sha256=Ub_EL71GcclEoG0zJz20aomm-8iwOFxh6wS01W5PlK8,5556
|
3
|
+
effectual/colors.py,sha256=na7SEUSXM7aHvEKeIAn5shrZJtrBYq_ZUp121GRO_PQ,1411
|
4
|
+
effectual/config.py,sha256=3vMO_r9jf3GX7VMnZBbedk-g9rgUkfwa57bpq7yLQiQ,1767
|
5
|
+
effectual/developer.py,sha256=ERbmZuaUzSVzKgWNUWMa1H7K39xfBNeHolUEdUKcOWc,2052
|
6
|
+
effectual/minifier.py,sha256=7GHgQWzin2J1W62yMReHXaYIChXc3f0rNJA-yY4LDEI,1313
|
7
|
+
effectual-0.5.4.dist-info/METADATA,sha256=S46Zge-cvbJWjq5mcxt_CW5P953iEnDf1pYROylBqIE,2560
|
8
|
+
effectual-0.5.4.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
9
|
+
effectual-0.5.4.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
|
10
|
+
effectual-0.5.4.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
|
11
|
+
effectual-0.5.4.dist-info/RECORD,,
|
effectual/fileHash.py
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import hashlib
|
2
|
-
from multiprocessing import Pool
|
3
|
-
from pathlib import Path
|
4
|
-
|
5
|
-
|
6
|
-
def getFilehash(filePath: Path) -> str:
|
7
|
-
"""Gets the file hash of a single python script
|
8
|
-
|
9
|
-
Args:
|
10
|
-
filePath (Path): Path to a file
|
11
|
-
|
12
|
-
Returns:
|
13
|
-
str: Hash of the file
|
14
|
-
"""
|
15
|
-
with open(filePath, "rb") as file:
|
16
|
-
fileHash = hashlib.sha1(file.read()).hexdigest()
|
17
|
-
return fileHash
|
18
|
-
|
19
|
-
|
20
|
-
def getAllHashes(sourceDirectory: Path, fileExtension: str) -> set[str]:
|
21
|
-
"""Gets all hashes in directory
|
22
|
-
|
23
|
-
Args:
|
24
|
-
sourceDirectory (Path): Path to a folder containing files
|
25
|
-
|
26
|
-
Returns:
|
27
|
-
set[str]: Set containing paths and hashes
|
28
|
-
"""
|
29
|
-
|
30
|
-
with Pool() as pool:
|
31
|
-
hashList: set[str] = set(
|
32
|
-
pool.map(getFilehash, sourceDirectory.glob(f"*.{fileExtension}"))
|
33
|
-
)
|
34
|
-
return hashList
|
effectual-0.5.2.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
effectual/__init__.py,sha256=9hA5S-390BtY7m-NojGHioaBJJ8vEM3IXuMvmzWBv0E,407
|
2
|
-
effectual/build.py,sha256=WlgaXvu3dt6Uv1QpYkk9P3uUfYq0-5rHZTpiucPhpsg,5646
|
3
|
-
effectual/colors.py,sha256=na7SEUSXM7aHvEKeIAn5shrZJtrBYq_ZUp121GRO_PQ,1411
|
4
|
-
effectual/config.py,sha256=otTF0HIBwECrHpXsB-e_rlxDZg5uRwIIoUPC37TZl8Q,1165
|
5
|
-
effectual/developer.py,sha256=IL588ieg5LN9nMvGUl26I_jKiavstAVRiyik3OopiyA,2050
|
6
|
-
effectual/fileHash.py,sha256=ftFDY0RY1RF-IQxgbS9HfJp9mzgc3I6Acl69CIKUL2o,848
|
7
|
-
effectual/minifier.py,sha256=7GHgQWzin2J1W62yMReHXaYIChXc3f0rNJA-yY4LDEI,1313
|
8
|
-
effectual-0.5.2.dist-info/METADATA,sha256=wqnbNprbZ6m7Pbdo-DKLWHYixdxYxcqqp36tHHBLUD4,2560
|
9
|
-
effectual-0.5.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
10
|
-
effectual-0.5.2.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
|
11
|
-
effectual-0.5.2.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
|
12
|
-
effectual-0.5.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|