diff --git a/sros2/package.xml b/sros2/package.xml
index e15296fe..429e520d 100644
--- a/sros2/package.xml
+++ b/sros2/package.xml
@@ -10,13 +10,13 @@
Morgan Quigley
Mikael Arguedas
- rclpy
- ros2cli
-
ament_index_python
- python3-lxml
+ python3-argcomplete
python3-cryptography
python3-importlib-resources
+ python3-lxml
+ rclpy
+ ros2cli
ament_copyright
ament_flake8
diff --git a/sros2/sros2/api/_artifact_generation.py b/sros2/sros2/api/_artifact_generation.py
index 7a23bb09..80746ce6 100644
--- a/sros2/sros2/api/_artifact_generation.py
+++ b/sros2/sros2/api/_artifact_generation.py
@@ -13,7 +13,7 @@
# limitations under the License.
import pathlib
-from typing import List
+from typing import List, Optional
from sros2 import _utilities, keystore
from sros2.policy import load_policy
@@ -22,7 +22,7 @@
def generate_artifacts(
- keystore_path: pathlib.Path = None,
+ keystore_path: Optional[pathlib.Path] = None,
identity_names: List[str] = [],
policy_files: List[pathlib.Path] = []) -> None:
if keystore_path is None:
diff --git a/sros2/sros2/policy/__init__.py b/sros2/sros2/policy/__init__.py
index bd27acd6..0f8c8189 100644
--- a/sros2/sros2/policy/__init__.py
+++ b/sros2/sros2/policy/__init__.py
@@ -27,37 +27,39 @@
POLICY_VERSION = '0.2.0'
+def _get_path(template, name):
+ if hasattr(importlib_resources, 'files'):
+ return importlib_resources.files(template).joinpath(name)
+ else:
+ with importlib_resources.path(template, name) as path:
+ return path
+
+
def get_policy_default(name: str) -> pathlib.Path:
- with importlib_resources.path('sros2.policy.defaults', name) as path:
- return path
+ return _get_path('sros2.policy.defaults', name)
def get_policy_schema(name: str) -> pathlib.Path:
- with importlib_resources.path('sros2.policy.schemas', name) as path:
- return path
+ return _get_path('sros2.policy.schemas', name)
def get_policy_template(name: str) -> pathlib.Path:
- with importlib_resources.path('sros2.policy.templates', name) as path:
- return path
+ return _get_path('sros2.policy.templates', name)
def get_transport_default(transport: str, name: str) -> pathlib.Path:
module = 'sros2.policy.defaults.' + transport
- with importlib_resources.path(module, name) as path:
- return path
+ return _get_path(module, name)
def get_transport_schema(transport: str, name: str) -> pathlib.Path:
module = 'sros2.policy.schemas.' + transport
- with importlib_resources.path(module, name) as path:
- return path
+ return _get_path(module, name)
def get_transport_template(transport: str, name: str) -> pathlib.Path:
module = 'sros2.policy.templates.' + transport
- with importlib_resources.path(module, name) as path:
- return path
+ return _get_path(module, name)
def load_policy(policy_file_path: pathlib.Path) -> etree.ElementTree:
diff --git a/sros2/sros2/verb/create_enclave.py b/sros2/sros2/verb/create_enclave.py
index 5462fa26..b2320d8e 100644
--- a/sros2/sros2/verb/create_enclave.py
+++ b/sros2/sros2/verb/create_enclave.py
@@ -16,11 +16,7 @@
import sys
import warnings
-try:
- from argcomplete.completers import DirectoriesCompleter
-except ImportError:
- def DirectoriesCompleter():
- return None
+from argcomplete.completers import DirectoriesCompleter
import sros2.keystore
from sros2.verb import VerbExtension
diff --git a/sros2/sros2/verb/create_keystore.py b/sros2/sros2/verb/create_keystore.py
index 15206f71..82744a32 100644
--- a/sros2/sros2/verb/create_keystore.py
+++ b/sros2/sros2/verb/create_keystore.py
@@ -15,11 +15,7 @@
import pathlib
import sys
-try:
- from argcomplete.completers import DirectoriesCompleter
-except ImportError:
- def DirectoriesCompleter():
- return None
+from argcomplete.completers import DirectoriesCompleter
import sros2.errors
import sros2.keystore
diff --git a/sros2/sros2/verb/create_permission.py b/sros2/sros2/verb/create_permission.py
index 79d3c2e7..5bde9ea1 100644
--- a/sros2/sros2/verb/create_permission.py
+++ b/sros2/sros2/verb/create_permission.py
@@ -15,16 +15,8 @@
import pathlib
import sys
-try:
- from argcomplete.completers import DirectoriesCompleter
-except ImportError:
- def DirectoriesCompleter():
- return None
-try:
- from argcomplete.completers import FilesCompleter
-except ImportError:
- def FilesCompleter(*, allowednames, directories):
- return None
+from argcomplete.completers import DirectoriesCompleter
+from argcomplete.completers import FilesCompleter
import sros2.keystore
from sros2.verb import VerbExtension
diff --git a/sros2/sros2/verb/generate_artifacts.py b/sros2/sros2/verb/generate_artifacts.py
index 05674ad9..098d342a 100644
--- a/sros2/sros2/verb/generate_artifacts.py
+++ b/sros2/sros2/verb/generate_artifacts.py
@@ -15,16 +15,8 @@
import pathlib
import sys
-try:
- from argcomplete.completers import DirectoriesCompleter
-except ImportError:
- def DirectoriesCompleter():
- return None
-try:
- from argcomplete.completers import FilesCompleter
-except ImportError:
- def FilesCompleter(*, allowednames, directories):
- return None
+from argcomplete.completers import DirectoriesCompleter
+from argcomplete.completers import FilesCompleter
from sros2.api import _artifact_generation
import sros2.errors
diff --git a/sros2/sros2/verb/generate_policy.py b/sros2/sros2/verb/generate_policy.py
index 64112e05..4b2bcfc0 100644
--- a/sros2/sros2/verb/generate_policy.py
+++ b/sros2/sros2/verb/generate_policy.py
@@ -16,16 +16,7 @@
import pathlib
import sys
-try:
- from argcomplete.completers import DirectoriesCompleter
-except ImportError:
- def DirectoriesCompleter():
- return None
-try:
- from argcomplete.completers import FilesCompleter
-except ImportError:
- def FilesCompleter(*, allowednames, directories):
- return None
+from argcomplete.completers import FilesCompleter
from lxml import etree
diff --git a/sros2/sros2/verb/list_enclaves.py b/sros2/sros2/verb/list_enclaves.py
index ba1fff9a..6e733092 100644
--- a/sros2/sros2/verb/list_enclaves.py
+++ b/sros2/sros2/verb/list_enclaves.py
@@ -12,16 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-try:
- from argcomplete.completers import DirectoriesCompleter
-except ImportError:
- def DirectoriesCompleter():
- return None
-
import pathlib
import sys
import warnings
+from argcomplete.completers import DirectoriesCompleter
+
import sros2.keystore
from sros2.verb import VerbExtension