diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-01-24 15:43:13 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-01-29 09:29:46 +0000 |
commit | 0c43850687fa3b56f40b03a1bef8a54cda38ac14 (patch) | |
tree | 2327fe64c92d6aafb4ac0f102c66191c00d23d22 /util/cmake/pro2cmake.py | |
parent | 4a2562e5db1605ba2d99445e6ea2bda69867a4d7 (diff) |
CMake: pro2cmake.py: Better printing of scopes
Change-Id: Ibeb77a23c90d3a47c78d17c4683e4af3c64449fc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-x | util/cmake/pro2cmake.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index fb55988600..6883a117e0 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -227,6 +227,10 @@ class Scope: self._visited_keys = set() # type: typing.Set[str] self._total_condition = None # type: typing.Optional[str] + def __repr__(self): + return '{}:{}:{}'.format(self._basedir, self._file, + self._condition or '<NONE>') + def reset_visited_keys(self): self._visited_keys = set() @@ -276,8 +280,8 @@ class Scope: elif operation == '*=': scope._append_operation(key, UniqueAddOperation(value)) else: - print('Unexpected operation "{}" in scope with ' - 'condition {}.'.format(operation, cond)) + print('Unexpected operation "{}" in scope "{}".' + .format(operation, scope)) assert(False) continue @@ -346,11 +350,7 @@ class Scope: def dump(self, *, indent: int = 0) -> None: ind = ' ' * indent - if self._condition == '': - print('{}Scope {} in "{}".'.format(ind, self._file, self._basedir)) - else: - print('{}Scope {} in "{}" with condition: "{}".' - .format(ind, self._file, self._basedir, self._condition)) + print('{}Scope "{}":'.format(ind, self)) print('{} Keys:'.format(ind)) keys = self._operations.keys() if not keys: @@ -576,8 +576,7 @@ def handle_subdir(scope: Scope, cm_fh: typing.IO[str], *, cm_fh.write('{}### remove_subdirectory' '("{}")\n'.format(ind, sd[1:])) else: - print(' XXXX: SUBDIR {} in {}: ' - 'Not found.'.format(sd, scope.file())) + print(' XXXX: SUBDIR {} in {}: Not found.'.format(sd, scope)) for c in scope.children(): cond = c.condition() |