-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommonconfig.py
More file actions
64 lines (51 loc) · 1.79 KB
/
commonconfig.py
File metadata and controls
64 lines (51 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import annotations
import os
from functools import wraps
from pathlib import Path
import colorama
from helper import BuildError, read_version_file, set_readonly, write_version_file
colorama.init(autoreset=True)
def stage(name: str):
def decorator(function):
@wraps(function)
def wrapper(*args, **kwargs):
print()
print(
colorama.Style.BRIGHT
+ colorama.Fore.YELLOW
+ "======== stage: "
+ colorama.Style.BRIGHT
+ colorama.Fore.CYAN
+ name
+ colorama.Style.BRIGHT
+ colorama.Fore.YELLOW
+ " ========="
)
return function(*args, **kwargs)
return wrapper
return decorator
def check_paths(env: dict[str, str]) -> None:
essentials = [
env["sourcesdk"],
env["GameExeDir"],
os.path.join(env["GameExeDir"], "bin"),
os.path.join(env["GameDir"], "addons"),
os.path.join(env["GameDir"], "maps"),
env["mapdata"],
os.path.join(env["sourcesdk"], "bin"),
os.path.join(env["sourcesdk"], "bin", "hammer.exe"),
os.path.join(env["VProject"], "gameinfo.txt"),
env["VProject"],
env["version_file"],
env["SteamPath"],
]
for path in essentials:
if not Path(path).exists():
raise BuildError("missing path", {"path": path})
def next_build_version(version_file: Path, delta: int) -> int:
version = read_version_file(version_file)
next_version = version + delta
set_readonly(version_file, False)
write_version_file(version_file, next_version)
set_readonly(version_file, True)
return next_version