MCPcopy Index your code
hub / github.com/csev/py4e / buildTagMap

Function buildTagMap

old/old-code/BeautifulSoup.py:1013–1030  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1011# Now, some helper functions.
1012
1013def 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

Callers 4

__init__Method · 0.70
BeautifulSoupClass · 0.70
MinimalSoupClass · 0.70

Calls 1

itemsMethod · 0.45

Tested by

no test coverage detected