Allow CSRElement objects to be autocompleted.

This commit is contained in:
Tim 'mithro' Ansell 2016-12-16 15:59:26 +01:00
parent 722edfe9e8
commit 1f6dc446d2
1 changed files with 6 additions and 2 deletions

View File

@ -3,11 +3,15 @@ import csv
class CSRElements: class CSRElements:
def __init__(self, d): def __init__(self, d):
self.d = d self.__dict__.update(d)
@property
def d(self):
return self.__dict__
def __getattr__(self, attr): def __getattr__(self, attr):
try: try:
return self.__dict__['d'][attr] return self.__dict__[attr]
except KeyError: except KeyError:
pass pass
raise KeyError("No such element " + attr) raise KeyError("No such element " + attr)