Ejemplo n.º 1
0
def parse_document(args):
    document = None
    if args.document_json:
        document = args.document_json
    elif args.document_file:
        document = args.document_file
    else:
        mode = os.fstat(0).st_mode
        if stat.S_ISFIFO(mode):
            # cat doc.json | cmd
            document = driver.load(sys.stdin)
        elif stat.S_ISREG(mode):
            # cmd < doc.json
            document = driver.load(sys.stdin)

    setattr(args, 'document', document)
    return args
Ejemplo n.º 2
0
def parse_document(args):
    document = None
    if args.document_json:
        document = args.document_json
    elif args.document_file:
        document = args.document_file
    else:
        mode = os.fstat(0).st_mode
        if stat.S_ISFIFO(mode):
            # cat doc.json | cmd
            document = driver.load(sys.stdin)
        elif stat.S_ISREG(mode):
            # cmd < doc.json
            document = driver.load(sys.stdin)

    setattr(args, 'document', document)
    return args
Ejemplo n.º 3
0
def contents(*paths):
    fullpath = os.path.join(here, 'suite', *paths)
    print("fullp", fullpath)
    d = len(fullpath) + 1
    for dirpath, dirnames, filenames in os.walk(fullpath):
        for filename in filenames:
            if filename.endswith('.json'):
                filepath = os.path.join(dirpath, filename)
                with io.open(filepath, 'r', encoding='utf-8') as file:
                    yield json.load(file), filepath[d:]
Ejemplo n.º 4
0
def contents(*paths):
    fullpath = os.path.join(here, 'suite', *paths)
    print("fullp", fullpath)
    d = len(fullpath) + 1
    for dirpath, dirnames, filenames in os.walk(fullpath):
        for filename in filenames:
            if filename.endswith('.json'):
                filepath = os.path.join(dirpath, filename)
                with io.open(filepath, 'r', encoding='utf-8') as file:
                    yield json.load(file), filepath[d:]
Ejemplo n.º 5
0
def contents(*paths):
    fullpath = os.path.join(here, 'suite', *paths)
    d = len(fullpath)
    for filepath in Path(fullpath).glob('**/*.json'):
        with filepath.open('r', encoding='utf-8') as file:
            yield json.load(file), filepath.as_posix()[d:].lstrip('/')
Ejemplo n.º 6
0
def contents(*paths):
    fullpath = os.path.join(here, 'suite', *paths)
    d = len(fullpath)
    for filepath in Path(fullpath).glob('**/*.json'):
        with filepath.open('r', encoding='utf-8') as file:
            yield json.load(file), filepath.as_posix()[d:].lstrip('/')
Ejemplo n.º 7
0
 def __call__(self, string):
     file = super(JSONFile, self).__call__(string)
     return driver.load(file)
Ejemplo n.º 8
0
 def __call__(self, string):
     file = super(JSONFile, self).__call__(string)
     return driver.load(file)