From 1fcf938f9ceaec1b0b48b7b7f310a0830b679b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 6 Jun 2020 23:49:49 +0200 Subject: [PATCH] implement a general 'delete_items()' function --- gallery_dl/util.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 85b871b788..afd96b889d 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -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