Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class values do not follow model files #706

Open
davaya opened this issue Jun 25, 2023 · 1 comment
Open

Class values do not follow model files #706

davaya opened this issue Jun 25, 2023 · 1 comment

Comments

@davaya
Copy link

davaya commented Jun 25, 2023

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants