tools-python icon indicating copy to clipboard operation
tools-python copied to clipboard

Class values do not follow model files

Open davaya opened this issue 2 years ago • 1 comments

The SPDX model files have properties with camelCase names:

- externalIdentifierType
  - type: ExternalIdentifierType
  - minCount: 1
  - maxCount: 1

but the tool class files have snake_case property names:

@dataclass_with_properties
class ExternalIdentifier:
    external_identifier_type: ExternalIdentifierType
    identifier: str
    ...

and upper case enum values instead of the camelCase model-defined vocabulary items:

class ExternalIdentifierType(Enum):
    CPE22 = auto()
    CPE23 = auto()
    CVE = auto()
    EMAIL = auto()
    GITOID = auto()
    PURL = auto()
    SECURITY_OTHER = auto()
    SWHID = auto()
    SWID = auto()
    URL_SCHEME = auto()
    OTHER = auto()

This causes multiple errors when trying to initialize the class types from example messages. Can the tool classes be regenerated from the model files using the property names and enum values from the model? The PascalCase type names (e.g. ExternalIdentifier) do appear to be correct.

PR #708 is a first step towards auto-generation of classes from the model.

davaya avatar Jun 25 '23 01:06 davaya

When it comes to python code conventions, we try to follow the PEP8 guideline. Conversion tools between snake case and camel case can be found here. Feel free to adapt them if you think they lack in functionality (so far, I only ran into problems with some checksum algorithm identifiers).

armintaenzertng avatar Jun 27 '23 08:06 armintaenzertng