Skip to content

Commit

Permalink
Code Cleanup and Tidying (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc authored Dec 28, 2022
1 parent 0b1655c commit 4ecfe7f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
8 changes: 3 additions & 5 deletions apprise/plugins/NotifyMailgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ class NotifyMailgun(NotifyBase):
# Default Notify Format
notify_format = NotifyFormat.HTML

# The default region to use if one isn't otherwise specified
mailgun_default_region = MailgunRegion.US

# The maximum amount of emails that can reside within a single
# batch transfer
default_batch_size = 2000
Expand Down Expand Up @@ -250,7 +247,8 @@ def __init__(self, apikey, targets, cc=None, bcc=None, from_addr=None,

# Store our region
try:
self.region_name = self.mailgun_default_region \
self.region_name = \
NotifyMailgun.template_args['region']['default'] \
if region_name is None else region_name.lower()

if self.region_name not in MAILGUN_REGIONS:
Expand Down Expand Up @@ -667,7 +665,7 @@ def parse_url(url):
NotifyMailgun.unquote(results['qsd']['name'])

if 'region' in results['qsd'] and len(results['qsd']['region']):
# Extract from name to associate with from address
# Acquire region if defined
results['region_name'] = \
NotifyMailgun.unquote(results['qsd']['region'])

Expand Down
3 changes: 3 additions & 0 deletions apprise/plugins/NotifySMSEagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ def url(self, privacy=False, *args, **kwargs):
['@{}'.format(x) for x in self.target_contacts],
# Groups
['#{}'.format(x) for x in self.target_groups],
# Pass along the same invalid entries as were provided
self.invalid_targets,
)]),
params=NotifySMSEagle.urlencode(params),
)
Expand Down Expand Up @@ -633,6 +635,7 @@ def parse_url(url):
results['status'] = \
parse_bool(results['qsd'].get('status', False))

# Get priority
if 'priority' in results['qsd'] and len(results['qsd']['priority']):
results['priority'] = \
NotifySMSEagle.unquote(results['qsd']['priority'])
Expand Down
11 changes: 5 additions & 6 deletions apprise/plugins/NotifySparkPost.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@
}


# Priorities
class SparkPostRegion:
"""
Regions
"""
US = 'us'
EU = 'eu'

Expand Down Expand Up @@ -141,9 +143,6 @@ class NotifySparkPost(NotifyBase):
# Default Notify Format
notify_format = NotifyFormat.HTML

# The default region to use if one isn't otherwise specified
sparkpost_default_region = SparkPostRegion.US

# Define object templates
templates = (
'{schema}://{user}@{host}:{apikey}/',
Expand Down Expand Up @@ -254,7 +253,7 @@ def __init__(self, apikey, targets, cc=None, bcc=None, from_name=None,

# Store our region
try:
self.region_name = self.sparkpost_default_region \
self.region_name = self.template_args['region']['default'] \
if region_name is None else region_name.lower()

if self.region_name not in SPARKPOST_REGIONS:
Expand Down Expand Up @@ -746,7 +745,7 @@ def parse_url(url):
NotifySparkPost.unquote(results['qsd']['name'])

if 'region' in results['qsd'] and len(results['qsd']['region']):
# Extract from name to associate with from address
# Extract region
results['region_name'] = \
NotifySparkPost.unquote(results['qsd']['region'])

Expand Down
1 change: 0 additions & 1 deletion test/test_plugin_msteams.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ def request_mock(mocker):

@pytest.fixture
def simple_template(tmpdir):
# Test cases where our URL is invalid.
template = tmpdir.join("simple.json")
template.write("""
{
Expand Down

0 comments on commit 4ecfe7f

Please sign in to comment.