effectual 0.5.2__py3-none-any.whl → 0.5.3__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- effectual/build.py +6 -7
- effectual/config.py +43 -21
- effectual/developer.py +1 -0
- {effectual-0.5.2.dist-info → effectual-0.5.3.dist-info}/METADATA +1 -1
- effectual-0.5.3.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.3.dist-info}/WHEEL +0 -0
- {effectual-0.5.2.dist-info → effectual-0.5.3.dist-info}/entry_points.txt +0 -0
- {effectual-0.5.2.dist-info → effectual-0.5.3.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
|
|
@@ -67,7 +66,7 @@ def bundleFiles(
|
|
67
66
|
|
68
67
|
def dependencies(minify: bool) -> None:
|
69
68
|
with open("./pyproject.toml", "r", encoding="utf-8") as file:
|
70
|
-
packages: list[str] =
|
69
|
+
packages: list[str] = loadToml(file).get("project").get("dependencies") # type: ignore
|
71
70
|
|
72
71
|
arguments: list[str] = ["--no-compile", "--quiet", "--no-binary=none", "--no-cache"]
|
73
72
|
|
@@ -140,14 +139,14 @@ def main() -> None:
|
|
140
139
|
|
141
140
|
if uvHashPath.exists():
|
142
141
|
with open(uvHashPath, "r") as file:
|
143
|
-
lastHash: dict[Any, Any] =
|
142
|
+
lastHash: dict[Any, Any] = loadToml(file).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 | io.TextIOWrapper) -> dict[str, Any]:
|
8
|
+
"""Loads a toml file from a specific path to a dictionary
|
8
9
|
|
9
10
|
Args:
|
10
|
-
|
11
|
+
pathToToml (str | io.TextIOWrapper): Path or object 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=PfnE6A8OfrVNV5AFxwqQIpNwr7OxbfhjkIzkcwSRM0M,5638
|
3
|
+
effectual/colors.py,sha256=na7SEUSXM7aHvEKeIAn5shrZJtrBYq_ZUp121GRO_PQ,1411
|
4
|
+
effectual/config.py,sha256=HthkvUSOvkEN9N2_Eg5z4OU1jLLixLB5mmv-Npf3f4o,1815
|
5
|
+
effectual/developer.py,sha256=ERbmZuaUzSVzKgWNUWMa1H7K39xfBNeHolUEdUKcOWc,2052
|
6
|
+
effectual/minifier.py,sha256=7GHgQWzin2J1W62yMReHXaYIChXc3f0rNJA-yY4LDEI,1313
|
7
|
+
effectual-0.5.3.dist-info/METADATA,sha256=J5La4SFmCBy5DYzkzagOQqUbysivbsoknc1RAV_vV-Y,2560
|
8
|
+
effectual-0.5.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
9
|
+
effectual-0.5.3.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
|
10
|
+
effectual-0.5.3.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
|
11
|
+
effectual-0.5.3.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
|