|
1 | | -import collections |
2 | 1 | import sys |
3 | 2 |
|
4 | 3 | from htmlgen.generator import Generator, HTMLChildGenerator |
|
15 | 14 | str_class = basestring |
16 | 15 |
|
17 | 16 |
|
18 | | -def is_element(object, element_name): |
| 17 | +def is_element(o, element_name): |
19 | 18 | """Return whether a given object is a certain element generator.""" |
20 | | - return (isinstance(object, collections.Iterable) and |
21 | | - hasattr(object, "element_name") and |
22 | | - object.element_name == element_name) |
| 19 | + return (hasattr(o, "__iter__") and |
| 20 | + hasattr(o, "element_name") and |
| 21 | + o.element_name == element_name) |
23 | 22 |
|
24 | 23 |
|
25 | 24 | class _ElementBase(Generator): |
@@ -179,7 +178,7 @@ def _style_value(self): |
179 | 178 | return "; ".join(rendered_styles) |
180 | 179 |
|
181 | 180 |
|
182 | | -class _ElementDataProxy(collections.MutableMapping): |
| 181 | +class _ElementDataProxy: |
183 | 182 |
|
184 | 183 | """Dictionary-like object for setting data-* attributes. |
185 | 184 |
|
@@ -258,7 +257,7 @@ def generate_children(self): |
258 | 257 | raise NotImplementedError() |
259 | 258 |
|
260 | 259 |
|
261 | | -class Element(NonVoidElement, collections.Sized): |
| 260 | +class Element(NonVoidElement): |
262 | 261 |
|
263 | 262 | """Base generator for HTML elements with children. |
264 | 263 |
|
|
0 commit comments