(no commit message)
[sfa.git] / sfatables / commands / Add.py
index da02e86..e7657ff 100644 (file)
@@ -4,12 +4,11 @@ from sfatables.command import Command
 from sfatables.globals import *
 
 class Add(Command):
-    options = [('-A','--add')]
-    help = 'Add a rule to a chain'
-    matches = True
-    targets = True
-
     def __init__(self):
+        self.options = [('-A','--add')]
+        self.help = 'Add a rule to a chain'
+        self.matches = True
+        self.targets = True
         return
 
     def getnextfilename(self,type,chain):
@@ -42,7 +41,7 @@ class Add(Command):
             option_name = option['name']
             option_value = getattr(options,option_name)
 
-            if (hasattr(options,option_name)):
+            if (hasattr(options,option_name) and getattr(options,option_name)):
                 context = p.xpathEval("//rule[@element='%s' or @element='*']/argument[name='%s']"%(element, option_name))
                 if (not context):
                     raise Exception('Unknown option %s for match %s and element %s'%(option,option['name'], element))