def apply_edits(self): """ Apply any edits defined in the final ``layer.yaml`` file to the data. An example edit definition: .. code-block:: yaml metadata: deletes: - requires.http """ # Apply any editing rules from config config = self.config if config: section = config.get(self.section) if section: dels = section.get('deletes', []) if self.prefix: namespace = self.data.get(self.prefix, {}) else: namespace = self.data for key in dels: # TODO: Chuck edit this thing utils.delete_path(key, namespace) if not self.target_file.parent.exists(): self.target_file.parent.makedirs_p()
def apply_edits(self): # Apply any editing rules from config config = self.config if config: section = config.get(self.section) if section: dels = section.get('deletes', []) if self.prefix: namespace = self.data.get(self.prefix, {}) else: namespace = self.data for key in dels: utils.delete_path(key, namespace) if not self.target_file.parent.exists(): self.target_file.parent.makedirs_p()
def apply_edits(self): # Apply any editing rules from config config = self.config if config: section = config.get(self.section) if section: dels = section.get('deletes', []) if self.prefix: namespace = self.data.get(self.prefix, {}) else: namespace = self.data for key in dels: # TODO: Chuck edit this thing utils.delete_path(key, namespace) if not self.target_file.parent.exists(): self.target_file.parent.makedirs_p()
def __call__(self): data = self.load(self.entity.open()) # self.data represents the product of previous layers if self.data: data = utils.deepmerge(self.data, data) # Now apply any rules from config config = self.config if config: section = config.get(self.section) if section: dels = section.get('deletes', []) if self.prefix: namespace = data[self.prefix] else: namespace = data for key in dels: utils.delete_path(key, namespace) self.data = data if not self.target_file.parent.exists(): self.target_file.parent.makedirs_p() self.dump(data) return data
def __call__(self): data = self.load(self.entity.open()) # self.data represents the product of previous layers if self.data: data = utils.deepmerge(self.data, data) # Now apply any rules from config config = self.config if config: section = config.get(self.section) if section: dels = section.get("deletes", []) if self.prefix: namespace = data[self.prefix] else: namespace = data for key in dels: utils.delete_path(key, namespace) self.data = data if not self.target_file.parent.exists(): self.target_file.parent.makedirs_p() self.dump(data) return data