Turns a list of maps, lists, or scalars into a single map. Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and NESTING_RESET_TAGS maps out of lists and partial maps.
(default, *args)
| 1011 | # Now, some helper functions. |
| 1012 | |
| 1013 | def buildTagMap(default, *args): |
| 1014 | """Turns a list of maps, lists, or scalars into a single map. |
| 1015 | Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and |
| 1016 | NESTING_RESET_TAGS maps out of lists and partial maps.""" |
| 1017 | built = {} |
| 1018 | for portion in args: |
| 1019 | if hasattr(portion, 'items'): |
| 1020 | #It's a map. Merge it. |
| 1021 | for k,v in portion.items(): |
| 1022 | built[k] = v |
| 1023 | elif hasattr(portion, '__iter__'): # is a list |
| 1024 | #It's a list. Map each item to the default. |
| 1025 | for k in portion: |
| 1026 | built[k] = default |
| 1027 | else: |
| 1028 | #It's a scalar. Map it to the default. |
| 1029 | built[portion] = default |
| 1030 | return built |
| 1031 | |
| 1032 | # Now, the parser classes. |
| 1033 |
no test coverage detected