8000 Combine logic for printing lists, generators, and sets (#9) · tywin1104/python-fire@f8ad6b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit f8ad6b7

Browse files
r0flsdbieber
authored andcommitted
Combine logic for printing lists, generators, and sets (google#9)
* cleanup logic in print * leave tuple logic separate
1 parent 63aba49 commit f8ad6b7

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

fire/core.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def main(argv):
5757
import pipes
5858
import shlex
5959
import sys
60+
import types
6061

6162
from fire import completion
6263
from fire import decorators
@@ -166,13 +167,8 @@ def _PrintResult(component_trace, verbose=False):
166167
# and move serialization to it's own module.
167168
result = component_trace.GetResult()
168169

169-
if isinstance(result, list):
170-
for i in result:
171-
print(_OneLineResult(i))
172-
elif isinstance(result, set):
173-
for i in result:
174-
print(_OneLineResult(i))
175-
elif inspect.isgenerator(result):
170+
171+
if isinstance(result, (list, set, types.GeneratorType)):
176172
for i in result:
177173
print(_OneLineResult(i))
178174
elif inspect.isgeneratorfunction(result):

0 commit comments

Comments
 (0)
0