summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-04-20 11:20:47 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-04 11:10:39 -0400
commita8421cae0d2864e8bb9010656351f37d2db941c4 (patch)
tree5e8cb6ae5d4549e5ffcd31821f45277e08b3f7ec
parent1886e7437a445cbf60dca1c8a5d3ba2fee438573 (diff)
downloadbcfg2-a8421cae0d2864e8bb9010656351f37d2db941c4.tar.gz
bcfg2-a8421cae0d2864e8bb9010656351f37d2db941c4.tar.bz2
bcfg2-a8421cae0d2864e8bb9010656351f37d2db941c4.zip
make bcfg2-lint warn about .cat and .diff files
-rw-r--r--src/lib/Bcfg2/Server/Lint/Deltas.py20
-rw-r--r--src/lib/Server/Lint/__init__.py7
2 files changed, 25 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/Deltas.py b/src/lib/Bcfg2/Server/Lint/Deltas.py
new file mode 100644
index 000000000..7627b0cb0
--- /dev/null
+++ b/src/lib/Bcfg2/Server/Lint/Deltas.py
@@ -0,0 +1,20 @@
+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 check_entry(self, basename, entry):
+ for fname in list(entry.entries.keys()):
+ 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))
diff --git a/src/lib/Server/Lint/__init__.py b/src/lib/Server/Lint/__init__.py
index a9d57c46c..ff5293a81 100644
--- a/src/lib/Server/Lint/__init__.py
+++ b/src/lib/Server/Lint/__init__.py
@@ -8,7 +8,8 @@ __all__ = ['Bundles',
'Pkgmgr',
'RequiredAttrs',
'Validate',
- 'Genshi']
+ 'Genshi',
+ 'Deltas']
import logging
import os
@@ -119,7 +120,9 @@ class ErrorHandler (object):
"merge-probes":"warning",
"input-output-error":"error",
"genshi-syntax-error":"error",
- "pattern-fails-to-initialize":"error"}
+ "pattern-fails-to-initialize":"error",
+ "cat-file-used":"warning",
+ "diff-file-used":"warning"}
def __init__(self, config=None):
self.errors = 0