Skip to content

Commit

Permalink
Update baselib, add LICENSE, use Optional (#67)
Browse files Browse the repository at this point in the history
Signed-off-by: hoangtungdinh <11166240+hoangtungdinh@users.noreply.github.com>
Co-authored-by: hoangtungdinh <11166240+hoangtungdinh@users.noreply.github.com>
  • Loading branch information
hoangtungdinh and hoangtungdinh committed Oct 7, 2024
1 parent bb5165f commit 8702779
Show file tree
Hide file tree
Showing 8 changed files with 413 additions and 34 deletions.
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ asam-qc-openscenarioxml can be installed using pip or from source.

asam-qc-openscenarioxml can be installed using pip.

**From PyPi**

```bash
pip install asam-qc-openscenarioxml
```

**From GitHub repository**

```bash
pip install asam-qc-openscenarioxml@git+https://github.com/asam-ev/qc-openscenarioxml@main
```

**Note:** The above command will install `asam-qc-openscenarioxml` from the `main` branch. If you want to install `asam-qc-openscenarioxml` from another branch or tag, replace `@main` with the desired branch or tag. It is also possible to install from a local directory.
The above command will install `asam-qc-openscenarioxml` from the `main` branch. If you want to install `asam-qc-openscenarioxml` from another branch or tag, replace `@main` with the desired branch or tag.

**From a local repository**

```bash
pip install /home/user/qc-openscenarioxml
Expand Down
28 changes: 12 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ packages = [

[tool.poetry.dependencies]
python = "^3.10"
asam-qc-baselib = {git = "https://github.com/asam-ev/qc-baselib-py.git", rev = "develop"}
asam-qc-baselib = "^1.0.0rc1"
lxml = "^5.2.2"

[tool.poetry.group.dev.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions qc_openscenario/checks/data_type_checker/allowed_operators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from dataclasses import dataclass
from typing import Union
from typing import Union, Optional

from lxml import etree

Expand Down Expand Up @@ -47,7 +47,7 @@ class ExpressionMember(enum.IntEnum):
@dataclass
class QueueNode:
element: etree._ElementTree
xpath: Union[str, None]
xpath: Optional[str]


@dataclass
Expand Down
8 changes: 4 additions & 4 deletions qc_openscenario/checks/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from lxml import etree
from typing import Union
from typing import Optional
from enum import Enum

from qc_baselib import Configuration, Result
Expand All @@ -9,11 +9,11 @@
@dataclass
class CheckerData:
xml_file_path: str
input_file_xml_root: Union[None, etree._ElementTree]
input_file_xml_root: Optional[etree._ElementTree]
config: Configuration
result: Result
schema_version: Union[None, str]
xodr_root: Union[None, etree._ElementTree]
schema_version: Optional[str]
xodr_root: Optional[etree._ElementTree]


class AttributeType(Enum):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging

from dataclasses import dataclass
from typing import Union
from typing import Optional

from lxml import etree

from qc_baselib import IssueSeverity, StatusType
from qc_baselib import IssueSeverity

from qc_openscenario import constants
from qc_openscenario.checks import utils, models
from qc_openscenario.checks import models

from qc_openscenario import basic_preconditions
from collections import deque, defaultdict
Expand All @@ -22,7 +22,7 @@
@dataclass
class QueueNode:
element: etree._ElementTree
parent_xpath: Union[str, None]
parent_xpath: Optional[str]


@dataclass
Expand Down
12 changes: 6 additions & 6 deletions qc_openscenario/checks/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from lxml import etree
from io import BytesIO
from typing import Union
from typing import Union, Optional
from qc_openscenario.checks import models
import re
import logging
Expand All @@ -17,7 +17,7 @@ def to_float(s):
return None


def get_root_without_default_namespace(path: str) -> Union[None, etree._ElementTree]:
def get_root_without_default_namespace(path: str) -> Optional[etree._ElementTree]:
if not os.path.exists(path):
return None

Expand All @@ -30,7 +30,7 @@ def get_root_without_default_namespace(path: str) -> Union[None, etree._ElementT
return etree.parse(BytesIO(xml_string.encode()))


def get_standard_schema_version(root: etree._ElementTree) -> Union[str, None]:
def get_standard_schema_version(root: etree._ElementTree) -> Optional[str]:
header = root.find("FileHeader")
if header is None:
return None
Expand Down Expand Up @@ -107,15 +107,15 @@ def get_parameter_value_from_node(

def get_xodr_road_network(
input_file_path: str, tree: etree._ElementTree
) -> Union[etree._ElementTree, None]:
) -> Optional[etree._ElementTree]:
"""Get parsed xodr tree indicated in the RoadNetwork/LogicFile node of the input tree
Args:
tree (etree._ElementTree): xml document tree that refers to a xodr file
Returns:
Union[etree._ElementTree, None]: the parsed road network tree.
None if the specified nodes in the root or the road network file are not found
Optional[etree._ElementTree]: the parsed road network tree.
None if the specified nodes in the root or the road network file are not found
"""

road_network = tree.find("RoadNetwork")
Expand Down

0 comments on commit 8702779

Please sign in to comment.