-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate primitives and datatypes instances
- Loading branch information
Showing
8 changed files
with
181 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from ..utils.datatypes import CIMDatatype | ||
from ..utils.profile import Profile | ||
from .enum import * |
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,4 @@ | ||
from datetime import date, datetime, time | ||
from ..utils.datatypes import Primitive | ||
from ..utils.profile import Profile | ||
from .enum import * |
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,11 @@ | ||
|
||
""" | ||
Generated from the CGMES 3 files via cimgen: https://github.com/sogno-platform/cimgen | ||
""" | ||
|
||
{{class_name}} = CIMDatatype("{{class_name}}", {{data_type}}, {{unit}}, {{multiplier}}, [{{#class_origin}}Profile.{{origin}},{{/class_origin}}]) | ||
|
||
""" | ||
{{{wrapped_class_comment}}} | ||
""" | ||
|
File renamed without changes.
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,11 @@ | ||
|
||
""" | ||
Generated from the CGMES 3 files via cimgen: https://github.com/sogno-platform/cimgen | ||
""" | ||
|
||
{{class_name}} = Primitive("{{class_name}}",{{data_type}}, [{{#class_origin}}Profile.{{origin}}, {{/class_origin}}]) | ||
|
||
""" | ||
{{{wrapped_class_comment}}} | ||
""" | ||
|
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,51 @@ | ||
import importlib | ||
from dataclasses import Field, fields | ||
from functools import cached_property | ||
from typing import Any, TypeAlias, TypedDict | ||
|
||
from .constants import NAMESPACES | ||
from pydantic.dataclasses import dataclass | ||
|
||
from .dataclassconfig import DataclassConfig | ||
from .profile import BaseProfile | ||
from ..resources.enum import UnitMultiplier, UnitSymbol | ||
|
||
@dataclass(config=DataclassConfig) | ||
class Primitive: | ||
|
||
def __init__(self, name: str, type, profiles: set[BaseProfile]): | ||
self.name = name | ||
self.type = type | ||
self.profiles = profiles | ||
|
||
def getName(self) -> str: | ||
return self.name | ||
|
||
def getType(self): | ||
return self.type | ||
|
||
@cached_property | ||
def namespace(self) -> str: | ||
"""Returns the namespace. By default, the namespace is the cim namespace for all resources. | ||
Custom resources can override this. | ||
""" | ||
return NAMESPACES["cim"] | ||
|
||
@cached_property | ||
def getProfiles(self) -> set[BaseProfile]: | ||
return self.profiles | ||
|
||
@dataclass(config=DataclassConfig) | ||
class CIMDatatype(Primitive): | ||
|
||
def __init__(self, | ||
name: str, type, symbol: UnitSymbol, multiplier: UnitMultiplier, profiles: set[BaseProfile]): | ||
super().__init__(name, type, profiles) | ||
self.multiplier = multiplier | ||
self.symbol = symbol | ||
|
||
def getMultiplier(self) -> UnitMultiplier: | ||
return self.multiplier | ||
|
||
def getSymbole(self) -> UnitSymbol: | ||
return self.symbol |