Spaces:
Runtime error
Runtime error
Niv Sardi
commited on
Commit
·
0d9abe9
1
Parent(s):
e805ade
python/entity: new to_dict method
Browse files- python/entity.py +10 -0
python/entity.py
CHANGED
@@ -46,7 +46,17 @@ Entity {self.id}:
|
|
46 |
def to_row(self):
|
47 |
return [self.id, self.name, self.bco, self.url, self.logo]
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
if __name__ == '__main__':
|
50 |
e = Entity.from_dict({'name': 'test', 'url': 'blah'})
|
51 |
assert(e.url == 'blah')
|
52 |
print(e)
|
|
|
|
46 |
def to_row(self):
|
47 |
return [self.id, self.name, self.bco, self.url, self.logo]
|
48 |
|
49 |
+
def to_dict(self):
|
50 |
+
return {
|
51 |
+
'id': self.id,
|
52 |
+
'name': self.name,
|
53 |
+
'bco': self.bco,
|
54 |
+
'url': self.url,
|
55 |
+
'logo': self.logo
|
56 |
+
}
|
57 |
+
|
58 |
if __name__ == '__main__':
|
59 |
e = Entity.from_dict({'name': 'test', 'url': 'blah'})
|
60 |
assert(e.url == 'blah')
|
61 |
print(e)
|
62 |
+
print(e.to_dict())
|