forked from iexbase/tron-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.py
More file actions
33 lines (26 loc) · 1009 Bytes
/
module.py
File metadata and controls
33 lines (26 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# --------------------------------------------------------------------
# Copyright (c) iEXBase. All rights reserved.
# Licensed under the MIT License.
# See License.txt in the project root for license information.
# --------------------------------------------------------------------
class Module:
"""Module Class"""
def __init__(self, tron) -> None:
self.tron = tron
@classmethod
def attach(cls, target, module_name: str = None) -> None:
if not module_name:
module_name = cls.__name__.lower()
if hasattr(target, module_name):
raise AttributeError(
"Cannot set {0} module named '{1}'. The Tron object "
"already has an attribute with that name".format(
target,
module_name,
)
)
if isinstance(target, Module):
tron = target.tron
else:
tron = target
setattr(target, module_name, cls(tron))