tabs -> spaces

This commit is contained in:
Ian Adam Naval 2015-02-20 18:27:21 -05:00
parent c9b1b2fba9
commit 0a78e571fd
2 changed files with 26 additions and 26 deletions

View File

@ -3,18 +3,18 @@ from commands import BaseCommand, register_cmd
@register_cmd @register_cmd
class example_cmd(BaseCommand): class example_cmd(BaseCommand):
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
def input_generator(): def input_generator():
yield 'example' yield 'example'
yield 'command' yield 'command'
return input_generator return input_generator
@register_cmd @register_cmd
class echo(BaseCommand): class echo(BaseCommand):
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
def input_generator(): def input_generator():
for line in self.input_cmd(): for line in self.input_cmd():
yield line yield line
return input_generator return input_generator

View File

@ -1,23 +1,23 @@
class Formatter(object): class Formatter(object):
"""Formatters are callable objects who always accept a generator. """Formatters are callable objects who always accept a generator.
The generator represents the output stream of an executing program. The generator represents the output stream of an executing program.
Formatters are special commands which produce no output themselves. Formatters are special commands which produce no output themselves.
Instead, they always write to the standard out of the program. """ Instead, they always write to the standard out of the program. """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
# Always require no arguments # Always require no arguments
pass pass
def __call__(self, input_generator): def __call__(self, input_generator):
raise NotImplementedError( raise NotImplementedError(
"You must extend a Formatter and implement the __call__ method") "You must extend a Formatter and implement the __call__ method")
class Printer(Formatter): class Printer(Formatter):
"""Simple formatter which accepts any object from the input """Simple formatter which accepts any object from the input
generator and simply prints it as if it were a string.""" generator and simply prints it as if it were a string."""
def __call__(self, input_generator): def __call__(self, input_generator):
for line in input_generator: for line in input_generator:
print(str(line.decode('utf-8'))) print(str(line.decode('utf-8')))
return None return None