コード例 #1
0
ファイル: tactics.py プロジェクト: timClicks/charm-tools
    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()
コード例 #2
0
ファイル: tactics.py プロジェクト: AdamIsrael/charm-tools
    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()
コード例 #3
0
ファイル: tactics.py プロジェクト: aznashwan/charm-tools
 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()
コード例 #4
0
ファイル: tactics.py プロジェクト: tai271828/charm-tools
 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()
コード例 #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
コード例 #6
0
ファイル: tactics.py プロジェクト: pdaniel-frk/charm-tools
    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