Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split up models/helpers.py (#760)
- Loading branch information
Showing
17 changed files
with
166 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from enum import Enum, unique | ||
from typing import Optional | ||
|
||
|
||
@dataclass(frozen=True) | ||
class OntoIri: | ||
""" | ||
Holds an ontology IRI | ||
Attributes: | ||
iri: the ontology IRI | ||
hashtag: True if "#" is used to separate elements, False if element name is appended after "/" | ||
""" | ||
|
||
iri: str | ||
hashtag: bool | ||
|
||
|
||
ContextType = dict[str, OntoIri] | ||
|
||
|
||
@unique | ||
class Actions(Enum): | ||
Create = 1 | ||
Read = 2 | ||
Update = 3 | ||
Delete = 4 | ||
|
||
|
||
@unique | ||
class Cardinality(Enum): | ||
C_1 = "1" | ||
C_0_1 = "0-1" | ||
C_1_n = "1-n" | ||
C_0_n = "0-n" | ||
|
||
|
||
class WithId: | ||
""" | ||
Class helper to get json-ld "@id" thingies | ||
""" | ||
|
||
_tmp: str = None | ||
|
||
def __init__(self, obj: Optional[dict[str, str]]): | ||
if obj is None: | ||
return | ||
self._tmp = obj.get("@id") | ||
|
||
def to_string(self) -> Optional[str]: | ||
return self._tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.