Beispiel #1
0
def load(path, parser=None, grammar=None, decoder=None, **kwargs):
    """Returns a Python object from parsing the file at *path*.

    :param path: an :class:`os.PathLike` which presumably has a
        PVL Module in it to parse.
    :param parser: defaults to :class:`pvl.parser.OmniParser()`.
    :param grammar: defaults to :class:`pvl.grammar.OmniGrammar()`.
    :param decoder: defaults to :class:`pvl.decoder.OmniDecoder()`.
    :param ``**kwargs``: the keyword arguments that will be passed
        to :func:`loads()` and are described there.

    If *path* is not an :class:`os.PathLike`, it will be assumed to be an
    already-opened file object, and ``.read()`` will be applied
    to extract the text.

    If the :class:`os.PathLike` or file object contains some bytes
    decodable as text, followed by some that is not (e.g. an ISIS
    cube file), that's fine, this function will just extract the
    decodable text.
    """
    return loads(get_text_from(path),
                 parser=parser,
                 grammar=grammar,
                 decoder=decoder,
                 **kwargs)
Beispiel #2
0
def main():
    args = arg_parser().parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s',
                        level=(60 - 20 * args.verbose))

    results_list = list()
    for f in args.file:
        pvl_text = pvl.get_text_from(f)

        results = dict()

        for k, v in dialects.items():
            results[k] = pvl_flavor(pvl_text, k, v, f, args.verbose)

        results_list.append((f, results))

    # Writing the flavors out again to preserve order.
    print(report(results_list, list(dialects.keys())))
    return