forked from OpenCyphal/pydsdl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update the development-related dependencies. - Demote Python v3.6 and v3.7 to minimally supported versions (no linting, no coverage). - Fix OpenCyphal#84. `os.path` is no longer used, and dependency on the text representations of paths is minimized. - Refactor the test suite to eliminate the global state and simplify the internal APIs. - The library now logs a warning when it encounters a `*.uavcan` file, suggesting renaming it to `*.dsdl`. See https://forum.opencyphal.org/t/uavcan-file-extension/438/8. There are no plans to remove support for `*.uavcan` but it is desirable to push users towards consistency. - Bump the minor version.
- Loading branch information
1 parent
fc0715c
commit 7f0270c
Showing
11 changed files
with
569 additions
and
553 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
# This software is distributed under the terms of the MIT License. | ||
# Author: Pavel Kirienko <[email protected]> | ||
|
||
import os | ||
import time | ||
from typing import Iterable, Callable, Optional, List | ||
import logging | ||
|
@@ -41,21 +40,14 @@ def __init__(self, file_path: Path, root_namespace_path: Path): | |
self._text = str(f.read()) | ||
|
||
# Checking the sanity of the root directory path - can't contain separators | ||
if CompositeType.NAME_COMPONENT_SEPARATOR in os.path.split(self._root_namespace_path)[-1]: | ||
if CompositeType.NAME_COMPONENT_SEPARATOR in self._root_namespace_path.name: | ||
raise FileNameFormatError("Invalid namespace name", path=self._root_namespace_path) | ||
|
||
# Determining the relative path within the root namespace directory | ||
relative_path = str( | ||
os.path.join( | ||
os.path.split(self._root_namespace_path)[-1], | ||
self._file_path.relative_to(self._root_namespace_path), | ||
) | ||
) | ||
|
||
relative_directory, basename = [str(x) for x in os.path.split(relative_path)] # type: str, str | ||
relative_path = self._root_namespace_path.name / self._file_path.relative_to(self._root_namespace_path) | ||
|
||
# Parsing the basename, e.g., 434.GetTransportStatistics.0.1.dsdl | ||
basename_components = basename.split(".")[:-1] | ||
basename_components = relative_path.name.split(".")[:-1] | ||
str_fixed_port_id: Optional[str] = None | ||
if len(basename_components) == 4: | ||
str_fixed_port_id, short_name, str_major_version, str_minor_version = basename_components | ||
|
@@ -86,11 +78,10 @@ def __init__(self, file_path: Path, root_namespace_path: Path): | |
raise FileNameFormatError("Could not parse the version numbers", path=self._file_path) from None | ||
|
||
# Finally, constructing the name | ||
namespace_components = list(relative_directory.strip(os.sep).split(os.sep)) | ||
namespace_components = list(relative_path.parent.parts) | ||
for nc in namespace_components: | ||
if CompositeType.NAME_COMPONENT_SEPARATOR in nc: | ||
raise FileNameFormatError(f"Invalid name for namespace component: {nc!r}", path=self._file_path) | ||
|
||
self._name: str = CompositeType.NAME_COMPONENT_SEPARATOR.join(namespace_components + [str(short_name)]) | ||
|
||
self._cached_type: Optional[CompositeType] = None | ||
|
Oops, something went wrong.