Skip to content

Instantly share code, notes, and snippets.

@merrillcook0
Last active November 12, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save merrillcook0/7a97c2d1939900dc67e83e362a5dbdaa to your computer and use it in GitHub Desktop.
Save merrillcook0/7a97c2d1939900dc67e83e362a5dbdaa to your computer and use it in GitHub Desktop.
def _get_valid_attrs(item):
key_attrs = {'class', 'style'}
attrs = {
k: v if v != [] else '' for k, v in item.attrs.items() if k in key_attrs
}
for attr in key_attrs:
if attr not in attrs:
attrs[attr] = ''
return attrs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment