Esempio n. 1
0
 def combine(self, existing):
     ""  # suppress inherited doc
     self.read()
     existing.read()
     super(LayerYAML, self).combine(existing)
     self.schema = utils.deepmerge(existing.schema, self.schema)
     return self
Esempio n. 2
0
 def combine(self, existing):
     # make sure both versions are read in
     existing.read()
     self.read()
     # merge them
     self.data = utils.deepmerge(existing.data, self.data)
     return self
Esempio n. 3
0
 def combine(self, existing):
     """
     Merge the deserialized data from two layers using ``deepmerge``.
     """
     # make sure both versions are read in
     existing.read()
     self.read()
     # merge them
     if existing.data and self.data:
         self.data = utils.deepmerge(existing.data, self.data)
     elif existing.data:
         self.data = dict(existing.data)
     return self
Esempio n. 4
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
Esempio n. 5
0
 def combine(self, existing):
     self.read()
     existing.read()
     super(LayerYAML, self).combine(existing)
     self.schema = utils.deepmerge(existing.schema, self.schema)
     return self