Coverage for /home/runner/work/viur-core/viur-core/viur/src/viur/core/bones/__init__.py: 91%
41 statements
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
1from .base import (
2 BaseBone,
3 Compute,
4 ComputeInterval,
5 ComputeMethod,
6 MultipleConstraints,
7 ReadFromClientError,
8 ReadFromClientErrorSeverity,
9 UniqueLockMethod,
10 UniqueValue,
11)
12from .boolean import BooleanBone
13from .captcha import CaptchaBone
14from .color import ColorBone
15from .credential import CredentialBone
16from .date import DateBone
17from .email import EmailBone
18from .file import FileBone
19from .json import JsonBone
20from .key import KeyBone
21from .numeric import NumericBone
22from .password import PasswordBone
23from .randomslice import RandomSliceBone
24from .raw import RawBone
25from .record import RecordBone
26from .relational import RelationalBone, RelationalConsistency, RelationalUpdateLevel
27from .selectcountry import SelectCountryBone
28from .select import (
29 SelectBone,
30 translation_key_prefix_skeleton_bonename,
31 translation_key_prefix_bonename,
32)
33from .sortindex import SortIndexBone
34from .spatial import SpatialBone
35from .string import StringBone
36from .text import TextBone
37from .treeleaf import TreeLeafBone
38from .treenode import TreeNodeBone
39from .user import UserBone
41# Expose only specific names
42__all = [
43 "BaseBone",
44 "BooleanBone",
45 "CaptchaBone",
46 "ColorBone",
47 "Compute",
48 "ComputeInterval",
49 "ComputeMethod",
50 "CredentialBone",
51 "DateBone",
52 "EmailBone",
53 "FileBone",
54 "JsonBone",
55 "KeyBone",
56 "MultipleConstraints",
57 "NumericBone",
58 "PasswordBone",
59 "RandomSliceBone",
60 "RawBone",
61 "ReadFromClientError",
62 "ReadFromClientErrorSeverity",
63 "RecordBone",
64 "RelationalBone",
65 "RelationalConsistency",
66 "RelationalUpdateLevel",
67 "SelectBone",
68 "SelectCountryBone",
69 "SortIndexBone",
70 "SpatialBone",
71 "StringBone",
72 "TextBone",
73 "TreeLeafBone",
74 "TreeNodeBone",
75 "UniqueLockMethod",
76 "UniqueValue",
77 "UserBone",
78 "translation_key_prefix_bonename",
79 "translation_key_prefix_skeleton_bonename",
80]
82for __cls_name, __cls in locals().copy().items():
83 if __cls_name.startswith("__"):
84 continue
86 if __cls_name.endswith("Bone"):
87 __old_cls_name = __cls_name[0].lower() + __cls_name[1:]
89 __all += [__old_cls_name]
91 # Dynamically create a class providing a deprecation logging message for every lower-case bone name
92 def __generate_deprecation_constructor(cls, cls_name, old_cls_name):
93 def __init__(self, *args, **kwargs):
94 import logging, warnings
95 logging.warning(f"Use of class '{old_cls_name}' is deprecated, use '{cls_name}' instead.")
96 warnings.warn(f"Use of class '{old_cls_name}' is deprecated, use '{cls_name}' instead.", stacklevel=2)
97 cls.__init__(self, *args, **kwargs)
99 return __init__
101 locals()[__old_cls_name] = type(__old_cls_name, (__cls,), {
102 "__init__": __generate_deprecation_constructor(__cls, __cls_name, __old_cls_name)
103 })
105 # print(__old_cls_name, "installed as ", locals()[__old_cls_name], issubclass(locals()[__old_cls_name], __cls))
107__all__ = __all