specitems 1.7.4__tar.gz → 1.7.6__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.
- {specitems-1.7.4 → specitems-1.7.6}/PKG-INFO +1 -1
- {specitems-1.7.4 → specitems-1.7.6}/pyproject.toml +1 -1
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/__init__.py +2 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/itemmapper.py +23 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/items.py +19 -8
- {specitems-1.7.4 → specitems-1.7.6}/README.md +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/cite.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/clangformat.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/clihash.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/clipickle.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/clispecdoc.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/clitypeview.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/cliutil.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/cliverify.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/cliyamlquery.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/content.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/contentcommonmark.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/contentmarkdown.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/contentsphinx.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/contenttext.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/copyrights.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/getvaluesubprocess.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/glossary.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/hashutil.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/licenseinfo.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/py.typed +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/spdx.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/spec.pickle +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/specconfig.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/specdoc.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/specformatter.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/specverify.py +0 -0
- {specitems-1.7.4 → specitems-1.7.6}/src/specitems/subprocessaction.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: specitems
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.6
|
|
4
4
|
Summary: Provides interfaces to work with specification items.
|
|
5
5
|
Keywords: certification,documentation,markdown,qualification,requirements-management,traceability
|
|
6
6
|
Author: The specitems Authors
|
|
@@ -135,6 +135,7 @@ from .itemmapper import (
|
|
|
135
135
|
ItemValueProvider,
|
|
136
136
|
SubstitutionError,
|
|
137
137
|
from_clang_variables,
|
|
138
|
+
get_bool_arg,
|
|
138
139
|
get_value_default,
|
|
139
140
|
to_at_variables,
|
|
140
141
|
to_clang_variables,
|
|
@@ -239,6 +240,7 @@ __all__ = [
|
|
|
239
240
|
"generate_glossary",
|
|
240
241
|
"generate_specification_documentation",
|
|
241
242
|
"get_arguments",
|
|
243
|
+
"get_bool_arg",
|
|
242
244
|
"get_item_cache_arguments",
|
|
243
245
|
"get_license_list_version",
|
|
244
246
|
"get_reference",
|
|
@@ -344,6 +344,24 @@ def unpack_args(
|
|
|
344
344
|
return args, kwargs
|
|
345
345
|
|
|
346
346
|
|
|
347
|
+
def get_bool_arg(kwargs: dict[str, str],
|
|
348
|
+
name: str,
|
|
349
|
+
default: bool = False) -> bool:
|
|
350
|
+
"""
|
|
351
|
+
Get the boolean value of the keyword argument by name.
|
|
352
|
+
|
|
353
|
+
The value of the argument shall be "0" or "1". If the argument is not
|
|
354
|
+
present, then return the default value.
|
|
355
|
+
"""
|
|
356
|
+
value = kwargs.get(name)
|
|
357
|
+
if value is None:
|
|
358
|
+
return default
|
|
359
|
+
if value not in ("0", "1"):
|
|
360
|
+
raise ValueError(f"argument '{name}' has the value '{value}', "
|
|
361
|
+
"expected '0' or '1'")
|
|
362
|
+
return value == "1"
|
|
363
|
+
|
|
364
|
+
|
|
347
365
|
def _identity(value: str) -> str:
|
|
348
366
|
return value
|
|
349
367
|
|
|
@@ -372,6 +390,11 @@ class ItemGetValueContext:
|
|
|
372
390
|
return kwargs[name]
|
|
373
391
|
return kwargs.get(name, value)
|
|
374
392
|
|
|
393
|
+
def arg_bool(self, name: str, default: bool = False) -> bool:
|
|
394
|
+
""" Get the boolean argument value by name. """
|
|
395
|
+
_, kwargs = self.unpack_args_dict()
|
|
396
|
+
return get_bool_arg(kwargs, name, default)
|
|
397
|
+
|
|
375
398
|
def unpack_args_list(self) -> list[str]:
|
|
376
399
|
""" Unpack the context arguments to a list. """
|
|
377
400
|
if self.args is None:
|
|
@@ -37,8 +37,8 @@ import logging
|
|
|
37
37
|
import os
|
|
38
38
|
import pickle
|
|
39
39
|
import re
|
|
40
|
+
import secrets
|
|
40
41
|
import stat
|
|
41
|
-
import tempfile
|
|
42
42
|
from typing import (Any, Callable, Collection, Iterable, Iterator, Match,
|
|
43
43
|
Optional, Union)
|
|
44
44
|
import json
|
|
@@ -753,6 +753,18 @@ def _json_load_data_by_uid(data_by_uid: ItemDataByUID, _cache_dir: str,
|
|
|
753
753
|
path_2)
|
|
754
754
|
|
|
755
755
|
|
|
756
|
+
def _create_temporary_file(directory: str, suffix: str) -> tuple[int, str]:
|
|
757
|
+
while True:
|
|
758
|
+
path = os.path.join(directory, f".tmp-{secrets.token_hex(8)}{suffix}")
|
|
759
|
+
try:
|
|
760
|
+
# The umask applies to this mode, as for a file which open()
|
|
761
|
+
# creates.
|
|
762
|
+
return os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL,
|
|
763
|
+
0o666), path
|
|
764
|
+
except FileExistsError:
|
|
765
|
+
continue
|
|
766
|
+
|
|
767
|
+
|
|
756
768
|
def atomic_dump_to_file(path: str, data: Any,
|
|
757
769
|
dumper: Callable[[Any], str | bytes]) -> None:
|
|
758
770
|
"""
|
|
@@ -765,6 +777,9 @@ def atomic_dump_to_file(path: str, data: Any,
|
|
|
765
777
|
as the path. The temporary file is then renamed to the path. This way, a
|
|
766
778
|
failure while producing the content cannot truncate or corrupt an already
|
|
767
779
|
existing file at the path.
|
|
780
|
+
|
|
781
|
+
A file which exists keeps its permissions. A new file gets the
|
|
782
|
+
permissions which the umask leaves of 0o666.
|
|
768
783
|
"""
|
|
769
784
|
dumped = dumper(data)
|
|
770
785
|
encoding: Optional[str] = None
|
|
@@ -776,13 +791,9 @@ def atomic_dump_to_file(path: str, data: Any,
|
|
|
776
791
|
directory = os.path.dirname(os.path.abspath(path))
|
|
777
792
|
tmp_path: Optional[str] = None
|
|
778
793
|
try:
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
prefix=".tmp-",
|
|
783
|
-
suffix=os.path.basename(path),
|
|
784
|
-
delete=False) as out:
|
|
785
|
-
tmp_path = out.name
|
|
794
|
+
fd, tmp_path = _create_temporary_file(directory,
|
|
795
|
+
os.path.basename(path))
|
|
796
|
+
with os.fdopen(fd, mode, encoding=encoding) as out:
|
|
786
797
|
with suppress(OSError):
|
|
787
798
|
os.chmod(tmp_path, stat.S_IMODE(os.stat(path).st_mode))
|
|
788
799
|
out.write(dumped)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|