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
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:]
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('/')
def __call__(self, string): file = super(JSONFile, self).__call__(string) return driver.load(file)