utils¶
ATOMIC_NUMBERS
¶
CHEMICAL_SYMBOLS
¶
EXTRA_SYMBOLS
¶
SemanticVersion (str)
¶
A custom type for a semantic version, using the recommended semver regexp from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string.
base_version: str
property
readonly
¶
The base version string without patch and metadata info.
build_metadata: str
property
readonly
¶
The build metadata.
major: int
property
readonly
¶
The major version number.
minor: int
property
readonly
¶
The minor version number.
patch: int
property
readonly
¶
The patch version number.
prerelease: str
property
readonly
¶
The pre-release tag.
regex
¶
__get_validators__()
classmethod
special
¶
Source code in optimade/models/utils.py
@classmethod
def __get_validators__(cls):
yield cls.validate
__modify_schema__(field_schema)
classmethod
special
¶
Source code in optimade/models/utils.py
@classmethod
def __modify_schema__(cls, field_schema):
field_schema.update(
pattern=cls.regex.pattern,
examples=["0.10.1", "1.0.0-rc.2", "1.2.3-rc.5+develop"],
)
validate(v)
classmethod
¶
Source code in optimade/models/utils.py
@classmethod
def validate(cls, v: str):
if not cls.regex.match(v):
raise ValueError(f"Unable to validate version {v} as a semver.")
return v