Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/config.py @ 518:55b8aed70f7d
Remove unneeded "default" keyword argument for Configuration._lookupref() and Configuration.expand_ref_uri()
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 19 Dec 2021 16:33:31 +0100 |
| parents | 328af767f5f8 |
| children | df0bb39617d6 |
comparison
equal
deleted
inserted
replaced
| 517:328af767f5f8 | 518:55b8aed70f7d |
|---|---|
| 688 self.__cache[path] = _MISSING | 688 self.__cache[path] = _MISSING |
| 689 raise | 689 raise |
| 690 self.__cache[path] = v | 690 self.__cache[path] = v |
| 691 return v | 691 return v |
| 692 | 692 |
| 693 def _lookupref(self, key, default=_MARKER): | 693 def _lookupref(self, key): |
| 694 """ | 694 """ |
| 695 | 695 |
| 696 `key` must be a configuration reference URI without any | 696 `key` must be a configuration reference URI without any |
| 697 (namespace) prefixes and suffixes | 697 (namespace) prefixes and suffixes |
| 698 | 698 |
| 699 """ | 699 """ |
| 700 return self.expand_ref_uri(key, default=default) | 700 return self.expand_ref_uri(key) |
| 701 | 701 |
| 702 def expand_if_reference(self, v): | 702 def expand_if_reference(self, v): |
| 703 """Check whether `v` is a configuration reference and -- if true -- | 703 """Check whether `v` is a configuration reference and -- if true -- |
| 704 then expand it. | 704 then expand it. |
| 705 | 705 |
| 717 return self.expand_ref_uri( | 717 return self.expand_ref_uri( |
| 718 v[len(_STARTTOK_REF):-len(_ENDTOK_REF)]) | 718 v[len(_STARTTOK_REF):-len(_ENDTOK_REF)]) |
| 719 else: | 719 else: |
| 720 return v | 720 return v |
| 721 | 721 |
| 722 def expand_ref_uri(self, uri, default=_MARKER): | 722 def expand_ref_uri(self, uri): |
| 723 pu = urlsplit(uri) | 723 pu = urlsplit(uri) |
| 724 if pu.scheme or pu.netloc or pu.path or pu.query: | 724 if pu.scheme or pu.netloc or pu.path or pu.query: |
| 725 raise ValueError("only fragment-only URIs are supported") | 725 raise ValueError("only fragment-only URIs are supported") |
| 726 if not pu.fragment: | 726 if not pu.fragment: |
| 727 return self | 727 return self |
| 728 if pu.fragment.startswith(_DOT): | 728 if pu.fragment.startswith(_DOT): |
| 729 raise ValueError("relative refs not supported") | 729 raise ValueError("relative refs not supported") |
| 730 return self.getvar(pu.fragment, default=default) | 730 return self.getvar(pu.fragment) |
| 731 | 731 |
| 732 def substitute_variables_in_obj(self, obj): | 732 def substitute_variables_in_obj(self, obj): |
| 733 """Recursively expand variables in the object tree `obj`.""" | 733 """Recursively expand variables in the object tree `obj`.""" |
| 734 ty = type(obj) | 734 ty = type(obj) |
| 735 if issubclass(ty, _TEXTTYPE): | 735 if issubclass(ty, _TEXTTYPE): |
