comparison cutils/util/fnmatch.py @ 304:dc1f08937621

FIX: fnmatch: handle None fnmatch filter definitions
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 05 Mar 2025 10:24:51 +0100
parents bf88323d6bf7
children 6c212e407524
comparison
equal deleted inserted replaced
303:73d13be531b5 304:dc1f08937621
102 self._matchers = matchers 102 self._matchers = matchers
103 103
104 @classmethod 104 @classmethod
105 def build_from_commandline_patterns(klass, filter_definitions): 105 def build_from_commandline_patterns(klass, filter_definitions):
106 matchers = [] 106 matchers = []
107 for action, kpattern in filter_definitions: 107 if filter_definitions:
108 kind, sep, pattern = kpattern.partition(':') 108 for action, kpattern in filter_definitions:
109 if not sep: 109 kind, sep, pattern = kpattern.partition(':')
110 # use the default 110 if not sep:
111 kind = "glob" 111 # use the default
112 pattern = kpattern 112 kind = "glob"
113 factory = klass._registry.get(kind, None) 113 pattern = kpattern
114 if not factory: 114 factory = klass._registry.get(kind, None)
115 raise RuntimeError("unknown pattern kind: {}".format(kind)) 115 if not factory:
116 matchers.append((action, kind, factory(pattern), pattern)) 116 raise RuntimeError("unknown pattern kind: {}".format(kind))
117 117 matchers.append((action, kind, factory(pattern), pattern))
118 return klass(matchers) 118 return klass(matchers)
119 119
120 def shall_visit(self, fn): 120 def shall_visit(self, fn):
121 visit = self.VISIT_DEFAULT 121 visit = self.VISIT_DEFAULT
122 for action, kind, matcher, orig_pattern in self._matchers: 122 for action, kind, matcher, orig_pattern in self._matchers: