|
45 | 45 | RELATIONSHIP_TYPE_AAS_SUPL = "http://admin-shell.io/aasx/relationships/aas-suppl" |
46 | 46 |
|
47 | 47 |
|
48 | | -class FailsafeConfigurable: |
49 | | - """ |
50 | | - A base class for enabling or disabling failsafe behavior in readers, writers, |
51 | | - or other components that perform parsing or serialization. |
52 | | -
|
53 | | - This class provides a standard mechanism to configure and access a `failsafe` flag |
54 | | - that can be used to control whether errors should raise exceptions or be handled |
55 | | - more leniently (e.g., logged and skipped). |
56 | | -
|
57 | | - Subclasses can use the `failsafe` attribute directly or call `set_failsafe()` to update it. |
58 | | -
|
59 | | - :param failsafe: If ``True``, operate in failsafe mode by suppressing exceptions and logging errors instead. |
60 | | - If ``False``, raise exceptions on critical issues. |
61 | | - """ |
62 | | - |
63 | | - def __init__(self, failsafe: bool = True): |
64 | | - """ |
65 | | - Initialize the failsafe configuration. |
66 | | -
|
67 | | - :param failsafe: Initial value for the failsafe behavior. |
68 | | - """ |
69 | | - self.failsafe = failsafe |
70 | | - |
71 | | - def set_failsafe(self, enabled: bool): |
72 | | - """ |
73 | | - Enable or disable failsafe behavior. |
74 | | -
|
75 | | - :param enabled: If ``True``, enables failsafe mode. If ``False``, disables it. |
76 | | - """ |
77 | | - self.failsafe = enabled |
78 | | - |
79 | | - |
80 | | -class AASXReader(FailsafeConfigurable): |
| 48 | +class AASXReader(): |
81 | 49 | """ |
82 | 50 | An AASXReader wraps an existing AASX package file to allow reading its contents and metadata. |
83 | 51 |
|
@@ -106,7 +74,7 @@ def __init__(self, file: Union[os.PathLike, str, IO], failsafe: bool = True): |
106 | 74 | :raises FileNotFoundError: If the file does not exist |
107 | 75 | :raises ValueError: If the file is not a valid OPC zip package |
108 | 76 | """ |
109 | | - super().__init__(failsafe) |
| 77 | + self.failsafe = failsafe |
110 | 78 | try: |
111 | 79 | logger.debug("Opening {} as AASX pacakge for reading ...".format(file)) |
112 | 80 | self.reader = pyecma376_2.ZipPackageReader(file) |
@@ -310,7 +278,7 @@ def _collect_supplementary_files(self, part_name: str, submodel: model.Submodel, |
310 | 278 | element.value = final_name |
311 | 279 |
|
312 | 280 |
|
313 | | -class AASXWriter(FailsafeConfigurable): |
| 281 | +class AASXWriter(): |
314 | 282 | """ |
315 | 283 | An AASXWriter wraps a new AASX package file to write its contents to it piece by piece. |
316 | 284 |
|
@@ -352,7 +320,7 @@ def __init__(self, file: Union[os.PathLike, str, IO], failsafe: bool = True): |
352 | 320 | logged instead of causing exceptions. Defect objects are skipped. |
353 | 321 | :param file: filename, path, or binary file handle opened for writing |
354 | 322 | """ |
355 | | - super().__init__(failsafe) |
| 323 | + self.failsafe = failsafe |
356 | 324 | # names of aas-spec parts, used by `_write_aasx_origin_relationships()` |
357 | 325 | self._aas_part_names: List[str] = [] |
358 | 326 | # name of the thumbnail part (if any) |
@@ -431,7 +399,7 @@ def write_aas(self, |
431 | 399 | f"{aas!r}") |
432 | 400 | except (KeyError, TypeError) as e: |
433 | 401 | if self.failsafe: |
434 | | - logger.warning(f"Skipping AAS {aas_id}: {e}") |
| 402 | + logger.error(f"Skipping AAS {aas_id}: {e}") |
435 | 403 | continue |
436 | 404 | else: |
437 | 405 | raise |
|
0 commit comments