Skip to content

Commit 99c1ed4

Browse files
committed
Ens class refactored
1 parent af0a294 commit 99c1ed4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/pymice/_Ens.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,11 @@ class AmbiguousInitializationError(ValueError):
9090
def __init__(self, *dicts, **kwargs):
9191
for dict in (kwargs,) + dicts:
9292
for key in dict:
93-
Ens.__tryToSetAttribute(Ens.__dict(self), key, dict[key])
93+
Ens.__tryToSetAttribute(self.__dict__, key, dict[key])
9494

9595
def __dict(self):
9696
return super(Ens, self).__getattribute__('__dict__')
9797

98-
@classmethod
99-
def __get(cls, ens, name):
100-
return cls.__dict(ens).get(name)
101-
10298
@classmethod
10399
def __tryToSetAttribute(cls, attributeDict, name, value):
104100
if name in attributeDict:
@@ -108,7 +104,10 @@ def __tryToSetAttribute(cls, attributeDict, name, value):
108104
attributeDict[name] = value
109105

110106
def __getattribute__(self, name):
111-
return Ens.__get(self, name)
107+
if name == '__dict__':
108+
return super(Ens, self).__getattribute__(name)
109+
110+
return self.__dict__.get(name)
112111

113112
def __setattr__(self, name, value):
114113
raise Ens.ReadOnlyError
@@ -120,10 +119,10 @@ def __dir__(self):
120119
return list(self)
121120

122121
def __iter__(self):
123-
return iter(Ens.__dict(self))
122+
return iter(self.__dict__)
124123

125124
def __getitem__(self, key):
126-
return Ens.__get(self, key)
125+
return self.__dict__.get(key)
127126

128127
def __setitem__(self, key, value):
129128
raise Ens.ReadOnlyError

0 commit comments

Comments
 (0)