spdx / tools-python

A Python library to parse, validate and create SPDX documents.
http://spdx.org
Apache License 2.0
181 stars 133 forks source link

Class values do not follow model files #706

Open davaya opened 1 year ago

davaya commented 1 year ago

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.

armintaenzertng commented 1 year ago

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).