1- # -*- coding: utf-8 -*-
21# BSD 2-Clause License
32#
43# Apprise - Push Notification Library.
2827
2928import asyncio
3029import concurrent .futures as cf
31- import os
3230from itertools import chain
33- from . import common
31+ import os
32+
33+ from . import __version__ , common , plugins
34+ from .apprise_attachment import AppriseAttachment
35+ from .apprise_config import AppriseConfig
36+ from .asset import AppriseAsset
37+ from .config .base import ConfigBase
3438from .conversion import convert_between
35- from .utils .logic import is_exclusive_match
36- from .utils .parse import parse_list , parse_urls
37- from .utils .cwe312 import cwe312_url
38- from .manager_plugins import NotificationManager
3939from .emojis import apply_emojis
40- from .logger import logger
41- from .asset import AppriseAsset
42- from .apprise_config import AppriseConfig
43- from .apprise_attachment import AppriseAttachment
4440from .locale import AppriseLocale
45- from .config .base import ConfigBase
41+ from .logger import logger
42+ from .manager_plugins import NotificationManager
4643from .plugins .base import NotifyBase
47-
48- from . import plugins
49- from . import __version__
44+ from . utils . cwe312 import cwe312_url
45+ from .utils . logic import is_exclusive_match
46+ from .utils . parse import parse_list , parse_urls
5047
5148# Grant access to our Notification Manager Singleton
5249N_MGR = NotificationManager ()
@@ -70,7 +67,7 @@ def __init__(self, servers=None, asset=None, location=None, debug=False):
7067 """
7168
7269 # Initialize a server list of URLs
73- self .servers = list ()
70+ self .servers = []
7471
7572 # Assigns an central asset object that will be later passed into each
7673 # notification plugin. Assets contain information such as the local
@@ -147,14 +144,14 @@ def instantiate(url, asset=None, tag=None, suppress_exceptions=True):
147144 logger .trace (
148145 'Invalid dictionary unpacked as:{}{}' .format (
149146 os .linesep , os .linesep .join (
150- ['{ }="{}"'. format ( k , v )
147+ [f' { k } ="{ v } "'
151148 for k , v in results .items ()])))
152149 return None
153150
154151 logger .trace (
155152 'Dictionary unpacked as:{}{}' .format (
156153 os .linesep , os .linesep .join (
157- ['{ }="{}"'. format ( k , v ) for k , v in results .items ()])))
154+ [f' { k } ="{ v } "' for k , v in results .items ()])))
158155
159156 # Otherwise we handle the invalid input specified
160157 else :
@@ -264,8 +261,7 @@ def add(self, servers, asset=None, tag=None):
264261
265262 elif not isinstance (servers , (tuple , set , list )):
266263 logger .error (
267- "An invalid notification (type={}) was specified." .format (
268- type (servers )))
264+ f"An invalid notification (type={ type (servers )} ) was specified." )
269265 return False
270266
271267 for _server in servers :
@@ -277,8 +273,7 @@ def add(self, servers, asset=None, tag=None):
277273
278274 elif not isinstance (_server , (str , dict )):
279275 logger .error (
280- "An invalid notification (type={}) was specified." .format (
281- type (_server )))
276+ f"An invalid notification (type={ type (_server )} ) was specified." )
282277 return_status = False
283278 continue
284279
@@ -469,13 +464,13 @@ def _create_notify_gen(self, body, title='',
469464
470465 except UnicodeDecodeError :
471466 msg = 'The content passed into Apprise was not of encoding ' \
472- 'type: {}' . format ( self .asset .encoding )
467+ f 'type: { self .asset .encoding } '
473468 logger .error (msg )
474469 raise TypeError (msg )
475470
476471 # Tracks conversions
477- conversion_body_map = dict ()
478- conversion_title_map = dict ()
472+ conversion_body_map = {}
473+ conversion_title_map = {}
479474
480475 # Prepare attachments if required
481476 if attach is not None and not isinstance (attach , AppriseAttachment ):
@@ -510,7 +505,7 @@ def _create_notify_gen(self, body, title='',
510505 if key not in conversion_title_map :
511506
512507 # Prepare our title
513- conversion_title_map [key ] = '' if not title else title
508+ conversion_title_map [key ] = title if title else ''
514509
515510 # Conversion of title only occurs for services where the title
516511 # is blended with the body (title_maxlen <= 0)
@@ -558,13 +553,13 @@ def _create_notify_gen(self, body, title='',
558553 conversion_title_map [key ] = \
559554 apply_emojis (conversion_title_map [key ])
560555
561- kwargs = dict (
562- body = conversion_body_map [key ],
563- title = conversion_title_map [key ],
564- notify_type = notify_type ,
565- attach = attach ,
566- body_format = body_format
567- )
556+ kwargs = {
557+ ' body' : conversion_body_map [key ],
558+ ' title' : conversion_title_map [key ],
559+ ' notify_type' : notify_type ,
560+ ' attach' : attach ,
561+ ' body_format' : body_format
562+ }
568563 yield (server , kwargs )
569564
570565 @staticmethod
@@ -861,7 +856,7 @@ def __setstate__(self, state):
861856 """
862857 Pickle Support loads()
863858 """
864- self .servers = list ()
859+ self .servers = []
865860 self .asset = state ['asset' ]
866861 self .locale = state ['locale' ]
867862 self .location = state ['location' ]
0 commit comments