Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/util/fnmatch.py @ 305:6c212e407524
fnmatch: allow to supply another default when determining matches
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 05 Mar 2025 13:54:55 +0100 |
| parents | dc1f08937621 |
| children | 652870b20f9e |
comparison
equal
deleted
inserted
replaced
| 304:dc1f08937621 | 305:6c212e407524 |
|---|---|
| 115 if not factory: | 115 if not factory: |
| 116 raise RuntimeError("unknown pattern kind: {}".format(kind)) | 116 raise RuntimeError("unknown pattern kind: {}".format(kind)) |
| 117 matchers.append((action, kind, factory(pattern), pattern)) | 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, default=None): |
| 121 visit = self.VISIT_DEFAULT | 121 visit = default if default is not None else self.VISIT_DEFAULT |
| 122 for action, kind, matcher, orig_pattern in self._matchers: | 122 for action, kind, matcher, orig_pattern in self._matchers: |
| 123 res = matcher(fn) | 123 res = matcher(fn) |
| 124 if res: | 124 if res: |
| 125 if action == "include": | 125 if action == "include": |
| 126 visit = True | 126 visit = True |
