summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Lint/Deltas.py
blob: 8d35d8e5ad1dc607421a0f79dd0fd2745d02f60e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Bcfg2.Server.Lint

class Deltas(Bcfg2.Server.Lint.ServerPlugin):
    """ Warn about usage of .cat and .diff files """
    def Run(self):
        """ run plugin """
        if 'Cfg' in self.core.plugins:
            cfg = self.core.plugins['Cfg']
            for basename, entry in list(cfg.entries.items()):
                self.check_entry(basename, entry)

    def Errors(self):
        return {"cat-file-used":"warning",
                "diff-file-used":"warning"}

    def check_entry(self, basename, entry):
        for fname in list(entry.entries.keys()):
            if self.HandlesFile(fname):
                match = entry.specific.delta_reg.match(fname)
                if match:
                    self.LintError("%s-file-used" % match.group('delta'),
                                   "%s file used on %s: %s" %
                                   (match.group('delta'), basename, fname))