From 4479a7f71bf37058476dc68b6ad18cd47d1baaf4 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Mon, 8 Oct 2018 15:21:08 -0400 Subject: [PATCH] details() preview commit for review; refs #21 --- apprise/Apprise.py | 33 +++++++++++++++++ apprise/AppriseAsset.py | 15 ++++++++ apprise/plugins/NotifyBase.py | 17 +++++++-- apprise/plugins/NotifyBoxcar.py | 9 +++++ apprise/plugins/NotifyDiscord.py | 8 ++++ apprise/plugins/NotifyEmail.py | 16 +++++--- apprise/plugins/NotifyEmby.py | 8 ++++ apprise/plugins/NotifyFaast.py | 9 +++++ apprise/plugins/NotifyGrowl/NotifyGrowl.py | 9 +++++ test/test_api.py | 43 ++++++++++++++++++++++ 10 files changed, 158 insertions(+), 9 deletions(-) diff --git a/apprise/Apprise.py b/apprise/Apprise.py index 8512ea14..bd81f5d5 100644 --- a/apprise/Apprise.py +++ b/apprise/Apprise.py @@ -32,6 +32,7 @@ from .AppriseAsset import AppriseAsset from . import NotifyBase from . import plugins +from . import __version__ logger = logging.getLogger(__name__) @@ -277,6 +278,38 @@ class Apprise(object): return status + def details(self): + """ + Returns the details associated with the Apprise object + + """ + + # general object returned + response = { + # Defines the current version of Apprise + 'version': __version__, + # Lists all of the currently supported Notifications + 'schemas': [], + # Includes the configured asset details + 'asset': self.asset.details(), + } + + # to add it's mapping to our hash table + for entry in sorted(dir(plugins)): + + # Get our plugin + plugin = getattr(plugins, entry) + + # Build our response object + response['schemas'].append({ + 'service_name': getattr(plugin, 'service_name', None), + 'service_url': getattr(plugin, 'service_url', None), + 'protocol': getattr(plugin, 'protocol', None), + 'secure_protocol': getattr(plugin, 'secure_protocol', None), + }) + + return response + def __len__(self): """ Returns the number of servers loaded diff --git a/apprise/AppriseAsset.py b/apprise/AppriseAsset.py index 5bbba2a9..4af1c72b 100644 --- a/apprise/AppriseAsset.py +++ b/apprise/AppriseAsset.py @@ -216,6 +216,21 @@ class AppriseAsset(object): return None + def details(self): + """ + Returns the details associated with the AppriseAsset object + + """ + return { + 'app_id': self.app_id, + 'app_desc': self.app_desc, + 'default_extension': self.default_extension, + 'theme': self.theme, + 'image_path_mask': self.image_url_mask, + 'image_url_mask': self.image_url_mask, + 'image_url_logo': self.image_url_logo, + } + @staticmethod def hex_to_rgb(value): """ diff --git a/apprise/plugins/NotifyBase.py b/apprise/plugins/NotifyBase.py index 9f028499..0a8a3687 100644 --- a/apprise/plugins/NotifyBase.py +++ b/apprise/plugins/NotifyBase.py @@ -34,7 +34,6 @@ except ImportError: from ..utils import parse_url from ..utils import parse_bool from ..utils import is_hostname -from ..common import NOTIFY_IMAGE_SIZES from ..common import NOTIFY_TYPES from ..common import NotifyFormat from ..common import NOTIFY_FORMATS @@ -70,7 +69,8 @@ PATHSPLIT_LIST_DELIM = re.compile(r'[ \t\r\n,\\/]+') # Regular expression retrieved from: # http://www.regular-expressions.info/email.html IS_EMAIL_RE = re.compile( - r"(?P[a-z0-9$%+=_~-]+" + r"((?P