MCPcopy Create free account
hub / github.com/clips/pattern / buildTagMap

Function buildTagMap

pattern/web/soup/BeautifulSoup.py:1018–1035  ·  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

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

Callers 4

__init__Method · 0.85
BeautifulSoupClass · 0.85
MinimalSoupClass · 0.85

Calls 1

itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…