# -*- coding: utf-8 -*- # # Base Notify Wrapper # # Copyright (C) 2017-2018 Chris Caron # # This file is part of apprise. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. import re import logging from time import sleep try: # Python 2.7 from urllib import unquote as _unquote from urllib import quote as _quote from urllib import urlencode as _urlencode except ImportError: # Python 3.x from urllib.parse import unquote as _unquote from urllib.parse import quote as _quote from urllib.parse import urlencode as _urlencode from ..utils import parse_url from ..utils import parse_bool from ..utils import is_hostname from ..common import NOTIFY_TYPES from ..common import NotifyFormat from ..common import NOTIFY_FORMATS from ..AppriseAsset import AppriseAsset # use sax first because it's faster from xml.sax.saxutils import escape as sax_escape def _escape(text): """ saxutil escape tool """ return sax_escape(text, {"'": "'", "\"": """}) HTTP_ERROR_MAP = { 400: 'Bad Request - Unsupported Parameters.', 401: 'Verification Failed.', 404: 'Page not found.', 405: 'Method not allowed.', 500: 'Internal server error.', 503: 'Servers are overloaded.', } # HTML New Line Delimiter NOTIFY_NEWLINE = '\r\n' # Used to break a path list into parts 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