Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/__init__.py @ 268:1484f6c0223a
Implemented "del_assoc()"
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 10 Sep 2020 09:22:30 +0200 |
| parents | d715c10f2930 |
| children | 7ef4362ca7c5 |
line wrap: on
line diff
--- a/configmix/__init__.py Thu Sep 10 02:01:28 2020 +0200 +++ b/configmix/__init__.py Thu Sep 10 09:22:30 2020 +0200 @@ -205,7 +205,7 @@ "javascript": _load_json, "json": _load_json, "-*-ignore-*-": _load_ignore, - "-*- ignore -*-": _load_ignore, + "-*- ignore -*-": _load_ignore, } """Default associations between file modes and loader functions""" @@ -327,6 +327,23 @@ _extensions.insert(0, (fnpattern, mode)) +def del_assoc(fnpattern): + """Remove all associations for `fnpattern`. + + :param str fnpattern: the :mod:`fnmatch` pattern to associate a loader + with + + """ + while True: + for i in range(len(_extensions)): + pat, fmode = _extensions[i] + if fnpattern == pat: + del _extensions[i] + break # restart + else: + return # nothing deleted -> done + + def _load_cfg_from_file(filename, ignore_unknown=False): """Determine the loader for file `filename` and return the loaded configuration dict.
