Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/config.py @ 490:ea4b7fac02d6
Reorder type comparisons by usage
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Fri, 17 Dec 2021 16:37:26 +0100 |
| parents | b49164db1273 |
| children | de776953337b |
comparison
equal
deleted
inserted
replaced
| 489:b49164db1273 | 490:ea4b7fac02d6 |
|---|---|
| 631 def substitute_variables_in_obj(self, obj): | 631 def substitute_variables_in_obj(self, obj): |
| 632 """Recursively expand variables in the object tree `obj`.""" | 632 """Recursively expand variables in the object tree `obj`.""" |
| 633 if isinstance(obj, self._TEXTTYPE): | 633 if isinstance(obj, self._TEXTTYPE): |
| 634 # a string - really replace the value | 634 # a string - really replace the value |
| 635 return self.expand_variable(obj) | 635 return self.expand_variable(obj) |
| 636 elif isinstance(obj, dict): | |
| 637 newdict = type(obj)() | |
| 638 for k in obj: | |
| 639 newdict[k] = self.substitute_variables_in_obj(obj[k]) | |
| 640 return newdict | |
| 636 elif isinstance(obj, list): | 641 elif isinstance(obj, list): |
| 637 return [self.substitute_variables_in_obj(i) for i in obj] | 642 return [self.substitute_variables_in_obj(i) for i in obj] |
| 638 elif isinstance(obj, tuple): | 643 elif isinstance(obj, tuple): |
| 639 tmp = [self.substitute_variables_in_obj(i) for i in obj] | 644 tmp = [self.substitute_variables_in_obj(i) for i in obj] |
| 640 return type(obj)(tmp) | 645 return type(obj)(tmp) |
| 641 elif isinstance(obj, dict): | |
| 642 newdict = type(obj)() | |
| 643 for k in obj: | |
| 644 newdict[k] = self.substitute_variables_in_obj(obj[k]) | |
| 645 return newdict | |
| 646 elif isinstance(obj, set): | 646 elif isinstance(obj, set): |
| 647 newset = type(obj)() | 647 newset = type(obj)() |
| 648 for i in obj: | 648 for i in obj: |
| 649 newset.add(self.substitute_variables_in_obj(i)) | 649 newset.add(self.substitute_variables_in_obj(i)) |
| 650 else: | 650 else: |
