diff options
author | Johan Lundberg <lundberg@nordu.net> | 2015-04-02 10:43:33 +0200 |
---|---|---|
committer | Johan Lundberg <lundberg@nordu.net> | 2015-04-02 10:43:33 +0200 |
commit | bd611ac59f7c4db885a2f8631ef0bcdcd1901ca0 (patch) | |
tree | e60f5333a7699cd021b33c7f5292af55b774001b /definate/global_filter.py |
Diffstat (limited to 'definate/global_filter.py')
-rwxr-xr-x | definate/global_filter.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/definate/global_filter.py b/definate/global_filter.py new file mode 100755 index 0000000..5969443 --- /dev/null +++ b/definate/global_filter.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# +# Copyright 2012 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Module that holds all global-level filter classes of Definate.""" + +__author__ = 'msu@google.com (Martin Suess)' + + +import yaml_validator + + +class Error(Exception): + """Base error class.""" + + +class Container(object): + """Container class to hold all information to be passed between filters.""" + + def __init__(self, absolute_paths=None, relative_paths=None): + """Initializer. + + Args: + absolute_paths: Optional list of strings to specify the full path of the + generated files + (e.g. ['//depot/def/AUTOGEN1.net', '/tmp/AUTOGEN2.net']). + relative_paths: Optional list of strings to specify the paths of the + generated files relative to the location of the definition directory + (e.g. ['AUTOGEN1.net']). + """ + self.absolute_paths = absolute_paths if absolute_paths else [] + self.relative_paths = relative_paths if relative_paths else [] + self.changelist = '' + + +class GlobalFilter(object): + """Abstract class defining the interface for the filter chain objects.""" + + def __init__(self): + """Initializer.""" + self._yaml_validator = yaml_validator.YamlValidator() + + def Filter(self, container, args): + """Interface to filter or modify data passed into it. + + Args: + container: Container object which holds all global information. + See Container class for details. + args: Dictionary of arguments depending on the actual filter in use. + + Raises: + NotImplementedError: In any case since this is not implemented an needs + to be defined by subclasses. + """ + raise NotImplementedError( + 'This is an interface only. Implemented by subclasses.') |