
import click
from .compat import StringIO
import seria


CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


@click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--xml', 'out_fmt', flag_value='xml')
@click.option('--yaml', 'out_fmt', flag_value='yaml')
@click.option('--json', 'out_fmt', flag_value='json')
@click.argument('input', type=click.File('rb'), default='-')
@click.argument('output', type=click.File('wb'), default='-')
def cli(out_fmt, input, output):
    """Converts text."""
    _input = StringIO()
    for l in input:
        try:
            _input.write(str(l))
        except TypeError:
            _input.write(bytes(l, 'utf-8'))
    _serialized_obj = seria.load(_input)
    output.write(_serialized_obj.dump(out_fmt))


if __name__ == '__main__':
    cli(out_fmt, input, output)



import click
from .compat import StringIO, str, builtin_str
import seria


CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


@click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--xml', 'out_fmt', flag_value='xml')
@click.option('--yaml', 'out_fmt', flag_value='yaml')
@click.option('--json', 'out_fmt', flag_value='json')
@click.argument('input', type=click.File('r'), default='-')
@click.argument('output', type=click.File('w'), default='-')
def cli(out_fmt, input, output):
    """Converts text."""
    _input = StringIO()
    for l in input:
        try:
            _input.write(str(l))
        except TypeError:
            _input.write(bytes(l, 'utf-8'))
    _input = seria.load(_input)
    _out = (_input.dump(out_fmt))
    output.write(_out)


if __name__ == '__main__':
    cli(out_fmt, input, output)
Fix errors with 2/3 FLO support
Fix errors with 2/3 FLO support

  
  import click
- from .compat import StringIO
+ from .compat import StringIO, str, builtin_str
  import seria
  
  
  CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
  
  
  @click.command(context_settings=CONTEXT_SETTINGS)
  @click.option('--xml', 'out_fmt', flag_value='xml')
  @click.option('--yaml', 'out_fmt', flag_value='yaml')
  @click.option('--json', 'out_fmt', flag_value='json')
- @click.argument('input', type=click.File('rb'), default='-')
+ @click.argument('input', type=click.File('r'), default='-')
- @click.argument('output', type=click.File('wb'), default='-')
+ @click.argument('output', type=click.File('w'), default='-')
  def cli(out_fmt, input, output):
      """Converts text."""
      _input = StringIO()
      for l in input:
          try:
              _input.write(str(l))
          except TypeError:
              _input.write(bytes(l, 'utf-8'))
-     _serialized_obj = seria.load(_input)
+     _input = seria.load(_input)
-     output.write(_serialized_obj.dump(out_fmt))
+     _out = (_input.dump(out_fmt))
+     output.write(_out)
  
  
  if __name__ == '__main__':
      cli(out_fmt, input, output)
- 
- 
Fix errors with 2/3 FLO support
## Code Before:

import click
from .compat import StringIO
import seria


CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


@click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--xml', 'out_fmt', flag_value='xml')
@click.option('--yaml', 'out_fmt', flag_value='yaml')
@click.option('--json', 'out_fmt', flag_value='json')
@click.argument('input', type=click.File('rb'), default='-')
@click.argument('output', type=click.File('wb'), default='-')
def cli(out_fmt, input, output):
    """Converts text."""
    _input = StringIO()
    for l in input:
        try:
            _input.write(str(l))
        except TypeError:
            _input.write(bytes(l, 'utf-8'))
    _serialized_obj = seria.load(_input)
    output.write(_serialized_obj.dump(out_fmt))


if __name__ == '__main__':
    cli(out_fmt, input, output)


## Instruction:
Fix errors with 2/3 FLO support
## Code After:

import click
from .compat import StringIO, str, builtin_str
import seria


CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


@click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--xml', 'out_fmt', flag_value='xml')
@click.option('--yaml', 'out_fmt', flag_value='yaml')
@click.option('--json', 'out_fmt', flag_value='json')
@click.argument('input', type=click.File('r'), default='-')
@click.argument('output', type=click.File('w'), default='-')
def cli(out_fmt, input, output):
    """Converts text."""
    _input = StringIO()
    for l in input:
        try:
            _input.write(str(l))
        except TypeError:
            _input.write(bytes(l, 'utf-8'))
    _input = seria.load(_input)
    _out = (_input.dump(out_fmt))
    output.write(_out)


if __name__ == '__main__':
    cli(out_fmt, input, output)