Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/config.py @ 703:193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 14 Aug 2023 09:31:27 +0200 |
| parents | 58dc57bed012 |
| children | 0485a033c95d |
comparison
equal
deleted
inserted
replaced
| 702:58dc57bed012 | 703:193a616e0b3c |
|---|---|
| 240 _HIER_SEPARATOR = u(b'.') | 240 _HIER_SEPARATOR = u(b'.') |
| 241 _NS_SEPARATOR = u(b':') | 241 _NS_SEPARATOR = u(b':') |
| 242 _FILTER_SEPARATOR = u(b'|') | 242 _FILTER_SEPARATOR = u(b'|') |
| 243 _STARTTOK_REF = _STARTTOK + REF_NAMESPACE + _NS_SEPARATOR | 243 _STARTTOK_REF = _STARTTOK + REF_NAMESPACE + _NS_SEPARATOR |
| 244 _ENDTOK_REF = _ENDTOK | 244 _ENDTOK_REF = _ENDTOK |
| 245 _ENDTOK_FILTER = _FILTER_SEPARATOR + _ENDTOK | |
| 245 _DOT = u(b'.') | 246 _DOT = u(b'.') |
| 246 _TILDE = u(b'~') | 247 _TILDE = u(b'~') |
| 247 _QUOTE = u(b'%') | 248 _QUOTE = u(b'%') |
| 248 _QUOTE_x = u(b'x') | 249 _QUOTE_x = u(b'x') |
| 249 _QUOTE_u = u(b'u') | 250 _QUOTE_u = u(b'u') |
| 1007 stacklevel=1) | 1008 stacklevel=1) |
| 1008 raise KeyError("Cannot interpolate variables in string " | 1009 raise KeyError("Cannot interpolate variables in string " |
| 1009 "%r (cached)" % (s, )) | 1010 "%r (cached)" % (s, )) |
| 1010 else: | 1011 else: |
| 1011 return res | 1012 return res |
| 1013 | |
| 1014 if ((len_s >= 6) | |
| 1015 and (s[2] == _FILTER_SEPARATOR) | |
| 1016 and (start == 0)): | |
| 1017 if s.find(_ENDTOK_FILTER, 3) != (len_s - 3): | |
| 1018 raise ValueError("`{{|' global filter interpolation must end with `|}}'") | |
| 1019 new_s, filters = _split_filters(s[3:-3]) | |
| 1020 try: | |
| 1021 varvalue = self.py_interpolate_variables(new_s) | |
| 1022 except KeyError: | |
| 1023 if NONE_FILTER in filters: | |
| 1024 varvalue = None | |
| 1025 elif EMPTY_FILTER in filters: | |
| 1026 varvalue = _EMPTY_STR | |
| 1027 else: | |
| 1028 raise | |
| 1029 varvalue = self._apply_filters(filters, varvalue) | |
| 1030 return varvalue | |
| 1012 res = [] | 1031 res = [] |
| 1013 res_append = res.append | 1032 res_append = res.append |
| 1014 rest = 0 | 1033 rest = 0 |
| 1015 cacheable = True | 1034 cacheable = True |
| 1016 while start != -1: | 1035 while start != -1: |
