| Total Complexity | 8 | 
| Total Lines | 27 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
| 1 | from abc import ABCMeta, abstractmethod  | 
            ||
| 6 | class DatadogBaseAction(Action):  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 7 | __metaclass__ = ABCMeta  | 
            ||
| 8 | |||
| 9 | def __init__(self, config):  | 
            ||
| 10 | super(DatadogBaseAction, self).__init__(config)  | 
            ||
| 11 | self._init_dd()  | 
            ||
| 12 | |||
| 13 | def _init_dd(self):  | 
            ||
| 14 |         options = { | 
            ||
| 15 | 'api_key': self.config['api_key'],  | 
            ||
| 16 | 'app_key': self.config['app_key']  | 
            ||
| 17 | }  | 
            ||
| 18 | initialize(**options)  | 
            ||
| 19 | |||
| 20 | @abstractmethod  | 
            ||
| 21 | def _run(self, **kwargs):  | 
            ||
| 22 | pass  | 
            ||
| 23 | |||
| 24 | def run(self, **kwargs):  | 
            ||
| 25 | # Removing empty strings, None from kwargs without excluding 0  | 
            ||
| 26 |         args = {k: v for k, v in kwargs.iteritems() | 
            ||
| 27 | if str(v).strip() and v is not None}  | 
            ||
| 28 | out = self._run(**args)  | 
            ||
| 29 |         errors = out.get("errors") | 
            ||
| 30 | if errors:  | 
            ||
| 31 | return (False, errors)  | 
            ||
| 32 | return (True, out)  | 
            ||
| 33 |