Skip to content

Commit 942b892

Browse files
committed
base.py: updated the base class utility functions to be not bound
1 parent 8f8995c commit 942b892

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

messagebird/base.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
class Base(object):
44
def load(self, data):
55
for name, value in list(data.items()):
6-
if hasattr(self, name):
6+
if hasattr(self, name) and not callable(getattr(self,name)):
77
setattr(self, name, value)
88

99
return self
10-
11-
def strip_nanoseconds_from_date(self, value):
10+
11+
@staticmethod
12+
def strip_nanoseconds_from_date(value):
1213
if str(value).find(".") != -1:
1314
return value[:-11] + value[-1:]
1415

1516
return value
1617

17-
def value_to_time(self, value, format='%Y-%m-%dT%H:%M:%S+00:00'):
18-
if value != None:
19-
value = self.strip_nanoseconds_from_date(value)
20-
return datetime.strptime(value, format)
18+
@staticmethod
19+
def value_to_time(value, format='%Y-%m-%dT%H:%M:%S+00:00'):
20+
if value is not None:
21+
value = Base.strip_nanoseconds_from_date(value)
22+
return datetime.strptime(value, format)

0 commit comments

Comments
 (0)