From c009e8f80f81d02e545152b7fdf230a3fb55ff7d Mon Sep 17 00:00:00 2001 From: dgelessus Date: Fri, 13 Dec 2019 10:52:59 +0100 Subject: [PATCH] Support passing an empty filter list to filter_resources --- rsrcfork/__main__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rsrcfork/__main__.py b/rsrcfork/__main__.py index d5eb825..0ea11aa 100644 --- a/rsrcfork/__main__.py +++ b/rsrcfork/__main__.py @@ -84,6 +84,12 @@ def bytes_escape(bs: bytes, *, quote: typing.Optional[str]=None) -> str: return "".join(out) def filter_resources(rf: api.ResourceFile, filters: typing.Sequence[str]) -> typing.List[api.Resource]: + if not filters: + resources = [] + for reses in rf.values(): + resources.extend(reses.values()) + return resources + matching: typing.MutableMapping[typing.Tuple[bytes, int], api.Resource] = collections.OrderedDict() for filter in filters: @@ -550,12 +556,7 @@ or rewritten by the shell. ns = ap.parse_args(args) with open_resource_file(ns.file, fork=ns.fork) as rf: - if ns.filter: - resources = filter_resources(rf, ns.filter) - else: - resources = [] - for reses in rf.values(): - resources.extend(reses.values()) + resources = filter_resources(rf, ns.filter) if ns.sort: resources.sort(key=lambda res: (res.type, res.id))