Add filters option to property watch class

Each property changed signal calls a defined callback, an optional set
of filters can be defined to filter out property values not intended to
be used within the callback. These filters can be setup to eliminate
property value(s) that should be ignored per property group and its
configured callback.

ex.) Handle errant sensor values that could occur from a faulty device
so these values do not cause unwanted results from a callback function.

Example config entry to throw out an ambient temperature less than 0C or
greater than 100C:

- name: watch ambient temps
  description: >
    'Filter the ambient temps, discarding any value that
    does not pass, then trigger the callback logic.'
  class: watch
  watch: property
  paths: ambient sensors
  properties: ambient temp
  callback: median temps
  filters:
    - op: '>='
      bound: 0
    - op: '<='
      bound: 100000

Tested:
    Generate a single filter function against a group of properties
    Generate multiple filter functions against a group of properties
    Property values are cleared when it fails to pass a filter
    Property values that pass all filters are updated

Change-Id: Id5126263096b4787a40befdb14cf3514038df3ed
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/src/pdmgen.py b/src/pdmgen.py
index 963c7b3..dc1c9b7 100755
--- a/src/pdmgen.py
+++ b/src/pdmgen.py
@@ -196,6 +196,30 @@
         return a
 
 
+class OpArgument(Argument):
+    '''Operation type arguments.'''
+
+    def __init__(self, **kw):
+        self.op = kw.pop('op')
+        self.bound = kw.pop('bound')
+        self.decorators = kw.pop('decorators', [])
+        if kw.get('type', None):
+            self.decorators.insert(0, Literal(kw['type']))
+        if kw.get('type', None) == 'string':
+            self.decorators.insert(0, Quote())
+        if kw.get('type', None) == 'boolean':
+            self.decorators.insert(0, FixBool())
+
+        super(OpArgument, self).__init__(**kw)
+
+    def argument(self, loader, indent):
+        a = str(self.bound)
+        for d in self.decorators:
+            a = d(a)
+
+        return a
+
+
 class Indent(object):
     '''Help templates be depth agnostic.'''
 
@@ -616,6 +640,7 @@
     '''Handle the property watch config file directive.'''
 
     def __init__(self, *a, **kw):
+        self.filters = [OpArgument(**x) for x in kw.pop('filters', {})]
         self.callback = kw.pop('callback', None)
         super(PropertyWatch, self).__init__(**kw)