Skip to content

Commit

Permalink
gnulib-tool.py: Small refactoring.
Browse files Browse the repository at this point in the history
Suggested by Collin Funk.

* pygnulib/GLModuleSystem.py (GLModule.getDependenciesRecursively):
Return a set of GLModule.
* pygnulib/main.py (main): Convert the result to a string here.
  • Loading branch information
bhaible committed Aug 3, 2024
1 parent 2f400ff commit da8e6e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2024-08-03 Bruno Haible <[email protected]>

gnulib-tool.py: Small refactoring.
Suggested by Collin Funk.
* pygnulib/GLModuleSystem.py (GLModule.getDependenciesRecursively):
Return a set of GLModule.
* pygnulib/main.py (main): Convert the result to a string here.

2024-08-02 Collin Funk <[email protected]>

gnulib-tool.py: Correct type hint and doc string.
Expand Down
10 changes: 4 additions & 6 deletions pygnulib/GLModuleSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,9 @@ def getDependenciesWithConditions(self) -> list[tuple[GLModule, str | None]]:
self.cache['dependenciesWithCond'] = result
return self.cache['dependenciesWithCond']

def getDependenciesRecursively(self) -> str:
'''Return a list of recursive dependencies of this module separated
by a newline.'''
def getDependenciesRecursively(self) -> set[GLModule]:
'''Return a list of recursive dependencies of this module,
as a set of GLModule objects.'''
handledmodules = set()
inmodules = set()
outmodules = set()
Expand All @@ -551,9 +551,7 @@ def getDependenciesRecursively(self) -> str:
# Remove handledmodules from inmodules.
inmodules = inmodules.difference(handledmodules)

module_names = sorted([ module.name
for module in outmodules ])
return lines_to_multiline(module_names)
return outmodules

def getDependents(self) -> list[GLModule]:
'''Return list of dependents (a.k.a. "reverse dependencies"),
Expand Down
5 changes: 4 additions & 1 deletion pygnulib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,10 @@ def main(temp_directory: str) -> None:
for name in modules:
module = modulesystem.find(name)
if module:
sys.stdout.write(module.getDependenciesRecursively())
dependencies = module.getDependenciesRecursively()
dependencies_names = sorted([ m.name
for m in dependencies ])
sys.stdout.write(lines_to_multiline(dependencies_names))

elif mode == 'extract-dependents':
if avoids:
Expand Down

0 comments on commit da8e6e1

Please sign in to comment.