dev-tools-loader 0.2.0__tar.gz → 0.3.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dev_tools_loader
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Development tools loader
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://gitlab.com/karma_electronics/desktop/dev_tools_loader
@@ -51,6 +51,7 @@ dev_tools_loader -j path/to/config.json
51
51
  - **`-j`, `--json-path` *`<json_config_path>`*** **(required)** Specifies the path to the JSON configuration file that defines download targets.
52
52
  - **`-o`, `--output-path` *`<output_dir>`*** Sets the output directory where downloaded files will be saved.
53
53
  - **`-c`, `--clean`** If specified, deletes files in the target output directory before starting the download process.
54
+ - **`-t`, `--template`** Create JSON config template (json-path required).
54
55
  - **`-h`, `--help`** Displays the help message with a summary of all available options and exits.
55
56
  - **`--version`** Prints the current version of the `dev-tools-loader` package and exits.
56
57
 
@@ -39,6 +39,7 @@ dev_tools_loader -j path/to/config.json
39
39
  - **`-j`, `--json-path` *`<json_config_path>`*** **(required)** Specifies the path to the JSON configuration file that defines download targets.
40
40
  - **`-o`, `--output-path` *`<output_dir>`*** Sets the output directory where downloaded files will be saved.
41
41
  - **`-c`, `--clean`** If specified, deletes files in the target output directory before starting the download process.
42
+ - **`-t`, `--template`** Create JSON config template (json-path required).
42
43
  - **`-h`, `--help`** Displays the help message with a summary of all available options and exits.
43
44
  - **`--version`** Prints the current version of the `dev-tools-loader` package and exits.
44
45
 
@@ -2,4 +2,4 @@ from .dev_tools_loader import DevToolsLoader
2
2
 
3
3
  __all__ = ['DevToolsLoader']
4
4
 
5
- __version__ = '0.2.0'
5
+ __version__ = '0.3.0'
@@ -11,21 +11,26 @@ def main():
11
11
  parser.add_argument('-j', '--json-path', help='Path to JSON config file', action='store', required=True)
12
12
  parser.add_argument('-o', '--output-path', help='Path to output dir (default ./output)', action='store', default=Path(os.getcwd()) / Path('output'))
13
13
  parser.add_argument('-c', '--clean', help='Clean output before load (default False)', action='store_true')
14
+ parser.add_argument('-t', '--template', help='Create config template (default False)', action='store_true')
14
15
  parser.add_argument('--version', help='Show version', action='version', version=f'%(prog)s {__version__}')
15
16
  args = parser.parse_args()
16
17
 
17
- try:
18
- dtl = DevToolsLoader(args.json_path, args.output_path, args.clean)
19
- dtl.run()
18
+ if args.template:
19
+ DevToolsLoader.create_template(args.json_path)
20
20
 
21
- except KeyboardInterrupt:
22
- DebugLog.log(f'\n>>> Exit by user', color='yellow')
21
+ else:
22
+ try:
23
+ dtl = DevToolsLoader(args.json_path, args.output_path, args.clean)
24
+ dtl.run()
23
25
 
24
- except ValueError as e:
25
- DebugLog.log(f'\n>>> Value error: {e}', color='red')
26
+ except KeyboardInterrupt:
27
+ DebugLog.log(f'\n>>> Exit by user', color='yellow')
26
28
 
27
- except RuntimeError as e:
28
- DebugLog.log(f'\n>>> Runtime error: {e}', color='red')
29
+ except ValueError as e:
30
+ DebugLog.log(f'\n>>> Value error: {e}', color='red')
29
31
 
30
- finally:
31
- pass
32
+ except RuntimeError as e:
33
+ DebugLog.log(f'\n>>> Runtime error: {e}', color='red')
34
+
35
+ finally:
36
+ pass
@@ -135,6 +135,50 @@ class DevToolsLoader:
135
135
  self.__clean = clean
136
136
 
137
137
 
138
+ @staticmethod
139
+ def create_template(json_path: Path) -> None:
140
+ config_template = {
141
+ 'version': '0.1.0',
142
+ 'targets': [
143
+ {
144
+ 'type': 'python',
145
+ 'platform': 'win_amd64',
146
+ 'version': '3.12.0',
147
+ 'installer': "load",
148
+ 'packages': [
149
+ {
150
+ 'name': 'compiledb',
151
+ 'version': '0.10.6'
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ 'type': 'vscode',
157
+ 'platform': 'win32-x64',
158
+ 'version': '1.96.0',
159
+ 'installer': "load",
160
+ 'extensions': [
161
+ {
162
+ 'uid': 'ms-vscode.cpptools',
163
+ 'version': 'latest'
164
+ }
165
+ ]
166
+ }
167
+ ]
168
+ }
169
+
170
+ if json_path:
171
+ json_path = Path(json_path)
172
+ if not json_path.parent.exists():
173
+ Path.mkdir(json_path.parent, parents=True)
174
+ with open(json_path, 'w', encoding='utf-8') as f:
175
+ json.dump(config_template, f, indent=4)
176
+ f.write('\n')
177
+ DebugLog.log(f'>>> Create config template \'{json_path}\'', color='bright_cyan')
178
+ else:
179
+ raise ValueError(f'json path required parameter')
180
+
181
+
138
182
  @staticmethod
139
183
  def __ver_2_tuple(ver_mmpb: str) -> Tuple[int]:
140
184
  ver_mmp = ver_mmpb.split('-')[0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dev_tools_loader
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Development tools loader
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://gitlab.com/karma_electronics/desktop/dev_tools_loader
@@ -51,6 +51,7 @@ dev_tools_loader -j path/to/config.json
51
51
  - **`-j`, `--json-path` *`<json_config_path>`*** **(required)** Specifies the path to the JSON configuration file that defines download targets.
52
52
  - **`-o`, `--output-path` *`<output_dir>`*** Sets the output directory where downloaded files will be saved.
53
53
  - **`-c`, `--clean`** If specified, deletes files in the target output directory before starting the download process.
54
+ - **`-t`, `--template`** Create JSON config template (json-path required).
54
55
  - **`-h`, `--help`** Displays the help message with a summary of all available options and exits.
55
56
  - **`--version`** Prints the current version of the `dev-tools-loader` package and exits.
56
57
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dev_tools_loader"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "Development tools loader"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6"
@@ -4,7 +4,7 @@ from pathlib import Path
4
4
  from unittest.mock import patch
5
5
 
6
6
  from dev_tools_loader.dev_tools_loader import DevToolsLoader
7
- from dev_tools_loader.cli import main
7
+ from dev_tools_loader.cli import main as cli_main
8
8
 
9
9
 
10
10
  @pytest.fixture
@@ -76,7 +76,7 @@ def test_cli_help():
76
76
  print()
77
77
  with patch('sys.argv', ['dev_tools_loader', '-h']):
78
78
  with pytest.raises(SystemExit):
79
- main()
79
+ cli_main()
80
80
 
81
81
 
82
82
  @pytest.mark.fast
@@ -84,7 +84,7 @@ def test_cli_version():
84
84
  print()
85
85
  with patch('sys.argv', ['dev_tools_loader', '--version']):
86
86
  with pytest.raises(SystemExit):
87
- main()
87
+ cli_main()
88
88
 
89
89
 
90
90
  @pytest.mark.fast
@@ -92,7 +92,17 @@ def test_cli_invalid_config():
92
92
  print()
93
93
  with patch('sys.argv', ['dev_tools_loader']):
94
94
  with pytest.raises(SystemExit):
95
- main()
95
+ cli_main()
96
+
97
+
98
+ @pytest.mark.fast
99
+ def test_cli_config_template(tmp_path):
100
+ print()
101
+ config_path = tmp_path / Path('dir/config.json')
102
+ with patch('sys.argv', ['dev_tools_loader', '-j', str(config_path), '-t']):
103
+ cli_main()
104
+ with patch('sys.argv', ['dev_tools_loader', '-j', str(config_path), '-o', str(tmp_path)]):
105
+ cli_main()
96
106
 
97
107
 
98
108
  @pytest.mark.fast
@@ -100,7 +110,7 @@ def test_config_example(tmp_path):
100
110
  print()
101
111
  config_path = Path(__file__).parent / Path('data/config_example.json')
102
112
  with patch('sys.argv', ['dev_tools_loader', '-j', str(config_path), '-o', str(tmp_path)]):
103
- main()
113
+ cli_main()
104
114
 
105
115
 
106
116
  @pytest.mark.parametrize('platform', DevToolsLoader.PYTHON_PLATFORMS)