1515import pathlib
1616
1717from jaraco .ui .main import main
18- from more_itertools import flatten
18+ from more_itertools import consume , flatten
1919
2020from . import imports , pypi
2121
2222
2323def emit_plain (deps ):
24- print ( * deps , sep = " \n " )
24+ yield from deps
2525
2626
2727def emit_toml (deps ):
28- print ( "[project]\n requires = [" )
29- print ( * map (lambda d : f' "{ d } ",' , deps ), sep = " \n " )
30- print ( "]" )
28+ yield "[project]\n requires = ["
29+ yield from map (lambda d : f' "{ d } ",' , deps )
30+ yield "]"
3131
3232
3333def emit_inline (deps ):
34- print ( """# ///\n # requires-python = ">=3.8"\n # dependencies = [""" )
35- print ( * map (lambda d : f'# "{ d } ",' , deps ), sep = " \n " )
36- print ( "# ]\n # ///" )
34+ yield """# ///\n # requires-python = ">=3.8"\n # dependencies = ["""
35+ yield from map (lambda d : f'# "{ d } ",' , deps )
36+ yield "# ]\n # ///"
3737
3838
3939def emit_python (deps ):
40- print ( """__requires__ = [""" )
41- print ( * map (lambda d : f' "{ d } ",' , deps ), sep = " \n " )
42- print ( "]" )
40+ yield """__requires__ = ["""
41+ yield from map (lambda d : f' "{ d } ",' , deps )
42+ yield "]"
4343
4444
4545def parse_glob (spec : str ):
@@ -54,4 +54,5 @@ def main(
5454 files = flatten (map (parse_glob , globs ))
5555 imps = flatten (map (imports .get_module_imports , files ))
5656 deps = (pypi .distribution_for (imp ) for imp in imps if not imp .excluded ())
57- globals ()[f'emit_{ format } ' ](deps )
57+ lines = globals ()[f'emit_{ format } ' ](deps )
58+ consume (map (print , lines ))
0 commit comments