Ejemplo n.º 1
0
Archivo: runner.py Proyecto: iffy/ppo
def run():
    args = ap.parse_args()

    if args.ls:
        print('\n'.join(parser.listPluginNames()))
        sys.exit(0)

    if args.verbose:
        structlog.configure(
            logger_factory=structlog.PrintLoggerFactory(sys.stderr))

    infile = BytesIO(sys.stdin.read())
    try:
        parsed = parse(infile, exclude=args.exclude)
    except NoWillingParsers:
        if args.strict:
            raise
        else:
            infile.seek(0)
            sys.stdout.write(infile.read())
            sys.exit(0)

    if args.format == 'yaml':
        print(yaml.safe_dump(parsed, default_flow_style=False))
    elif args.format == 'json':
        print(json.dumps(parsed))
    elif args.format == 'grep':
        from ppo.output import giganticGrep
        giganticGrep(parsed, sys.stdout)
Ejemplo n.º 2
0
Archivo: runner.py Proyecto: iffy/ppo
def run():
    args = ap.parse_args()

    if args.ls:
        print('\n'.join(parser.listPluginNames()))
        sys.exit(0)

    if args.verbose:
        structlog.configure(logger_factory=structlog.PrintLoggerFactory(sys.stderr))

    infile = BytesIO(sys.stdin.read())
    try:
        parsed = parse(infile, exclude=args.exclude)
    except NoWillingParsers:
        if args.strict:
            raise
        else:
            infile.seek(0)
            sys.stdout.write(infile.read())
            sys.exit(0)

    if args.format == 'yaml':
        print(yaml.safe_dump(parsed, default_flow_style=False))
    elif args.format == 'json':
        print(json.dumps(parsed))
    elif args.format == 'grep':
        from ppo.output import giganticGrep
        giganticGrep(parsed, sys.stdout)
Ejemplo n.º 3
0
 def assertValue(self, indata, expected_output, message=None):
     """
     Assert that the given input results in the expected_output.
     """
     outstream = StringIO()
     giganticGrep(indata, outstream)
     value = outstream.getvalue()
     self.assertEqual(value, expected_output, message)
Ejemplo n.º 4
0
 def assertValue(self, indata, expected_output, message=None):
     """
     Assert that the given input results in the expected_output.
     """
     outstream = StringIO()
     giganticGrep(indata, outstream)
     value = outstream.getvalue()
     self.assertEqual(value, expected_output, message)
Ejemplo n.º 5
0
    def assertLines(self, indata, expected_output, message=None):
        """
        Assert that the given input results in the expected_output lines.
        """
        outstream = StringIO()
        giganticGrep(indata, outstream)
        value = outstream.getvalue()
        actual_lines = value.split('\n')
        expected_lines = expected_output + ['']

        present = set(expected_lines) & set(actual_lines)
        missing = set(expected_lines) - set(actual_lines)
        extra = set(actual_lines) - set(expected_lines)

        if missing or extra:
            self.fail(
                'Expected these lines:\n%s\n\nPresent:\n%s\n\nExtra:\n%s\n\nMissing:\n%s'
                % ('\n'.join(expected_output), '\n'.join(list(present)),
                   '\n'.join(list(extra)), '\n'.join(list(missing))))
Ejemplo n.º 6
0
    def assertLines(self, indata, expected_output, message=None):
        """
        Assert that the given input results in the expected_output lines.
        """
        outstream = StringIO()
        giganticGrep(indata, outstream)
        value = outstream.getvalue()
        actual_lines = value.split('\n')
        expected_lines = expected_output + ['']

        present = set(expected_lines) & set(actual_lines)
        missing = set(expected_lines) - set(actual_lines)
        extra = set(actual_lines) - set(expected_lines)

        if missing or extra:
            self.fail('Expected these lines:\n%s\n\nPresent:\n%s\n\nExtra:\n%s\n\nMissing:\n%s' % (
                '\n'.join(expected_output),
                '\n'.join(list(present)),
                '\n'.join(list(extra)),
                '\n'.join(list(missing))))