Spaces:
Runtime error
Runtime error
File size: 976 Bytes
485f76b |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
#!/usr/bin/env python3
class Entity():
def __init__(self, name, bco, url=None, logo=None):
self.name = name
self.bco = bco
self.url = url
self.logo = logo
def __repr__(self):
return f"""
Entity:
name: {self.name}
bco: {self.bco}
url: {self.url}
logo: {self.logo}
"""
@classmethod
def from_list(cls, l):
self = apply(cls, l)
return self
@classmethod
def from_dict(cls, d):
self = cls(None, None)
for f in d.keys():
setattr(self, f, d[f])
return self
@classmethod
def row_names(cls):
return ['name', 'bco', 'url', 'logo']
@property
def DATA_PATH(self):
return f"./data/{self.bco}"
def to_row(self):
return [self.name, self.bco, self.url, self.logo]
if __name__ == '__main__':
e = Entity.from_dict({'url': 'blah'})
assert(e.url == 'blah')
print(e)
|