Exemplo n.º 1
0
def getPreset(name, prefix=None):
    key = name.lower()
    if key in PRESETS.keys():
        return PRESETS[key]
    prefixN = re_prefixN.match(key)
    if prefixN:
        stems = split_lru_in_stems(prefix)
        return PREFIXN % (int(prefixN.group(1)) + len(stems) - 1)
    subdomN = re_subdomN.match(key)
    if subdomN:
        return SUBDOMN % (int(subdomN.group(1)) + 1)
    pathN = re_pathN.match(key)
    if pathN:
        return PATHN % int(pathN.group(1))
    return name
Exemplo n.º 2
0
def getPreset(name, prefix=None):
    key = name.lower()
    if key in PRESETS.keys():
        return PRESETS[key]
    prefixN = re_prefixN.match(key)
    if prefixN:
        stems = split_lru_in_stems(prefix)
        return PREFIXN % (int(prefixN.group(1)) + len(stems) - 1)
    subdomN = re_subdomN.match(key)
    if subdomN:
        return SUBDOMN % (int(subdomN.group(1)) + 1)
    pathN = re_pathN.match(key)
    if pathN:
        return PATHN % int(pathN.group(1))
    return name
Exemplo n.º 3
0
def getName(regexp, prefix=None):
    for k, v in PRESETS.items():
        if regexp == v:
            return k
    digit = re_regN.search(regexp)
    if regexp.startswith("(%s(%s)" % (SCHEME, ANY)) and digit:
        lev = int(digit.group(1)) + 1 - len(split_lru_in_stems(prefix))
        return "prefix+%s" % lev
    elif regexp.startswith("(%s" % DEFAULT) and digit:
        sreg = regexp.replace("(%s" % DEFAULT, "")
        lev = int(digit.group(1))
        typ = "path"
        if sreg.startswith("+(%s)" % PATH):
            typ = "path"
        else:
            lev -= 1
            typ = "subdomain"
        return "%s-%s" % (typ, lev)
    return 'unknown regexp'
Exemplo n.º 4
0
def getName(regexp, prefix=None):
    for k, v in PRESETS.items():
        if regexp == v:
            return k
    digit = re_regN.search(regexp)
    if regexp.startswith("(%s(%s)" % (SCHEME, ANY)) and digit:
        lev = int(digit.group(1)) + 1 - len(split_lru_in_stems(prefix))
        return "prefix+%s" % lev
    elif regexp.startswith("(%s" % DEFAULT) and digit:
        sreg = regexp.replace("(%s" % DEFAULT, "")
        lev = int(digit.group(1))
        typ = "path"
        if sreg.startswith("+(%s)" % PATH):
            typ = "path"
        else:
            lev -= 1
            typ = "subdomain"
        return "%s-%s" % (typ, lev)
    return 'unknown regexp'