Definition at line 659 of file Utils.py.
◆ __init__()
def app.Utils.UrlNormalizator.__init__ |
( |
|
self | ) |
|
Definition at line 669 of file Utils.py.
def __init__(self)
constructor
◆ entitiesEncode()
def app.Utils.UrlNormalizator.entitiesEncode |
( |
|
url, |
|
|
|
entities = None |
|
) |
| |
|
static |
Definition at line 728 of file Utils.py.
728 def entitiesEncode(url, entities=None):
731 entities = {
"&":
"&"}
734 le = len(entities[k])
738 p = ret.find(k, p + 1)
742 if (p + le - 1 > l)
or ((p + le - 1 <= l)
and (ret[p:p + le] != entities[k])):
743 ret = ret[:p] + entities[k] + ret[p + 1:]
◆ isNormalUrl()
def app.Utils.UrlNormalizator.isNormalUrl |
( |
|
url | ) |
|
|
static |
Definition at line 718 of file Utils.py.
718 def isNormalUrl(url):
719 return False if url.find(UrlNormalizator.BAD_URL_PREFIX) == 0
else True
◆ normalize()
def app.Utils.UrlNormalizator.normalize |
( |
|
url, |
|
|
|
supportProtocols = None , |
|
|
|
normMask = NORM_DEFAULT |
|
) |
| |
|
static |
Definition at line 678 of file Utils.py.
678 def normalize(url, supportProtocols=None, normMask=NORM_DEFAULT):
679 norm_url = url.strip()
681 logger.debug(
"None zero normMask: %s", str(normMask))
683 if supportProtocols
is not None and isinstance(supportProtocols, list):
684 colonPos = norm_url.find(
':')
685 slashPos = norm_url.find(
'/')
686 if colonPos != -1
and (slashPos == -1
or slashPos > colonPos):
687 if len(norm_url.split(
':')) > 1:
688 protocol = norm_url.split(
':')[0]
689 if protocol
not in supportProtocols:
691 norm_url = UrlNormalizator.BAD_URL_PREFIX + urllib.quote(norm_url)
692 except Exception
as err:
693 logger.debug(
">>> urllib.quote error = " + str(err))
694 norm_url = UrlNormalizator.BAD_URL_PREFIX + norm_url
698 stripWWW =
True if normMask & UrlNormalizator.NORM_SKIP_WWW
else False 699 useValidator =
True if normMask & UrlNormalizator.NORM_USE_VALIDATOR
else False 700 enableAdditionNormalize =
True if normMask & UrlNormalizator.NORM_MAIN
else False 701 norm_url = str(
urinormpath(url.strip(), stripWWW, useValidator, enableAdditionNormalize))
707 except Exception
as e:
708 logger.error(
"Normalization error: " + str(e) +
"\nURL: [" + url +
"]\n" + str(
getTracebackInfo()))
def urinormpath(path, stripWWW=False, useValidator=False, enableAdditionNormalize=True)
def getTracebackInfo(linesNumberMax=None)
◆ BAD_URL_PREFIX
string app.Utils.UrlNormalizator.BAD_URL_PREFIX = "normalization-error://?" |
|
static |
◆ NORM_DEFAULT
int app.Utils.UrlNormalizator.NORM_DEFAULT = NORM_MAIN |
|
static |
◆ NORM_MAIN
int app.Utils.UrlNormalizator.NORM_MAIN = 4 |
|
static |
◆ NORM_NONE
int app.Utils.UrlNormalizator.NORM_NONE = 0 |
|
static |
◆ NORM_SKIP_WWW
int app.Utils.UrlNormalizator.NORM_SKIP_WWW = 1 |
|
static |
◆ NORM_USE_VALIDATOR
int app.Utils.UrlNormalizator.NORM_USE_VALIDATOR = 2 |
|
static |
The documentation for this class was generated from the following file: