| 7 | |
| 8 | |
| 9 | class CDPObject(dict): |
| 10 | def __init__(self, *a, **k): |
| 11 | super().__init__(*a, **k) |
| 12 | self.__dict__ = self |
| 13 | for k in self.__dict__: |
| 14 | if isinstance(self.__dict__[k], dict): |
| 15 | self.__dict__[k] = CDPObject(self.__dict__[k]) |
| 16 | elif isinstance(self.__dict__[k], list): |
| 17 | for i in range(len(self.__dict__[k])): |
| 18 | if isinstance(self.__dict__[k][i], dict): |
| 19 | self.__dict__[k][i] = CDPObject(self) |
| 20 | |
| 21 | def __repr__(self): |
| 22 | tpl = "%s(\n\t{{}}\n\t)" % self.__class__.__name__ |
| 23 | return tpl.format( |
| 24 | "\n ".join("%s = %s" % (k, v) for k, v in self.items()) |
| 25 | ) |
| 26 | |
| 27 | |
| 28 | class PageElement(CDPObject): |