Browse Source

Deprication Cleanup and Code Tidy (#593)

pull/598/head
Chris Caron 3 years ago committed by GitHub
parent
commit
9ef8e72952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .github/PULL_REQUEST_TEMPLATE.md
  2. 3
      CONTRIBUTIONS.md
  3. 12
      apprise/plugins/NotifyAppriseAPI.py
  4. 9
      apprise/plugins/NotifyBoxcar.py
  5. 7
      apprise/plugins/NotifyEmail.py
  6. 12
      apprise/plugins/NotifyEnigma2.py
  7. 12
      apprise/plugins/NotifyForm.py
  8. 12
      apprise/plugins/NotifyJSON.py
  9. 13
      apprise/plugins/NotifyNextcloud.py
  10. 13
      apprise/plugins/NotifyNextcloudTalk.py
  11. 12
      apprise/plugins/NotifyNotica.py
  12. 31
      apprise/plugins/NotifyNtfy.py
  13. 2
      apprise/plugins/NotifyStreamlabs.py
  14. 12
      apprise/plugins/NotifyXML.py
  15. 23
      apprise/plugins/NotifyXMPP/SliXmppAdapter.py
  16. 2
      test/test_plugin_apprise_api.py
  17. 2
      test/test_plugin_custom_form.py
  18. 2
      test/test_plugin_custom_json.py
  19. 2
      test/test_plugin_custom_xml.py
  20. 12
      test/test_plugin_email.py
  21. 2
      test/test_plugin_enigma2.py
  22. 2
      test/test_plugin_nextcloud.py
  23. 2
      test/test_plugin_nextcloudtalk.py
  24. 4
      test/test_plugin_notica.py

6
.github/PULL_REQUEST_TEMPLATE.md

@ -6,8 +6,8 @@
## New Service Completion Status
<!-- This section is only applicable if you're adding a new service -->
* [ ] apprise/plugins/Notify<!--ServiceName goes here-->.py
* [ ] setup.py
- add new service into the `KEYWORDS` file located in the root directory
* [ ] KEYWORDS
- add new service into this file (alphabetically).
* [ ] README.md
- add entry for new service to table (as a quick reference)
* [ ] packaging/redhat/python-apprise.spec
@ -37,7 +37,7 @@ source bin/activate
# Install the branch
pip install git+https://github.com/caronc/apprise.git@<this.branch-name>
# Be sure you're running your Signal API Server and query it like so
# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
<apprise url related to ticket>

3
CONTRIBUTIONS.md

@ -24,3 +24,6 @@ The contributors have been listed in chronological order:
* Andreas Motl <andreas@getkotori.org>
* Mar 2020 - Fix XMPP Support
* Joey Espinosa <@particledecay>
* Apr 3rd 2022 - Added Ntfy Support

12
apprise/plugins/NotifyAppriseAPI.py

@ -339,18 +339,10 @@ class NotifyAppriseAPI(NotifyBase):
return results
# Add our headers that the user can potentially over-ride if they wish
# to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based Apprise API header tokens are being "
" removed; use the plus (+) symbol instead.")
# Tidy our header entries by unquoting them
# to to our returned result set and tidy entries by unquoting them
results['headers'] = \
{NotifyAppriseAPI.unquote(x): NotifyAppriseAPI.unquote(y)
for x, y in results['headers'].items()}
for x, y in results['qsd+'].items()}
# Support the passing of tags in the URL
if 'tags' in results['qsd'] and len(results['qsd']['tags']):

9
apprise/plugins/NotifyBoxcar.py

@ -357,13 +357,8 @@ class NotifyBoxcar(NotifyBase):
# by default
entries = NotifyBoxcar.split_path(results['fullpath'])
try:
# Now fetch the remaining tokens
results['secret'] = entries.pop(0)
except IndexError:
# secret wasn't specified
results['secret'] = None
# Now fetch the remaining tokens
results['secret'] = entries.pop(0) if entries else None
# Our recipients make up the remaining entries of our array
results['targets'] = entries

7
apprise/plugins/NotifyEmail.py

@ -901,13 +901,6 @@ class NotifyEmail(NotifyBase):
# Extract from name to associate with from address
results['from_name'] = NotifyEmail.unquote(results['qsd']['name'])
if 'timeout' in results['qsd'] and len(results['qsd']['timeout']):
# Deprecated in favor of cto= flag
NotifyBase.logger.deprecate(
"timeout= argument is deprecated; use cto= instead.")
results['qsd']['cto'] = results['qsd']['timeout']
del results['qsd']['timeout']
# Store SMTP Host if specified
if 'smtp' in results['qsd'] and len(results['qsd']['smtp']):
# Extract the smtp server

12
apprise/plugins/NotifyEnigma2.py

@ -337,18 +337,10 @@ class NotifyEnigma2(NotifyBase):
return results
# Add our headers that the user can potentially over-ride if they wish
# to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based Enigma header tokens are being "
" removed; use the plus (+) symbol instead.")
# Tidy our header entries by unquoting them
# to to our returned result set and tidy entries by unquoting them
results['headers'] = {
NotifyEnigma2.unquote(x): NotifyEnigma2.unquote(y)
for x, y in results['headers'].items()}
for x, y in results['qsd+'].items()}
# Save timeout value (if specified)
if 'timeout' in results['qsd'] and len(results['qsd']['timeout']):

12
apprise/plugins/NotifyForm.py

@ -374,17 +374,9 @@ class NotifyForm(NotifyBase):
for x, y in results['qsd:'].items()}
# Add our headers that the user can potentially over-ride if they wish
# to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based Form header tokens are being "
" removed; use the plus (+) symbol instead.")
# Tidy our header entries by unquoting them
# to to our returned result set and tidy entries by unquoting them
results['headers'] = {NotifyForm.unquote(x): NotifyForm.unquote(y)
for x, y in results['headers'].items()}
for x, y in results['qsd+'].items()}
# Set method if not otherwise set
if 'method' in results['qsd'] and len(results['qsd']['method']):

12
apprise/plugins/NotifyJSON.py

@ -361,17 +361,9 @@ class NotifyJSON(NotifyBase):
for x, y in results['qsd:'].items()}
# Add our headers that the user can potentially over-ride if they wish
# to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based JSON header tokens are being "
" removed; use the plus (+) symbol instead.")
# Tidy our header entries by unquoting them
# to to our returned result set and tidy entries by unquoting them
results['headers'] = {NotifyJSON.unquote(x): NotifyJSON.unquote(y)
for x, y in results['headers'].items()}
for x, y in results['qsd+'].items()}
# Set method if not otherwise set
if 'method' in results['qsd'] and len(results['qsd']['method']):

13
apprise/plugins/NotifyNextcloud.py

@ -331,13 +331,10 @@ class NotifyNextcloud(NotifyBase):
results['version'] = \
NotifyNextcloud.unquote(results['qsd']['version'])
# Add our headers that the user can potentially over-ride if they
# wish to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based Nextcloud header tokens are being "
" removed; use the plus (+) symbol instead.")
# Add our headers that the user can potentially over-ride if they wish
# to to our returned result set and tidy entries by unquoting them
results['headers'] = {
NotifyNextcloud.unquote(x): NotifyNextcloud.unquote(y)
for x, y in results['qsd+'].items()}
return results

13
apprise/plugins/NotifyNextcloudTalk.py

@ -269,13 +269,10 @@ class NotifyNextcloudTalk(NotifyBase):
results['targets'] = \
NotifyNextcloudTalk.split_path(results['fullpath'])
# Add our headers that the user can potentially over-ride if they
# wish to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based Nextcloud Talk header tokens are being "
" removed; use the plus (+) symbol instead.")
# Add our headers that the user can potentially over-ride if they wish
# to to our returned result set and tidy entries by unquoting them
results['headers'] = {
NotifyNextcloudTalk.unquote(x): NotifyNextcloudTalk.unquote(y)
for x, y in results['qsd+'].items()}
return results

12
apprise/plugins/NotifyNotica.py

@ -364,13 +364,11 @@ class NotifyNotica(NotifyBase):
'/' if not entries else '/{}/'.format('/'.join(entries))
# Add our headers that the user can potentially over-ride if they
# wish to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based Notica header tokens are being "
" removed; use the plus (+) symbol instead.")
# wish to to our returned result set and tidy entries by unquoting
# them
results['headers'] = {
NotifyNotica.unquote(x): NotifyNotica.unquote(y)
for x, y in results['qsd+'].items()}
return results

31
apprise/plugins/NotifyNtfy.py

@ -1,24 +1,31 @@
# MIT License
# Copyright (c) 2022 Joey Espinosa <@particledecay>
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 Chris Caron <lead2gold@gmail.com>
# All rights reserved.
#
# This code is licensed under the MIT License.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# of this software and associated documentation files(the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# furnished to do so, subject to the following conditions :
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Great sources
# - https://github.com/matrix-org/matrix-python-sdk
# - https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.rst
#
# Examples:
# ntfys://my-topic

2
apprise/plugins/NotifyStreamlabs.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 <example@example.com>
# Copyright (C) 2021 Chris Caron <lead2gold@gmail.com>
# All rights reserved.
#
# This code is licensed under the MIT License.

12
apprise/plugins/NotifyXML.py

@ -414,17 +414,9 @@ class NotifyXML(NotifyBase):
for x, y in results['qsd:'].items()}
# Add our headers that the user can potentially over-ride if they wish
# to to our returned result set
results['headers'] = results['qsd+']
if results['qsd-']:
results['headers'].update(results['qsd-'])
NotifyBase.logger.deprecate(
"minus (-) based XML header tokens are being "
"removed; use the plus (+) symbol instead.")
# Tidy our header entries by unquoting them
# to to our returned result set and tidy entries by unquoting them
results['headers'] = {NotifyXML.unquote(x): NotifyXML.unquote(y)
for x, y in results['headers'].items()}
for x, y in results['qsd+'].items()}
# Set method if not otherwise set
if 'method' in results['qsd'] and len(results['qsd']['method']):

23
apprise/plugins/NotifyXMPP/SliXmppAdapter.py

@ -1,4 +1,27 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 Chris Caron <lead2gold@gmail.com>
# All rights reserved.
#
# This code is licensed under the MIT License.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files(the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions :
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import ssl
from os.path import isfile

2
test/test_plugin_apprise_api.py

@ -132,7 +132,7 @@ apprise_url_tests = (
# Our expected url(privacy=True) startswith() response:
'privacy_url': 'apprises://user:****@localhost:8080/m...5/',
}),
('apprises://localhost:8080/path?-HeaderKey=HeaderValue', {
('apprises://localhost:8080/path?+HeaderKey=HeaderValue', {
'instance': plugins.NotifyAppriseAPI,
}),
('apprise://localhost/%s' % ('a' * 32), {

2
test/test_plugin_custom_form.py

@ -112,7 +112,7 @@ apprise_url_tests = (
# Our expected url(privacy=True) startswith() response:
'privacy_url': 'forms://user:****@localhost:8080',
}),
('form://localhost:8080/path?-HeaderKey=HeaderValue', {
('form://localhost:8080/path?+HeaderKey=HeaderValue', {
'instance': plugins.NotifyForm,
}),
('form://user:pass@localhost:8081', {

2
test/test_plugin_custom_json.py

@ -100,7 +100,7 @@ apprise_url_tests = (
# Our expected url(privacy=True) startswith() response:
'privacy_url': 'jsons://user:****@localhost:8080',
}),
('json://localhost:8080/path?-HeaderKey=HeaderValue', {
('json://localhost:8080/path?+HeaderKey=HeaderValue', {
'instance': plugins.NotifyJSON,
}),
('json://user:pass@localhost:8081', {

2
test/test_plugin_custom_xml.py

@ -125,7 +125,7 @@ apprise_url_tests = (
('xmls://user:pass@localhost:8080', {
'instance': plugins.NotifyXML,
}),
('xml://localhost:8080/path?-HeaderKey=HeaderValue', {
('xml://localhost:8080/path?+HeaderKey=HeaderValue', {
'instance': plugins.NotifyXML,
}),
('xml://user:pass@localhost:8081', {

12
test/test_plugin_email.py

@ -113,18 +113,6 @@ TEST_URLS = (
('mailtos://user:pass@nuxref.com:567/l2g@nuxref.com', {
'instance': plugins.NotifyEmail,
}),
(
'mailtos://user:pass@example.com?smtp=smtp.example.com&timeout=5'
'&name=l2g&from=noreply@example.com', {
'instance': plugins.NotifyEmail,
},
),
('mailto://user:pass@example.com?timeout=invalid.entry', {
'instance': plugins.NotifyEmail,
}),
('mailto://user:pass@example.com?timeout=invalid.entry', {
'instance': plugins.NotifyEmail,
}),
(
'mailto://user:pass@example.com:2525?user=l2g@example.com'
'&pass=l2g@apprise!is!Awesome', {

2
test/test_plugin_enigma2.py

@ -144,7 +144,7 @@ apprise_url_tests = (
'result': True
},
}),
('enigma2://localhost:8080/path?-HeaderKey=HeaderValue', {
('enigma2://localhost:8080/path?+HeaderKey=HeaderValue', {
'instance': plugins.NotifyEnigma2,
'requests_response_text': {
'result': True

2
test/test_plugin_nextcloud.py

@ -96,7 +96,7 @@ apprise_url_tests = (
('nclouds://user:pass@localhost:8080/admin/', {
'instance': plugins.NotifyNextcloud,
}),
('ncloud://localhost:8080/admin?-HeaderKey=HeaderValue', {
('ncloud://localhost:8080/admin?+HeaderKey=HeaderValue', {
'instance': plugins.NotifyNextcloud,
}),
('ncloud://user:pass@localhost:8081/admin', {

2
test/test_plugin_nextcloudtalk.py

@ -85,7 +85,7 @@ apprise_url_tests = (
'instance': plugins.NotifyNextcloudTalk,
'requests_response_code': requests.codes.created,
}),
('nctalk://user:pass@localhost:8080/roomid?-HeaderKey=HeaderValue', {
('nctalk://user:pass@localhost:8080/roomid?+HeaderKey=HeaderValue', {
'instance': plugins.NotifyNextcloudTalk,
'requests_response_code': requests.codes.created,
}),

4
test/test_plugin_notica.py

@ -110,10 +110,6 @@ apprise_url_tests = (
('notica://localhost:8080//%s/?+HeaderKey=HeaderValue' % ('7' * 6), {
'instance': plugins.NotifyNotica,
}),
# Test Depricated Header overrides
('notica://localhost:8080//%s/?-HeaderKey=HeaderValue' % ('7' * 6), {
'instance': plugins.NotifyNotica,
}),
('notica://%s' % ('c' * 6), {
'instance': plugins.NotifyNotica,
# force a failure

Loading…
Cancel
Save