]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Applying flake8 to lib/webhooks/base_app.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 14 Sep 2018 13:08:58 +0000 (15:08 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 14 Sep 2018 13:08:58 +0000 (15:08 +0200)
lib/webhooks/__init__.py
lib/webhooks/base_app.py

index cb0ae013c38ee0e3f042209613fdd47c625dfee1..847cf0dd480b3dfd6429adc91484c0d6ca9e7af6 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '1.0.1'
+__version__ = '1.1.0'
 
 # vim: ts=4 et list
index 9b8e7e255e710f62c0d0063a9d1768fcecccaf8f..63f02afd8786e19146f2fb3cecc586840406591b 100644 (file)
@@ -558,6 +558,12 @@ class BaseHookApp(BaseObject):
     # -------------------------------------------------------------------------
     def evaluate_config(self, config, yaml_file):
 
+        self._evaluate_general_config(config, yaml_file)
+        self.__evaluate_mail_config(config, yaml_file)
+
+    # -------------------------------------------------------------------------
+    def _evaluate_general_config(self, config, yaml_file):
+
         if 'verbose' in config:
             try:
                 v = int(config['verbose'])
@@ -575,36 +581,12 @@ class BaseHookApp(BaseObject):
         if 'simulate' in config and not self.simulate:
             self.simulate = config['simulate']
 
-        if 'no_error_mail' in config and not self.no_error_mail:
-            self.no_error_mail = to_bool(config['no_error_mail'])
-
         if 'do_sudo' in config:
             self.do_sudo = to_bool(config['do_sudo'])
 
         if 'log_dir' in config and config['log_dir']:
             self._log_directory = config['log_dir']
 
-        if 'default_email' in config and config['default_email']:
-            self.default_email = config['default_email']
-
-        if 'sender_address' in config and config['sender_address']:
-            self.sender_address = config['sender_address']
-
-        if 'smtp_server' in config and config['smtp_server'].strip():
-            self.smtp_server = config['smtp_server'].strip()
-
-        if 'smtp_port' in config and config['smtp_port']:
-            msg = "Invalid port {p!r} for SMTP in {f!r} found.".format(
-                p=config['smtp_port'], f=yaml_file)
-            try:
-                port = int(config['smtp_port'])
-                if port > 0 and port < 2**16:
-                    self.smtp_port = port
-                else:
-                    self.error_data.append(msg)
-            except ValueError:
-                self.error_data.append(msg)
-
         if 'default_parent_dir' in config and config['default_parent_dir']:
             pdir = config['default_parent_dir']
             if os.path.isabs(pdir):
@@ -626,6 +608,33 @@ class BaseHookApp(BaseObject):
         elif 'cache_file' in config:
             self._cachefile = config['cache_file']
 
+    # -------------------------------------------------------------------------
+    def __evaluate_mail_config(self, config, yaml_file):
+
+        if 'no_error_mail' in config and not self.no_error_mail:
+            self.no_error_mail = to_bool(config['no_error_mail'])
+
+        if 'default_email' in config and config['default_email']:
+            self.default_email = config['default_email']
+
+        if 'sender_address' in config and config['sender_address']:
+            self.sender_address = config['sender_address']
+
+        if 'smtp_server' in config and config['smtp_server'].strip():
+            self.smtp_server = config['smtp_server'].strip()
+
+        if 'smtp_port' in config and config['smtp_port']:
+            msg = "Invalid port {p!r} for SMTP in {f!r} found.".format(
+                p=config['smtp_port'], f=yaml_file)
+            try:
+                port = int(config['smtp_port'])
+                if port > 0 and port < 2**16:
+                    self.smtp_port = port
+                else:
+                    self.error_data.append(msg)
+            except ValueError:
+                self.error_data.append(msg)
+
         if 'mail_cc_addresses' in config:
             if config['mail_cc_addresses'] is None:
                 self.mail_cc_addresses = []
@@ -1074,8 +1083,8 @@ class BaseHookApp(BaseObject):
 
         return True
 
-# =============================================================================
 
+# =============================================================================
 if __name__ == "__main__":
 
     pass