Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/config.py @ 385:4beeb291926d
First documentation of getfirstvarl()
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 10 Nov 2021 02:11:12 +0100 |
| parents | 8c3aaa894089 |
| children | 13427f37abab |
comparison
equal
deleted
inserted
replaced
| 384:8c3aaa894089 | 385:4beeb291926d |
|---|---|
| 100 return default | 100 return default |
| 101 else: | 101 else: |
| 102 return varvalue | 102 return varvalue |
| 103 | 103 |
| 104 def getfirstvarl(self, *paths, **kwds): | 104 def getfirstvarl(self, *paths, **kwds): |
| 105 """A variant of :meth:`~.getvarl` that returns the first found | |
| 106 variable in the `paths` list. | |
| 107 | |
| 108 Every item in `paths` is either a `tuple` or `list` or a `dict`. | |
| 109 If the path item is a `dict` then it must have two keys "namespace" | |
| 110 and "path". | |
| 111 If the path item is a `list` or `tuple` then the namespace is assumed | |
| 112 to be `None`. | |
| 113 | |
| 114 No variable interpolation is done and no filters are applied. | |
| 115 | |
| 116 Quoting of anything in `paths` is *not* needed and wrong. | |
| 117 | |
| 118 """ | |
| 105 default = kwds.pop("default", _MARKER) | 119 default = kwds.pop("default", _MARKER) |
| 106 for path in paths: | 120 for path in paths: |
| 107 if isinstance(path, (list, tuple)): | 121 if isinstance(path, (list, tuple)): |
| 108 try: | 122 try: |
| 109 varvalue = self.getvarl(*path) | 123 varvalue = self.getvarl(*path) |
