Skip to content

Commit

Permalink
implement a general 'delete_items()' function
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 6, 2020
1 parent c6c06c4 commit 1fcf938
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gallery_dl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def filter_dict(a):
return {k: v for k, v in a.items() if k[0] != "_"}


def delete_items(obj, keys):
"""Remove all 'keys' from 'obj'"""
for key in keys:
if key in obj:
del obj[key]


def number_to_string(value, numbers=(int, float)):
"""Convert numbers (int, float) to string; Return everything else as is."""
return str(value) if value.__class__ in numbers else value
Expand Down

0 comments on commit 1fcf938

Please sign in to comment.