| 1 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
|
| 3 |
from Metadata import export |
| 4 |
from PyObjectBase import PyObjectBase |
| 5 |
from Quantity import Quantity |
| 6 |
from Unit import Unit |
| 7 |
from typing import Final, Tuple, overload |
| 8 |
|
| 9 |
@export( |
| 10 |
NumberProtocol=True, |
| 11 |
RichCompare=True, |
| 12 |
Constructor=True, |
| 13 |
Delete=True, |
| 14 |
) |
| 15 |
class Unit(PyObjectBase): |
| 16 |
""" |
| 17 |
Unit |
| 18 |
defines a unit type, calculate and compare. |
| 19 |
|
| 20 |
The following constructors are supported: |
| 21 |
Unit() -- empty constructor |
| 22 |
Unit(i1,i2,i3,i4,i5,i6,i7,i8) -- unit signature |
| 23 |
Unit(Quantity) -- copy unit from Quantity |
| 24 |
Unit(Unit) -- copy constructor |
| 25 |
Unit(string) -- parse the string for units |
| 26 |
|
| 27 |
Author: Juergen Riegel ([email protected]) |
| 28 |
Licence: LGPL |
| 29 |
""" |
| 30 |
|
| 31 |
@overload |
| 32 |
def __init__(self) -> None: ... |
| 33 |
@overload |
| 34 |
def __init__( |
| 35 |
self, |
| 36 |
i1: float, |
| 37 |
i2: float, |
| 38 |
i3: float, |
| 39 |
i4: float, |
| 40 |
i5: float, |
| 41 |
i6: float, |
| 42 |
i7: float, |
| 43 |
i8: float, |
| 44 |
) -> None: ... |
| 45 |
@overload |
| 46 |
def __init__(self, quantity: Quantity) -> None: ... |
| 47 |
@overload |
| 48 |
def __init__(self, unit: Unit) -> None: ... |
| 49 |
@overload |
| 50 |
def __init__(self, string: str) -> None: ... |
| 51 |
|
| 52 |
Type: Final[str] = ... |
| 53 |
"""holds the unit type as a string, e.g. 'Area'.""" |
| 54 |
|
| 55 |
Signature: Final[Tuple] = ... |
| 56 |
"""Returns the signature.""" |