|
6 | 6 | from datetime import datetime |
7 | 7 | from pathlib import Path |
8 | 8 | from typing import Any |
9 | | -import json |
10 | | -from collections import UserDict |
11 | 9 |
|
12 | | -import pytz |
13 | 10 | import pyttman |
14 | 11 | from pyttman.core.containers import MessageMixin, Reply |
15 | 12 | from pyttman.core.decorators import LifecycleHookRepository |
@@ -37,13 +34,6 @@ def depr_graceful(message: str, version: str): |
37 | 34 | warnings.warn(out, DeprecationWarning) |
38 | 35 |
|
39 | 36 |
|
40 | | -class CustomUserDict(UserDict): |
41 | | - |
42 | | - def __init__(self, dictionary): |
43 | | - self.data = dictionary |
44 | | - self.__dict__.update(dictionary) |
45 | | - |
46 | | - |
47 | 37 | class Settings: |
48 | 38 | """ |
49 | 39 | Dataclass holding settings configured in the settings.py |
@@ -74,32 +64,15 @@ def __init__(self, dictionary=None, **kwargs): |
74 | 64 | self.LOG_FORMAT: str | None = None |
75 | 65 | self.LOG_TO_STDOUT: bool = False |
76 | 66 | self.STATIC_FILES_DIR: Path | None = None |
77 | | - self.TIME_ZONE: pytz.timezone = None |
78 | 67 |
|
79 | | - [self._set_attr(k, v) for k, v in kwargs.items() |
| 68 | + [setattr(self, k, v) for k, v in kwargs.items() |
80 | 69 | if not inspect.ismodule(v) |
81 | 70 | and not inspect.isfunction(v)] |
82 | 71 |
|
83 | | - def __getitem__(self, item): |
84 | | - return self.__dict__[item] |
85 | | - |
86 | | - def _set_attr(self, k, v): |
87 | | - tmp = v |
88 | | - if isinstance(v, dict): |
89 | | - tmp = Settings._dict_to_object(v) |
90 | | - |
91 | | - setattr(self, k, tmp) |
92 | | - |
93 | 72 | def __repr__(self): |
94 | 73 | _attrs = {name: value for name, value in self.__dict__.items()} |
95 | 74 | return f"Settings({_attrs})" |
96 | 75 |
|
97 | | - @staticmethod |
98 | | - def _dict_to_object(dictionary): |
99 | | - return json.loads(json.dumps(dictionary), object_hook=Settings) |
100 | | - |
101 | | - |
102 | | - |
103 | 76 | def _generate_name(name): |
104 | 77 | """ |
105 | 78 | Generates a user-friendly name out of |
|
0 commit comments