Exemplo n.º 1
0
 def __init__(self, manifest: ResourceManifest, resource_path: str):
     self.resource = []
     self.manifest = manifest
     try:
         with open(resource_path, encoding='utf8') as f:
             reader = csv.reader(f, delimiter="|")
             if "skipheader" in self.manifest and self.manifest['skipheader']:
                 next(reader, [])
             for line in reader:
                 self.resource.append(line)
     except ValueError:
         raise SchemaValidationError('psv', resource_path)
     self.entry_template = self.manifest['targets']
Exemplo n.º 2
0
 def __init__(self, manifest: ResourceManifest,
              resource_path: Union[str, dict, list]):
     self.manifest = manifest
     try:
         if isinstance(resource_path, str):
             with open(resource_path, 'rb') as f:
                 self.resource = pickle.load(f)
         elif isinstance(resource_path, (dict, list)):
             self.resource = resource_path
     except ValueError:
         raise SchemaValidationError('json', resource_path)
     if "location" in self.manifest:
         self.resource = resolve_pointer(self.resource,
                                         self.manifest['location'])
     self.entry_template = self.manifest['targets']