def load_json(self, json_text): """Populates Collection from JSON-formatted text. Goes through COLLECTION_FIELDS, turning data in the JSON file into object attributes. @param json_text: JSON-formatted text """ module = self.identifier.fields_module() common.load_json(self, module, json_text)
def load_json(self, json_text): """Populate Entity data from JSON-formatted text. @param json_text: JSON-formatted text """ module = self.identifier.fields_module() json_data = common.load_json(self, module, json_text)
def load_json(self, json_text): """Populate Entity data from JSON-formatted text. @param json_text: JSON-formatted text """ module = self.identifier.fields_module() json_data = common.load_json(self, module, json_text) # special cases # files or file_groups -> self.files self.files = [] for fielddict in json_data: for fieldname,data in fielddict.iteritems(): if (fieldname in ['children', 'children_meta']) and data: self.children_meta = data elif (fieldname == 'file_groups') and data: self.files_dict = { d['role']: d['files'] for d in data } self.file_groups = [ {'role': role, 'files': self.files_dict.get(role, [])} for role in VALID_COMPONENTS['role'] ] self.files = filegroups_to_files(data) elif (fieldname == 'files') and data: self.files = data self.rm_file_duplicates()
def load_json(self, json_text): """Populate Entity data from JSON-formatted text. @param json_text: JSON-formatted text """ module = self.identifier.fields_module() json_data = common.load_json(self, module, json_text) # special cases # children and files/file_groups -> ._children_meta for fielddict in json_data: for fieldname,data in fielddict.iteritems(): if (fieldname in ['children', 'children_meta']) and data: self._entities_meta = data elif (fieldname in ['files', 'file_groups']) and data: self._files_meta = data self._children_meta = _meld_child_entity_file_meta( self._entities_meta, self._files_meta )
def load_json(self, json_text): """Populate File data from JSON-formatted text. @param json_text: JSON-formatted text """ module = self.identifier.fields_module() json_data = common.load_json(self, module, json_text) # fill in the blanks if self.access_rel: access_abs = os.path.join(self.entity_files_path, self.access_rel) if os.path.exists(access_abs): self.access_abs = access_abs # Identifier does not know file extension self.ext = os.path.splitext(self.basename_orig)[1] self.path = self.path + self.ext self.path_abs = self.path_abs + self.ext self.path_rel = self.path_rel + self.ext self.basename = self.basename + self.ext # fix access_rel self.access_rel = os.path.join(os.path.dirname(self.path_rel), os.path.basename(self.access_abs))
def load_json(self, json_text): """Populate File data from JSON-formatted text. @param json_text: JSON-formatted text """ module = self.identifier.fields_module() json_data = common.load_json(self, module, json_text) # fill in the blanks if self.access_rel: access_abs = os.path.join(self.entity_files_path, self.access_rel) if os.path.exists(access_abs): self.access_abs = access_abs # Identifier does not know file extension self.ext = os.path.splitext(self.basename_orig)[1] self.path = self.path + self.ext self.path_abs = self.path_abs + self.ext self.path_rel = self.path_rel + self.ext self.basename = self.basename + self.ext # fix access_rel self.access_rel = os.path.join( os.path.dirname(self.path_rel), os.path.basename(self.access_abs) )