Example #1
0
    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()
Example #2
0
    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()
Example #3
0
 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()
Example #4
0
 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()
Example #5
0
    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
Example #6
0
    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