cookworm 4.0.0__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.
- cookworm/__init__.py +26 -0
- cookworm/__main__.py +26 -0
- cookworm/config_io.py +105 -0
- cookworm/cookworm.ico +0 -0
- cookworm/cookworm.png +0 -0
- cookworm/gui.py +1279 -0
- cookworm/gui_heavy_ops.py +516 -0
- cookworm/info.py +135 -0
- cookworm/theme.py +131 -0
- cookworm/utils.py +350 -0
- cookworm-4.0.0.dist-info/METADATA +92 -0
- cookworm-4.0.0.dist-info/RECORD +15 -0
- cookworm-4.0.0.dist-info/WHEEL +4 -0
- cookworm-4.0.0.dist-info/entry_points.txt +2 -0
- cookworm-4.0.0.dist-info/licenses/LICENSE.txt +202 -0
cookworm/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Cookworm
|
|
3
|
+
|
|
4
|
+
The BookWorm Deluxe wordlist and popdefs editor.
|
|
5
|
+
|
|
6
|
+
Copyright 2026 Wilbur Jaywright d.b.a. Marswide BGL.
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
|
|
20
|
+
S.D.G."""
|
|
21
|
+
|
|
22
|
+
from .utils import *
|
|
23
|
+
from . import gui
|
|
24
|
+
from .info import PROGRAM_VER
|
|
25
|
+
|
|
26
|
+
__version__ = PROGRAM_VER
|
cookworm/__main__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# !/usr/bin/env python3
|
|
2
|
+
"""Cookworm - Main execution handle
|
|
3
|
+
|
|
4
|
+
Copyright 2026 Wilbur Jaywright d.b.a. Marswide BGL.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
See the License for the specific language governing permissions and
|
|
16
|
+
limitations under the License.
|
|
17
|
+
|
|
18
|
+
S.D.G.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from sys import exit
|
|
22
|
+
|
|
23
|
+
from .gui import main
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
exit(main())
|
cookworm/config_io.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Cookworm configuration I/O
|
|
3
|
+
|
|
4
|
+
Loads and saves the configuration for the aforementioned.
|
|
5
|
+
|
|
6
|
+
Copyright 2025 Wilbur Jaywright d.b.a. Marswide BGL.
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
|
|
20
|
+
S.D.G."""
|
|
21
|
+
|
|
22
|
+
import os
|
|
23
|
+
import os.path as op
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
import yaml
|
|
26
|
+
from . import utils
|
|
27
|
+
|
|
28
|
+
# The text encoding of the config file
|
|
29
|
+
CONFIG_ENC = "utf-8"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# The location of the config file
|
|
33
|
+
CONFIG_FILE = Path("~", ".cookworm", "config.yaml").expanduser()
|
|
34
|
+
|
|
35
|
+
# Default values for the config
|
|
36
|
+
CONFIG_DEFAULTS = {
|
|
37
|
+
"gamePath": str(utils.GAME_PATH_OS_DEFAULT)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def choose_best_game_path(suggestion: Path | str) -> Path:
|
|
42
|
+
"""Decide which is better: The suggested path, or the default
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
suggestion (Path | str): The path to try and use.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
best (Path): Our decision."""
|
|
49
|
+
|
|
50
|
+
suggestion = Path(suggestion)
|
|
51
|
+
|
|
52
|
+
# Allow system environment variable to override normal default for game path
|
|
53
|
+
msg_part = f"Config set the game path default to {suggestion}"
|
|
54
|
+
|
|
55
|
+
# The environment variable points to a nonexistent path
|
|
56
|
+
if not suggestion.exists():
|
|
57
|
+
print(msg_part, "but it does not exist.")
|
|
58
|
+
return utils.GAME_PATH_OS_DEFAULT
|
|
59
|
+
|
|
60
|
+
# The environment variable points to a real path, but not a valid game path
|
|
61
|
+
if not utils.is_game_path_valid(suggestion):
|
|
62
|
+
# The default game path is valid
|
|
63
|
+
if utils.is_game_path_valid(utils.GAME_PATH_OS_DEFAULT):
|
|
64
|
+
print(
|
|
65
|
+
msg_part,
|
|
66
|
+
f"but it is not valid while {utils.GAME_PATH_OS_DEFAULT} is.",
|
|
67
|
+
)
|
|
68
|
+
return utils.GAME_PATH_OS_DEFAULT
|
|
69
|
+
|
|
70
|
+
# The default game path isn't any better than the one provided
|
|
71
|
+
print(
|
|
72
|
+
msg_part +
|
|
73
|
+
"which is not a valid game path, but it's the best we know."
|
|
74
|
+
)
|
|
75
|
+
return suggestion
|
|
76
|
+
|
|
77
|
+
# The environment variable was set validly
|
|
78
|
+
print(msg_part)
|
|
79
|
+
return suggestion
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def load_config():
|
|
83
|
+
"""Load the config for the editor, or return blank new config"""
|
|
84
|
+
if not CONFIG_FILE.exists():
|
|
85
|
+
return CONFIG_DEFAULTS
|
|
86
|
+
|
|
87
|
+
with open(CONFIG_FILE, encoding=CONFIG_ENC) as f:
|
|
88
|
+
config = yaml.safe_load(f.read())
|
|
89
|
+
|
|
90
|
+
# Avoid loading the game path as a Path object
|
|
91
|
+
# Also, choose the best between it and the default
|
|
92
|
+
config["gamePath"] = str(choose_best_game_path(config["gamePath"]))
|
|
93
|
+
|
|
94
|
+
return config
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def save_config(config):
|
|
98
|
+
"""Save the config for the editor"""
|
|
99
|
+
|
|
100
|
+
# Ensure the config folder exists
|
|
101
|
+
os.makedirs(op.dirname(CONFIG_FILE), exist_ok=True)
|
|
102
|
+
|
|
103
|
+
# Actually write the configuration file
|
|
104
|
+
with open(CONFIG_FILE, "w", encoding=CONFIG_ENC) as f:
|
|
105
|
+
f.write(yaml.dump(config))
|
cookworm/cookworm.ico
ADDED
|
Binary file
|
cookworm/cookworm.png
ADDED
|
Binary file
|