Skip to content

Commit

Permalink
Tidy directory and file names
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schleemilch <[email protected]>
  • Loading branch information
sschleemilch authored and erikbosch committed Oct 23, 2024
1 parent 9355620 commit 92d4873
Show file tree
Hide file tree
Showing 46 changed files with 131 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
poetry run flake8 src tests contrib
- name: Run tests
run: |
poetry run pytest --cov=vss_tools --cov-report=term-missing --cov-fail-under=90
poetry run pytest --cov=vss_tools --cov-report=term-missing --cov-fail-under=88
- name: Test Binary Go Parser
run: |
cd binary/go_parser
Expand Down
4 changes: 2 additions & 2 deletions docs/vspec.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ vspec export json --vspec spec/VehicleSignalSpecification.vspec --output vss.jso
/Users/Bar/workspace/vehicle_signal_specification/spec/units.yaml
INFO Loading vspec from spec/VehicleSignalSpecification.vspec... utils.py:81
[16:40:04] INFO Check type usage __init__.py:117
INFO Generating JSON output... vss2json.py:142
INFO Serializing compact JSON... vss2json.py:148
INFO Generating JSON output... json.py:142
INFO Serializing compact JSON... json.py:148

```
## Exporter docs
Expand Down
2 changes: 1 addition & 1 deletion docs/vspec_arch.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ That means that we can define the cli interface of subcommands in their own file
The main cli entrypoint for `vspec` is defined in [vspec.py](../src/vss_tools/vspec/vspec.py).
There you can also see all the subcommands referenced.
When building a new exporter tool, this is the place that needs to be adapted as well
as creating a new file similar to the other exporters in [vssexporters](../src/vss_tools/vspec/vssexporters).
as creating a new file similar to the other exporters in [exporters](../src/vss_tools/vspec/exporters).

It is also possible to build a complete different script entrypoint and not hook into the current interface.
All cli options can be imported and used via [cli_options.py](../src/vss_tools/vspec/cli_options.py).
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pre-commit = "*"


[tool.poetry.scripts]
vspec = "vss_tools.vspec.cli:cli"
vspec = "vss_tools.cli:cli"

[build-system]
requires = ["poetry-core"]
Expand Down
32 changes: 16 additions & 16 deletions src/vss_tools/vspec/cli.py → src/vss_tools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import rich_click as click

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.lazy_group import LazyGroup
from vss_tools.lazy_group import LazyGroup


@click.group(context_settings={"auto_envvar_prefix": "vss_tools"}, invoke_without_command=True)
Expand All @@ -35,20 +35,20 @@ def cli(ctx: click.Context, log_level: str, log_file: Path):
@cli.group(
cls=LazyGroup,
lazy_subcommands={
"apigear": "vss_tools.vspec.vssexporters.vss2apigear:cli",
"binary": "vss_tools.vspec.vssexporters.vss2binary:cli",
"csv": "vss_tools.vspec.vssexporters.vss2csv:cli",
"ddsidl": "vss_tools.vspec.vssexporters.vss2ddsidl:cli",
"franca": "vss_tools.vspec.vssexporters.vss2franca:cli",
"graphql": "vss_tools.vspec.vssexporters.vss2graphql:cli",
"id": "vss_tools.vspec.vssexporters.vss2id:cli",
"json": "vss_tools.vspec.vssexporters.vss2json:cli",
"jsonschema": "vss_tools.vspec.vssexporters.vss2jsonschema:cli",
"protobuf": "vss_tools.vspec.vssexporters.vss2protobuf:cli",
"yaml": "vss_tools.vspec.vssexporters.vss2yaml:cli",
"tree": "vss_tools.vspec.vssexporters.vss2tree:cli",
"samm": "vss_tools.vspec.vssexporters.vss2samm.vss2samm:cli",
"go": "vss_tools.vspec.vssexporters.vss2go:cli",
"apigear": "vss_tools.exporters.apigear:cli",
"binary": "vss_tools.exporters.binary:cli",
"csv": "vss_tools.exporters.csv:cli",
"ddsidl": "vss_tools.exporters.ddsidl:cli",
"franca": "vss_tools.exporters.franca:cli",
"graphql": "vss_tools.exporters.graphql:cli",
"id": "vss_tools.exporters.id:cli",
"json": "vss_tools.exporters.json:cli",
"jsonschema": "vss_tools.exporters.jsonschema:cli",
"protobuf": "vss_tools.exporters.protobuf:cli",
"yaml": "vss_tools.exporters.yaml:cli",
"tree": "vss_tools.exporters.tree:cli",
"samm": "vss_tools.exporters.samm:cli",
"go": "vss_tools.exporters.go:cli",
},
)
@click.pass_context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import rich_click as click
from rich_click import option

from vss_tools.vspec.model import get_all_model_fields
from vss_tools.model import get_all_model_fields


def validate_attribute(value):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@

import abc
import typing
import yaml
from enum import Enum, Flag, auto
from math import inf
from pathlib import Path

import rich_click as click
import vss_tools.vspec.cli_options as clo
import yaml

from enum import Enum, Flag, auto
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.tree import VSSNode
from vss_tools.vspec.model import VSSDataBranch, VSSDataStruct, VSSDataDatatype
from vss_tools.vspec.datatypes import Datatypes
from vss_tools.vspec.main import get_trees
from pathlib import Path
from math import inf
from vss_tools.datatypes import Datatypes
from vss_tools.main import get_trees
from vss_tools.model import VSSDataBranch, VSSDataDatatype, VSSDataStruct
from vss_tools.tree import VSSNode


class SolutionLayers(Flag):
Expand Down Expand Up @@ -62,7 +63,7 @@ def __init__(self, name: str):
self.variants: typing.List[tuple[str, int | None]] = []


class ApiGearType():
class ApiGearType:
def __init__(self, type: str):
super().__init__()

Expand All @@ -76,7 +77,7 @@ def array(cls, type: str):
return t


class ApiGearProperty():
class ApiGearProperty:
def __init__(self, type: ApiGearType):
super().__init__()

Expand Down Expand Up @@ -234,7 +235,7 @@ def export_node(node: VSSNode, module: ApiGearModule, interface: ApiGearInterfac

def export_data_type_node(node: VSSNode | None, module: ApiGearModule, structure: ApiGearStructure | None = None):
"""This method is used to traverse through the root VSS Data Types node to build
-> ApiGear equivalent string buffer and to serialize it accordingly into a module
-> ApiGear equivalent string buffer and to serialize it accordingly into a module
"""
if node is None:
return
Expand Down Expand Up @@ -271,7 +272,7 @@ def generate_module(directory: Path, module: ApiGearModule, module_name: str, mo
"schema": "apigear.module/1.0",
"name": module_name,
"version": "1.0",
"interfaces": []
"interfaces": [],
}

for interface in module.interfaces:
Expand Down Expand Up @@ -342,15 +343,16 @@ def generate_module(directory: Path, module: ApiGearModule, module_name: str, mo
log.info(f"Module file generated at location: {module_path}")


def generate_solution(directory: Path, module_filename: str, module_name: str,
layers: typing.Dict[SolutionLayers, Path]):
def generate_solution(
directory: Path, module_filename: str, module_name: str, layers: typing.Dict[SolutionLayers, Path]
):
log.debug("Generating solution file")

yaml_dict: typing.Dict[str, typing.Any] = {
"schema": "apigear.solution/1.0",
"name": module_name,
"version": "1.0",
"layers": []
"layers": [],
}
unreal: typing.Dict[str, typing.Any] = {
"name": "unreal",
Expand Down Expand Up @@ -410,10 +412,11 @@ def export_yaml(file_name, content_dict):
)


def export_apigear(directory: Path, root: VSSNode, data_type_tree: VSSNode | None,
layers: typing.Dict[SolutionLayers, Path]):
def export_apigear(
directory: Path, root: VSSNode, data_type_tree: VSSNode | None, layers: typing.Dict[SolutionLayers, Path]
):
"""This method is used to traverse through the root VSS node to build
-> ApiGear equivalent string buffer and to serialize it accordingly into a file
-> ApiGear equivalent string buffer and to serialize it accordingly into a file
"""
module = ApiGearModule()
module_name = root.name
Expand All @@ -423,7 +426,7 @@ def export_apigear(directory: Path, root: VSSNode, data_type_tree: VSSNode | Non
log.debug(f"Module name: {module_name}")
log.debug(f"Module filename: {module_filename}")

if (not layers):
if not layers:
layers = {SolutionLayers.CPP: Path("./cppservice")}
log.warning(f"No layers provided! Defaulting to CPP in {layers[SolutionLayers.CPP]}")

Expand Down Expand Up @@ -512,13 +515,13 @@ def cli(
output_dir.mkdir(exist_ok=True, parents=True)

layers = {}
if (apigear_template_unreal_path is not None):
if apigear_template_unreal_path is not None:
layers[SolutionLayers.UNREAL] = apigear_template_unreal_path
if (apigear_template_cpp_path is not None):
if apigear_template_cpp_path is not None:
layers[SolutionLayers.CPP] = apigear_template_cpp_path
if (apigear_template_qt5_path is not None):
if apigear_template_qt5_path is not None:
layers[SolutionLayers.QT5] = apigear_template_qt5_path
if (apigear_template_qt6_path is not None):
if apigear_template_qt6_path is not None:
layers[SolutionLayers.QT6] = apigear_template_qt6_path

export_apigear(output_dir, tree, data_type_tree, layers)
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

import rich_click as click

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.tree import VSSNode
from vss_tools.main import get_trees
from vss_tools.tree import VSSNode


def allowedString(allowedList):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import rich_click as click
from anytree import PreOrderIter # type: ignore[import]

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.tree import VSSNode
from vss_tools.vspec.utils.misc import getattr_nn
from vss_tools.main import get_trees
from vss_tools.tree import VSSNode
from vss_tools.utils.misc import getattr_nn


def get_header(with_uuid: bool, entry_type: str, with_instance_column: bool) -> list[str]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

import rich_click as click

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.model import VSSDataBranch, VSSDataStruct
from vss_tools.vspec.tree import VSSNode
from vss_tools.vspec.utils.misc import getattr_nn
from vss_tools.main import get_trees
from vss_tools.model import VSSDataBranch, VSSDataStruct
from vss_tools.tree import VSSNode
from vss_tools.utils.misc import getattr_nn

c_keywords = [
"auto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import rich_click as click
from anytree import PreOrderIter

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.tree import VSSNode
from vss_tools.main import get_trees
from vss_tools.tree import VSSNode


# Write the header line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import rich_click as click
from anytree import PreOrderIter

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.datatypes import Datatypes, is_array
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.model import VSSDataBranch, VSSDataDatatype, VSSDataStruct
from vss_tools.vspec.tree import VSSNode
from vss_tools.datatypes import Datatypes, is_array
from vss_tools.main import get_trees
from vss_tools.model import VSSDataBranch, VSSDataDatatype, VSSDataStruct
from vss_tools.tree import VSSNode

datatype_map = {
Datatypes.INT8_ARRAY[0]: "[]int8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
print_schema,
)

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.datatypes import Datatypes
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.model import VSSDataDatatype
from vss_tools.vspec.tree import VSSNode
from vss_tools.vspec.utils.misc import camel_back
from vss_tools.datatypes import Datatypes
from vss_tools.main import get_trees
from vss_tools.model import VSSDataDatatype
from vss_tools.tree import VSSNode
from vss_tools.utils.misc import camel_back

GRAPHQL_TYPE_MAPPING = {
Datatypes.INT8[0]: GraphQLInt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
import rich_click as click
import yaml

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.tree import VSSNode
from vss_tools.vspec.utils import vss2id_val
from vss_tools.vspec.utils.idgen_utils import (
from vss_tools.main import get_trees
from vss_tools.tree import VSSNode
from vss_tools.utils import vss2id_val
from vss_tools.utils.idgen_utils import (
fnv1_32_hash,
get_all_keys_values,
get_node_identifier_bytes,
)
from vss_tools.vspec.utils.misc import getattr_nn
from vss_tools.utils.misc import getattr_nn


def generate_split_id(node: VSSNode, id_counter: int, strict_mode: bool) -> Tuple[str, int]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import rich_click as click

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.tree import VSSNode
from vss_tools.main import get_trees
from vss_tools.tree import VSSNode


def get_data(node: VSSNode, with_extra_attributes: bool = True, extended_attributes: tuple[str, ...] = ()):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import rich_click as click

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.model import VSSDataBranch, VSSDataDatatype, VSSDataStruct
from vss_tools.vspec.tree import VSSNode
from vss_tools.main import get_trees
from vss_tools.model import VSSDataBranch, VSSDataDatatype, VSSDataStruct
from vss_tools.tree import VSSNode

type_map = {
"int8": "integer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
import rich_click as click
from anytree import findall

import vss_tools.vspec.cli_options as clo
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.vspec.main import get_trees
from vss_tools.vspec.model import (
from vss_tools.main import get_trees
from vss_tools.model import (
VSSDataBranch,
VSSDataDatatype,
VSSDataStruct,
)
from vss_tools.vspec.tree import VSSNode
from vss_tools.tree import VSSNode

PATH_DELIMITER = "."
DIR_DELIMITER = "/"
Expand Down
Loading

0 comments on commit 92d4873

Please sign in to comment.