specware 1.3.0__tar.gz → 1.3.2__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: specware
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Provides utilities to specify software.
5
5
  Keywords: certification,documentation,markdown,qualification,requirements-management,traceability
6
6
  Author: The specware Authors
@@ -4,7 +4,7 @@
4
4
 
5
5
  [project]
6
6
  name = "specware"
7
- version = "1.3.0"
7
+ version = "1.3.2"
8
8
  description = "Provides utilities to specify software."
9
9
  authors = [
10
10
  {name = "The specware Authors", email = "specthings@embedded-brains.de"}
@@ -32,7 +32,8 @@ import os
32
32
  import sys
33
33
 
34
34
  from specitems import (Item)
35
- from specware import (open_tree, get_items_by_type_map,
35
+ from specware import (exit_on_config_file_error, open_tree,
36
+ get_items_by_type_map,
36
37
  get_benchmark_and_test_suite_items,
37
38
  get_interface_and_requirement_items,
38
39
  get_validation_items)
@@ -60,6 +61,7 @@ def _process_item_data(cwd: str, file_to_item: dict[str, list[str]],
60
61
  os.path.normpath(os.path.relpath(item.file, cwd)))
61
62
 
62
63
 
64
+ @exit_on_config_file_error
63
65
  def clifind(argv: list[str] = sys.argv) -> None:
64
66
  """ Find the items related to generated files. """
65
67
  cwd = os.getcwd()
@@ -35,11 +35,12 @@ from specitems import (COL_SPAN, CommonMarkContent, Item, ItemCache,
35
35
  ItemGetValueContext, ItemMapper, Link, MarkdownContent,
36
36
  ROW_SPAN, SphinxContent, TextContent, yield_tasks)
37
37
 
38
- from specware import (open_tree, augment_with_test_case_links,
39
- augment_with_test_links, gather_api_items,
40
- gather_build_files, get_register_bits_run,
41
- get_register_member_name, recursive_is_enabled,
42
- Transition, TransitionMap, validate)
38
+ from specware import (exit_on_config_file_error, open_tree,
39
+ augment_with_test_case_links, augment_with_test_links,
40
+ gather_api_items, gather_build_files,
41
+ get_register_bits_run, get_register_member_name,
42
+ recursive_is_enabled, Transition, TransitionMap,
43
+ validate)
43
44
 
44
45
  _DOC_FORMAT = {
45
46
  "commonmark": CommonMarkContent,
@@ -656,6 +657,7 @@ def _parse_args(argv: list[str]) -> argparse.Namespace:
656
657
  return parser.parse_args(argv[1:])
657
658
 
658
659
 
660
+ @exit_on_config_file_error
659
661
  def cliview(argv: list[str] = sys.argv):
660
662
  """ View the specification. """
661
663
 
@@ -26,16 +26,20 @@
26
26
 
27
27
  import argparse
28
28
  import contextlib
29
+ import functools
29
30
  import logging
30
31
  import os
31
32
  from pathlib import Path
32
33
  import subprocess
33
- from typing import Any, Callable, Iterator, NamedTuple, Optional, Union
34
+ import sys
35
+ from typing import (Any, Callable, Iterator, NamedTuple, Optional, TypeVar,
36
+ Union, cast)
34
37
 
35
38
  from specitems import (ClangFormatter, IsEnabled, Item, ItemCache,
36
39
  ItemCacheConfig, ItemDataByUID, SpecTypeProvider,
37
- create_config, find_config_file, load_config_item,
38
- monitor_logging, pickle_load_data_by_uid)
40
+ create_config, create_type_provider, find_config_file,
41
+ load_config_item, monitor_logging,
42
+ pickle_load_data_by_uid)
39
43
 
40
44
 
41
45
  class ClangFormatError(Exception):
@@ -156,7 +160,7 @@ def run_with_clang_formatter(
156
160
  with monitor_logging() as monitor:
157
161
  try:
158
162
  run(create_clang_formatter(args))
159
- except ClangFormatError as err:
163
+ except (ClangFormatError, ConfigFileError) as err:
160
164
  logging.error("%s", err)
161
165
  except subprocess.CalledProcessError as err:
162
166
  log_clang_format_failure(err)
@@ -214,6 +218,35 @@ def run_command(args: list[str],
214
218
  return actual_status
215
219
 
216
220
 
221
+ class ConfigFileError(Exception):
222
+ """ Indicates that the configuration file is missing or invalid. """
223
+
224
+
225
+ _Function = TypeVar("_Function", bound=Callable[..., Any])
226
+
227
+
228
+ def exit_on_config_file_error(function: _Function) -> _Function:
229
+ """
230
+ Make the command exit with a message where its configuration file is
231
+ missing or invalid.
232
+
233
+ Args:
234
+ function: The command.
235
+
236
+ Returns:
237
+ The command which exits with status 1 on a :class:`ConfigFileError`.
238
+ """
239
+
240
+ @functools.wraps(function)
241
+ def _run(*args: Any, **kwargs: Any) -> Any:
242
+ try:
243
+ return function(*args, **kwargs)
244
+ except ConfigFileError as err:
245
+ sys.exit(str(err))
246
+
247
+ return cast(_Function, _run)
248
+
249
+
217
250
  class Tree(NamedTuple):
218
251
  """ Is the tree of a configuration file. """
219
252
 
@@ -243,11 +276,20 @@ def open_tree(config_file: Optional[str],
243
276
  is_item_enabled: The optional enabled status of an item.
244
277
  enabled_set: The optional enabled set of the item cache.
245
278
 
279
+ The configuration is verified with the types of every installed package,
280
+ so it may state tasks of the tools of another package.
281
+
246
282
  Yields:
247
283
  The tree.
284
+
285
+ Raises:
286
+ ConfigFileError: The configuration file is missing or invalid.
248
287
  """
288
+ try:
289
+ config = load_config_item(config_file, create_type_provider())
290
+ except (FileNotFoundError, ValueError) as err:
291
+ raise ConfigFileError(str(err)) from err
249
292
  type_provider = SpecWareTypeProvider({})
250
- config = load_config_item(config_file, type_provider)
251
293
  directory = str(find_config_file(config_file).parent)
252
294
  with contextlib.chdir(directory):
253
295
  item_cache_config = create_config(config["item-cache"],
File without changes
File without changes
File without changes
File without changes