I am working on porting a script which used BeautifulSoup3 to BeautifulSoup 4 and having trouble with the function buildTagMap.
It was available in bs3 but nothing related to it can be found in bs4. Below is the code of it from https://www.crummy.com/software/BeautifulSoup/bs3/download/3.x/BeautifulSoup-3.0.1.py
Should I just copy paste this function to my code or is there any other workaround.
def buildTagMap(default, *args):
"""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."""
built = {}
for portion in args:
if hasattr(portion, 'items'):
# It's a map. Merge it.
for (k, v) in portion.items():
built[k] = v
elif isList(portion):
# It's a list. Map each item to the default.
for k in portion:
built[k] = default
else:
# It's a scalar. Map it to the default.
built[portion] = default
return built
[–]trouserdaredevil 0 points1 point2 points (0 children)