effectual 0.5.1__tar.gz → 0.5.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {effectual-0.5.1 → effectual-0.5.3}/PKG-INFO +1 -1
- {effectual-0.5.1 → effectual-0.5.3}/pyproject.toml +1 -1
- {effectual-0.5.1 → effectual-0.5.3}/src/effectual/build.py +6 -7
- effectual-0.5.3/src/effectual/config.py +60 -0
- {effectual-0.5.1 → effectual-0.5.3}/src/effectual/developer.py +3 -2
- {effectual-0.5.1 → effectual-0.5.3}/uv.lock +1 -1
- effectual-0.5.1/src/effectual/config.py +0 -38
- effectual-0.5.1/src/effectual/fileHash.py +0 -34
- {effectual-0.5.1 → effectual-0.5.3}/.gitignore +0 -0
- {effectual-0.5.1 → effectual-0.5.3}/.python-version +0 -0
- {effectual-0.5.1 → effectual-0.5.3}/LICENSE +0 -0
- {effectual-0.5.1 → effectual-0.5.3}/README.md +0 -0
- {effectual-0.5.1 → effectual-0.5.3}/src/effectual/__init__.py +0 -0
- {effectual-0.5.1 → effectual-0.5.3}/src/effectual/colors.py +0 -0
- {effectual-0.5.1 → effectual-0.5.3}/src/effectual/minifier.py +0 -0
- {effectual-0.5.1 → effectual-0.5.3}/taskfile.yml +0 -0
@@ -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(
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import io
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
import rtoml
|
5
|
+
|
6
|
+
|
7
|
+
def loadToml(tomlFile: str | io.TextIOWrapper) -> dict[str, Any]:
|
8
|
+
"""Loads a toml file from a specific path to a dictionary
|
9
|
+
|
10
|
+
Args:
|
11
|
+
pathToToml (str | io.TextIOWrapper): Path or object of a toml file
|
12
|
+
|
13
|
+
Raises:
|
14
|
+
RuntimeError: Toml file is incorrectly configured
|
15
|
+
RuntimeError: Toml file is can't be located
|
16
|
+
|
17
|
+
Returns:
|
18
|
+
dict[Any, Any]: Dictionary of toml file contents
|
19
|
+
"""
|
20
|
+
try:
|
21
|
+
with open(tomlFile, "r", encoding="utf-8") as file:
|
22
|
+
return dict(rtoml.load(file)) # type: ignore
|
23
|
+
except ValueError as e:
|
24
|
+
raise RuntimeError(f"Invalid TOML in {tomlFile}: {e}")
|
25
|
+
except FileNotFoundError:
|
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")
|
49
|
+
|
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)
|
@@ -3,6 +3,7 @@ import time
|
|
3
3
|
import zipfile
|
4
4
|
from pathlib import Path
|
5
5
|
from typing import Any
|
6
|
+
|
6
7
|
from watch_lite import getAllHashes
|
7
8
|
|
8
9
|
from .colors import completeColor, fileColor, tagColor
|
@@ -40,10 +41,10 @@ def main() -> None:
|
|
40
41
|
|
41
42
|
runCommand = subprocess.Popen(["uv", "run", outputFile], shell=True)
|
42
43
|
|
43
|
-
lastHashSet: set[str] = getAllHashes(sourceDirectory)
|
44
|
+
lastHashSet: set[str] = getAllHashes(str(sourceDirectory))
|
44
45
|
|
45
46
|
while True:
|
46
|
-
currentHashSet: set[str] = getAllHashes(sourceDirectory)
|
47
|
+
currentHashSet: set[str] = getAllHashes(str(sourceDirectory))
|
47
48
|
if currentHashSet != lastHashSet:
|
48
49
|
lastHashSet = currentHashSet
|
49
50
|
runCommand.kill()
|
@@ -1,38 +0,0 @@
|
|
1
|
-
from typing import Any
|
2
|
-
|
3
|
-
import rtoml
|
4
|
-
|
5
|
-
|
6
|
-
def loadConfig(configPath: str) -> dict[Any, Any]:
|
7
|
-
"""Loads effectual config from a file
|
8
|
-
|
9
|
-
Args:
|
10
|
-
configPath (str): Path to the config file
|
11
|
-
|
12
|
-
Raises:
|
13
|
-
RuntimeError: Invalid TOML format
|
14
|
-
RuntimeError: No configuration file found
|
15
|
-
|
16
|
-
Returns:
|
17
|
-
dict: _description_
|
18
|
-
"""
|
19
|
-
try:
|
20
|
-
with open(configPath, "r", encoding="utf-8") as file:
|
21
|
-
configData: dict[Any, Any] = dict(rtoml.load(file))
|
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
|
-
|
33
|
-
except ValueError as e:
|
34
|
-
raise RuntimeError(f"Invalid TOML in {configPath}: {e}")
|
35
|
-
except FileNotFoundError:
|
36
|
-
raise RuntimeError(f"Configuration file {configPath} not found.")
|
37
|
-
|
38
|
-
return configData
|
@@ -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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|