python-template-project 0.1.21__py3-none-any.whl → 0.2.1__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.
- python_template_project/_version.py +16 -3
- python_template_project/cli/cli.py +69 -153
- python_template_project/config/config.py +51 -419
- python_template_project/core/base.py +1 -1
- python_template_project/core/logging.py +6 -6
- python_template_project/gui/gui.py +12 -265
- {python_template_project-0.1.21.dist-info → python_template_project-0.2.1.dist-info}/METADATA +128 -15
- python_template_project-0.2.1.dist-info/RECORD +23 -0
- python_template_project-0.1.21.dist-info/RECORD +0 -23
- {python_template_project-0.1.21.dist-info → python_template_project-0.2.1.dist-info}/WHEEL +0 -0
- {python_template_project-0.1.21.dist-info → python_template_project-0.2.1.dist-info}/entry_points.txt +0 -0
- {python_template_project-0.1.21.dist-info → python_template_project-0.2.1.dist-info}/licenses/LICENSE +0 -0
- {python_template_project-0.1.21.dist-info → python_template_project-0.2.1.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
3
|
|
|
4
|
-
__all__ = [
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
5
12
|
|
|
6
13
|
TYPE_CHECKING = False
|
|
7
14
|
if TYPE_CHECKING:
|
|
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
|
|
|
9
16
|
from typing import Union
|
|
10
17
|
|
|
11
18
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
12
20
|
else:
|
|
13
21
|
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
14
23
|
|
|
15
24
|
version: str
|
|
16
25
|
__version__: str
|
|
17
26
|
__version_tuple__: VERSION_TUPLE
|
|
18
27
|
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
19
30
|
|
|
20
|
-
__version__ = version = '0.1
|
|
21
|
-
__version_tuple__ = version_tuple = (0,
|
|
31
|
+
__version__ = version = '0.2.1'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 2, 1)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
|
@@ -1,112 +1,17 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""CLI interface for python-template-project using the generic config framework.
|
|
2
2
|
|
|
3
|
-
This file
|
|
4
|
-
Do not modify manually - regenerate using ConfigParameterManager CLI generation methods.
|
|
5
|
-
|
|
6
|
-
run cli: python -m python_template_project.cli
|
|
3
|
+
This file uses the CliGenerator from the generic config framework.
|
|
7
4
|
"""
|
|
8
5
|
|
|
9
|
-
import argparse
|
|
10
|
-
import traceback
|
|
11
6
|
from pathlib import Path
|
|
12
|
-
|
|
7
|
+
|
|
8
|
+
from config_cli_gui.cli import CliGenerator
|
|
13
9
|
|
|
14
10
|
from python_template_project.config.config import ConfigParameterManager
|
|
15
11
|
from python_template_project.core.base import BaseGPXProcessor
|
|
16
12
|
from python_template_project.core.logging import initialize_logging
|
|
17
13
|
|
|
18
14
|
|
|
19
|
-
def parse_arguments():
|
|
20
|
-
"""Parse command line arguments with config file support."""
|
|
21
|
-
parser = argparse.ArgumentParser(
|
|
22
|
-
description="Process input files",
|
|
23
|
-
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
24
|
-
epilog="""
|
|
25
|
-
Examples:
|
|
26
|
-
python -m python_template_project.cli input.txt
|
|
27
|
-
python -m python_template_project.cli --output result.txt input.txt
|
|
28
|
-
python -m python_template_project.cli --config custom_config.yaml input.txt
|
|
29
|
-
""",
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
# Config file argument
|
|
33
|
-
parser.add_argument(
|
|
34
|
-
"--config",
|
|
35
|
-
default=None,
|
|
36
|
-
help="Path to configuration file (JSON or YAML)",
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
# Verbose/quiet options for log level override
|
|
40
|
-
parser.add_argument(
|
|
41
|
-
"-v", "--verbose", action="store_true", help="Enable verbose logging (DEBUG level)"
|
|
42
|
-
)
|
|
43
|
-
parser.add_argument(
|
|
44
|
-
"-q", "--quiet", action="store_true", help="Enable quiet mode (WARNING level only)"
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
# Get CLI parameters from ConfigParameterManager
|
|
48
|
-
config_manager = ConfigParameterManager()
|
|
49
|
-
cli_params = config_manager.get_cli_parameters()
|
|
50
|
-
|
|
51
|
-
# Generate arguments from CLI config parameters
|
|
52
|
-
for param in cli_params:
|
|
53
|
-
if param.required and param.cli_arg is None:
|
|
54
|
-
# Positional argument (like 'input')
|
|
55
|
-
parser.add_argument(param.name, help=param.help)
|
|
56
|
-
else:
|
|
57
|
-
# Optional argument
|
|
58
|
-
kwargs = {
|
|
59
|
-
"default": argparse.SUPPRESS, # Don't set default here, handle in config
|
|
60
|
-
"help": f"{param.help} (default: {param.default})",
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
# Handle different parameter types
|
|
64
|
-
if param.choices and not param.type_ == bool:
|
|
65
|
-
kwargs["choices"] = param.choices
|
|
66
|
-
|
|
67
|
-
if param.type_ == int:
|
|
68
|
-
kwargs["type"] = int
|
|
69
|
-
if param.type_ == float:
|
|
70
|
-
kwargs["type"] = float
|
|
71
|
-
elif param.type_ == bool:
|
|
72
|
-
kwargs["action"] = "store_true" if not param.default else "store_false"
|
|
73
|
-
kwargs["help"] = f"{param.help} (default: {param.default})"
|
|
74
|
-
elif param.type_ == str:
|
|
75
|
-
kwargs["type"] = str
|
|
76
|
-
|
|
77
|
-
parser.add_argument(param.cli_arg, **kwargs)
|
|
78
|
-
|
|
79
|
-
return parser.parse_args()
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def create_config_overrides(args: argparse.Namespace) -> dict[str, Any]:
|
|
83
|
-
"""Create configuration overrides from CLI arguments.
|
|
84
|
-
|
|
85
|
-
Args:
|
|
86
|
-
args: Parsed command line arguments
|
|
87
|
-
|
|
88
|
-
Returns:
|
|
89
|
-
Dictionary with CLI parameter overrides in format cli__parameter_name
|
|
90
|
-
"""
|
|
91
|
-
config_manager = ConfigParameterManager()
|
|
92
|
-
cli_params = config_manager.get_cli_parameters()
|
|
93
|
-
overrides = {}
|
|
94
|
-
|
|
95
|
-
for param in cli_params:
|
|
96
|
-
if hasattr(args, param.name):
|
|
97
|
-
arg_value = getattr(args, param.name)
|
|
98
|
-
# Add CLI category prefix for override system
|
|
99
|
-
overrides[f"cli__{param.name}"] = arg_value
|
|
100
|
-
|
|
101
|
-
# Handle log level overrides from verbose/quiet flags
|
|
102
|
-
if hasattr(args, "verbose") and args.verbose:
|
|
103
|
-
overrides["app__log_level"] = "DEBUG"
|
|
104
|
-
elif hasattr(args, "quiet") and args.quiet:
|
|
105
|
-
overrides["app__log_level"] = "WARNING"
|
|
106
|
-
|
|
107
|
-
return overrides
|
|
108
|
-
|
|
109
|
-
|
|
110
15
|
def validate_config(config: ConfigParameterManager, logger) -> bool:
|
|
111
16
|
"""Validate the configuration parameters.
|
|
112
17
|
|
|
@@ -117,13 +22,20 @@ def validate_config(config: ConfigParameterManager, logger) -> bool:
|
|
|
117
22
|
Returns:
|
|
118
23
|
True if configuration is valid, False otherwise
|
|
119
24
|
"""
|
|
120
|
-
#
|
|
121
|
-
|
|
25
|
+
# Get CLI category and check required parameters
|
|
26
|
+
cli_category = config.cli
|
|
27
|
+
if not cli_category:
|
|
28
|
+
logger.error("No CLI configuration found")
|
|
29
|
+
return False
|
|
30
|
+
|
|
31
|
+
# Check if input parameter exists and has a value
|
|
32
|
+
input_param = getattr(cli_category, "input")
|
|
33
|
+
if not input_param or not input_param.value:
|
|
122
34
|
logger.error("Input is required")
|
|
123
35
|
return False
|
|
124
36
|
|
|
125
37
|
# Check if input file exists
|
|
126
|
-
input_path = Path(
|
|
38
|
+
input_path = Path(input_param.value)
|
|
127
39
|
if not input_path.exists():
|
|
128
40
|
logger.error(f"File not found: {input_path}")
|
|
129
41
|
return False
|
|
@@ -132,30 +44,22 @@ def validate_config(config: ConfigParameterManager, logger) -> bool:
|
|
|
132
44
|
return True
|
|
133
45
|
|
|
134
46
|
|
|
135
|
-
def
|
|
136
|
-
"""Main
|
|
137
|
-
logger = None
|
|
138
|
-
|
|
139
|
-
try:
|
|
140
|
-
# Parse command line arguments
|
|
141
|
-
args = parse_arguments()
|
|
142
|
-
|
|
143
|
-
# Create configuration overrides from CLI arguments
|
|
144
|
-
cli_overrides = create_config_overrides(args)
|
|
47
|
+
def run_main_processing(config: ConfigParameterManager) -> int:
|
|
48
|
+
"""Main processing function that gets called by the CLI generator.
|
|
145
49
|
|
|
146
|
-
|
|
147
|
-
config
|
|
148
|
-
config_file=args.config if hasattr(args, "config") and args.config else None,
|
|
149
|
-
**cli_overrides,
|
|
150
|
-
)
|
|
50
|
+
Args:
|
|
51
|
+
config: Configuration manager with all settings
|
|
151
52
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
53
|
+
Returns:
|
|
54
|
+
Exit code (0 for success, non-zero for error)
|
|
55
|
+
"""
|
|
56
|
+
# Initialize logging system
|
|
57
|
+
logger_manager = initialize_logging(config)
|
|
58
|
+
logger = logger_manager.get_logger("python_template_project.cli")
|
|
155
59
|
|
|
60
|
+
try:
|
|
156
61
|
# Log startup information
|
|
157
62
|
logger.info("Starting python_template_project CLI")
|
|
158
|
-
logger.debug(f"Command line arguments: {vars(args)}")
|
|
159
63
|
logger_manager.log_config_summary()
|
|
160
64
|
|
|
161
65
|
# Validate configuration
|
|
@@ -163,52 +67,64 @@ def main():
|
|
|
163
67
|
logger.error("Configuration validation failed")
|
|
164
68
|
return 1
|
|
165
69
|
|
|
166
|
-
|
|
70
|
+
# Get CLI parameters
|
|
71
|
+
cli_category = config.cli
|
|
72
|
+
input_file = cli_category.input.value
|
|
73
|
+
output_file = cli_category.output.value
|
|
74
|
+
min_dist = cli_category.min_dist.value
|
|
75
|
+
extract_waypoints = cli_category.extract_waypoints.value
|
|
76
|
+
|
|
77
|
+
# Get app parameters
|
|
78
|
+
app_category = config.app
|
|
79
|
+
date_format = app_category.date_format.value if app_category else "%Y-%m-%d"
|
|
80
|
+
|
|
81
|
+
logger.info(f"Processing input: {input_file}")
|
|
167
82
|
|
|
168
83
|
# Create and run BaseGPXProcessor
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
84
|
+
processor = BaseGPXProcessor(
|
|
85
|
+
input_=input_file,
|
|
86
|
+
output=output_file,
|
|
87
|
+
min_dist=min_dist,
|
|
88
|
+
date_format=date_format,
|
|
89
|
+
elevation=extract_waypoints,
|
|
90
|
+
logger=logger,
|
|
175
91
|
)
|
|
176
92
|
|
|
177
93
|
logger.info("Starting conversion process")
|
|
178
94
|
|
|
179
|
-
|
|
95
|
+
# Run the processing (adjust method name based on your actual implementation)
|
|
96
|
+
result_files = processor.compress_files()
|
|
180
97
|
|
|
181
|
-
logger.info(f"Successfully processed: {
|
|
182
|
-
if
|
|
183
|
-
logger.info(f"Output written to: {
|
|
98
|
+
logger.info(f"Successfully processed: {input_file}")
|
|
99
|
+
if output_file:
|
|
100
|
+
logger.info(f"Output written to: {output_file}")
|
|
101
|
+
if result_files:
|
|
102
|
+
logger.info(f"Generated files: {', '.join(result_files)}")
|
|
184
103
|
|
|
185
104
|
logger.info("CLI processing completed successfully")
|
|
186
105
|
return 0
|
|
187
106
|
|
|
188
|
-
except
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
logger.debug("Full traceback:", exc_info=True)
|
|
192
|
-
else:
|
|
193
|
-
print(f"Error: {e}")
|
|
194
|
-
traceback.print_exc()
|
|
107
|
+
except Exception as e:
|
|
108
|
+
logger.error(f"Processing failed: {e}")
|
|
109
|
+
logger.debug("Full traceback:", exc_info=True)
|
|
195
110
|
return 1
|
|
196
111
|
|
|
197
|
-
except KeyboardInterrupt:
|
|
198
|
-
if logger:
|
|
199
|
-
logger.warning("Process interrupted by user")
|
|
200
|
-
else:
|
|
201
|
-
print("Process interrupted by user")
|
|
202
|
-
return 130 # Standard exit code for SIGINT
|
|
203
112
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
113
|
+
def main():
|
|
114
|
+
"""Main entry point for the CLI application."""
|
|
115
|
+
# Create the base configuration manager
|
|
116
|
+
config_manager = ConfigParameterManager()
|
|
117
|
+
|
|
118
|
+
# Create CLI generator
|
|
119
|
+
cli_generator = CliGenerator(config_manager=config_manager, app_name="python_template_project")
|
|
120
|
+
|
|
121
|
+
# Run the CLI with our main processing function
|
|
122
|
+
return cli_generator.run_cli(
|
|
123
|
+
main_function=run_main_processing,
|
|
124
|
+
description="Process GPX files with various operations like compression, "
|
|
125
|
+
"merging, and POI extraction",
|
|
126
|
+
validator=validate_config,
|
|
127
|
+
)
|
|
212
128
|
|
|
213
129
|
|
|
214
130
|
if __name__ == "__main__":
|