Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/config.py @ 519:df0bb39617d6
Docs
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 19 Dec 2021 18:37:37 +0100 |
| parents | 55b8aed70f7d |
| children | 1001701be682 |
comparison
equal
deleted
inserted
replaced
| 518:55b8aed70f7d | 519:df0bb39617d6 |
|---|---|
| 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 :raise KeyError: If the reference is not found | |
| 700 | |
| 699 """ | 701 """ |
| 700 return self.expand_ref_uri(key) | 702 return self.expand_ref_uri(key) |
| 701 | 703 |
| 702 def expand_if_reference(self, v): | 704 def expand_if_reference(self, v): |
| 703 """Check whether `v` is a configuration reference and -- if true -- | 705 """Check whether `v` is a configuration reference and -- if true -- |
| 718 v[len(_STARTTOK_REF):-len(_ENDTOK_REF)]) | 720 v[len(_STARTTOK_REF):-len(_ENDTOK_REF)]) |
| 719 else: | 721 else: |
| 720 return v | 722 return v |
| 721 | 723 |
| 722 def expand_ref_uri(self, uri): | 724 def expand_ref_uri(self, uri): |
| 725 """ | |
| 726 | |
| 727 :raises KeyError: If the reference URI is not found | |
| 728 | |
| 729 """ | |
| 723 pu = urlsplit(uri) | 730 pu = urlsplit(uri) |
| 724 if pu.scheme or pu.netloc or pu.path or pu.query: | 731 if pu.scheme or pu.netloc or pu.path or pu.query: |
| 725 raise ValueError("only fragment-only URIs are supported") | 732 raise ValueError("only fragment-only URIs are supported") |
| 726 if not pu.fragment: | 733 if not pu.fragment: |
| 727 return self | 734 return self |
