-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/development' into development
- Loading branch information
Showing
129 changed files
with
4,920 additions
and
1,837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This is a stub package designed to roughly emulate the _yaml | ||
# extension module, which previously existed as a standalone module | ||
# and has been moved into the `yaml` package namespace. | ||
# It does not perfectly mimic its old counterpart, but should get | ||
# close enough for anyone who's relying on it even when they shouldn't. | ||
import yaml | ||
|
||
# in some circumstances, the yaml module we imoprted may be from a different version, so we need | ||
# to tread carefully when poking at it here (it may not have the attributes we expect) | ||
if not getattr(yaml, '__with_libyaml__', False): | ||
from sys import version_info | ||
|
||
exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError | ||
raise exc("No module named '_yaml'") | ||
else: | ||
from yaml._yaml import * | ||
import warnings | ||
warnings.warn( | ||
'The _yaml extension module is now located at yaml._yaml' | ||
' and its location is subject to change. To use the' | ||
' LibYAML-based parser and emitter, import from `yaml`:' | ||
' `from yaml import CLoader as Loader, CDumper as Dumper`.', | ||
DeprecationWarning | ||
) | ||
del warnings | ||
# Don't `del yaml` here because yaml is actually an existing | ||
# namespace member of _yaml. | ||
|
||
__name__ = '_yaml' | ||
# If the module is top-level (i.e. not a part of any specific package) | ||
# then the attribute should be set to ''. | ||
# https://docs.python.org/3.8/library/types.html | ||
__package__ = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# BSD 3-Clause License | ||
# BSD 2-Clause License | ||
# | ||
# Apprise - Push Notification Library. | ||
# Copyright (c) 2023, Chris Caron <[email protected]> | ||
|
@@ -14,10 +14,6 @@ | |
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
|
@@ -458,7 +454,7 @@ def _create_notify_gen(self, body, title='', | |
logger.error(msg) | ||
raise TypeError(msg) | ||
|
||
if not (title or body): | ||
if not (title or body or attach): | ||
msg = "No message content specified to deliver" | ||
logger.error(msg) | ||
raise TypeError(msg) | ||
|
@@ -498,25 +494,29 @@ def _create_notify_gen(self, body, title='', | |
# If our code reaches here, we either did not define a tag (it | ||
# was set to None), or we did define a tag and the logic above | ||
# determined we need to notify the service it's associated with | ||
if server.notify_format not in conversion_body_map: | ||
# Perform Conversion | ||
conversion_body_map[server.notify_format] = \ | ||
convert_between( | ||
body_format, server.notify_format, content=body) | ||
|
||
# First we need to generate a key we will use to determine if we | ||
# need to build our data out. Entries without are merged with | ||
# the body at this stage. | ||
key = server.notify_format if server.title_maxlen > 0\ | ||
else f'_{server.notify_format}' | ||
|
||
if key not in conversion_title_map: | ||
|
||
# Prepare our title | ||
conversion_title_map[server.notify_format] = \ | ||
'' if not title else title | ||
conversion_title_map[key] = '' if not title else title | ||
|
||
# Tidy Title IF required (hence it will become part of the | ||
# body) | ||
if server.title_maxlen <= 0 and \ | ||
conversion_title_map[server.notify_format]: | ||
# Conversion of title only occurs for services where the title | ||
# is blended with the body (title_maxlen <= 0) | ||
if conversion_title_map[key] and server.title_maxlen <= 0: | ||
conversion_title_map[key] = convert_between( | ||
body_format, server.notify_format, | ||
content=conversion_title_map[key]) | ||
|
||
conversion_title_map[server.notify_format] = \ | ||
convert_between( | ||
body_format, server.notify_format, | ||
content=conversion_title_map[server.notify_format]) | ||
# Our body is always converted no matter what | ||
conversion_body_map[key] = \ | ||
convert_between( | ||
body_format, server.notify_format, content=body) | ||
|
||
if interpret_escapes: | ||
# | ||
|
@@ -526,13 +526,13 @@ def _create_notify_gen(self, body, title='', | |
try: | ||
# Added overhead required due to Python 3 Encoding Bug | ||
# identified here: https://bugs.python.org/issue21331 | ||
conversion_body_map[server.notify_format] = \ | ||
conversion_body_map[server.notify_format]\ | ||
conversion_body_map[key] = \ | ||
conversion_body_map[key]\ | ||
.encode('ascii', 'backslashreplace')\ | ||
.decode('unicode-escape') | ||
|
||
conversion_title_map[server.notify_format] = \ | ||
conversion_title_map[server.notify_format]\ | ||
conversion_title_map[key] = \ | ||
conversion_title_map[key]\ | ||
.encode('ascii', 'backslashreplace')\ | ||
.decode('unicode-escape') | ||
|
||
|
@@ -543,8 +543,8 @@ def _create_notify_gen(self, body, title='', | |
raise TypeError(msg) | ||
|
||
kwargs = dict( | ||
body=conversion_body_map[server.notify_format], | ||
title=conversion_title_map[server.notify_format], | ||
body=conversion_body_map[key], | ||
title=conversion_title_map[key], | ||
notify_type=notify_type, | ||
attach=attach, | ||
body_format=body_format | ||
|
@@ -685,6 +685,11 @@ def details(self, lang=None, show_requirements=False, show_disabled=False): | |
# Placeholder - populated below | ||
'details': None, | ||
|
||
# Let upstream service know of the plugins that support | ||
# attachments | ||
'attachment_support': getattr( | ||
plugin, 'attachment_support', False), | ||
|
||
# Differentiat between what is a custom loaded plugin and | ||
# which is native. | ||
'category': getattr(plugin, 'category', None) | ||
|
@@ -810,6 +815,36 @@ def __getitem__(self, index): | |
# If we reach here, then we indexed out of range | ||
raise IndexError('list index out of range') | ||
|
||
def __getstate__(self): | ||
""" | ||
Pickle Support dumps() | ||
""" | ||
attributes = { | ||
'asset': self.asset, | ||
# Prepare our URL list as we need to extract the associated tags | ||
# and asset details associated with it | ||
'urls': [{ | ||
'url': server.url(privacy=False), | ||
'tag': server.tags if server.tags else None, | ||
'asset': server.asset} for server in self.servers], | ||
'locale': self.locale, | ||
'debug': self.debug, | ||
'location': self.location, | ||
} | ||
|
||
return attributes | ||
|
||
def __setstate__(self, state): | ||
""" | ||
Pickle Support loads() | ||
""" | ||
self.servers = list() | ||
self.asset = state['asset'] | ||
self.locale = state['locale'] | ||
self.location = state['location'] | ||
for entry in state['urls']: | ||
self.add(entry['url'], asset=entry['asset'], tag=entry['tag']) | ||
|
||
def __bool__(self): | ||
""" | ||
Allows the Apprise object to be wrapped in an 'if statement'. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# BSD 3-Clause License | ||
# BSD 2-Clause License | ||
# | ||
# Apprise - Push Notification Library. | ||
# Copyright (c) 2023, Chris Caron <[email protected]> | ||
|
@@ -14,10 +14,6 @@ | |
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# BSD 3-Clause License | ||
# BSD 2-Clause License | ||
# | ||
# Apprise - Push Notification Library. | ||
# Copyright (c) 2023, Chris Caron <[email protected]> | ||
|
@@ -14,10 +14,6 @@ | |
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# BSD 3-Clause License | ||
# BSD 2-Clause License | ||
# | ||
# Apprise - Push Notification Library. | ||
# Copyright (c) 2023, Chris Caron <[email protected]> | ||
|
@@ -14,10 +14,6 @@ | |
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
|
Oops, something went wrong.