# -*- coding: utf-8 -*-

import re

SCHEME = "s:[a-zA-Z]+\\|"
PORT = "t:[0-9]+\\|"
HOST = "h:[^\\|]+\\|"
PATH = "p:[^\\|]+\\|"

DEFAULT = "(%s(%s)?%s(%s)+)" % (SCHEME, PORT, HOST, HOST)

PRESETS = {
  "subdomain": DEFAULT,
  "domain": "(%s(%s)?%s%s)" % (SCHEME, PORT, HOST, HOST),
  "page": "(.*)$"
}

PATHN = ("(%s(%s)?%s(%s)+(%s)" % (SCHEME, PORT, HOST, HOST, PATH)) + "{%d})"

re_pathN = re.compile(r"path-(\d+)$")

def getPreset(name):
    key = name.lower()
    if key in PRESETS.keys():
        return PRESETS[keys]
    pathN = re_pathN.match(key)
    if pathN:
        return PATHN % int(pathN.group(1))
    return name


@@ -204,16 +204,17 @@
 ubdomain
+s
 %22: DEFAU
@@ -217,16 +217,16 @@
 EFAULT,%0A
-
   %22domai
@@ -296,16 +296,130 @@
 *)$%22%0A%7D%0A%0A
+SUBDOMN = %22(%25s(%25s)?%25s(%25s)%22 %25 (SCHEME, PORT, HOST, HOST)) + %22%7B%25d%7D)%22%0A%0Are_subdomN = re.compile(r%22subdomain-(%5Cd+)$%22)%0A%0A
 PATHN = 
@@ -601,16 +601,16 @@
 keys():%0A
-
         
@@ -630,16 +630,115 @@
 S%5Bkeys%5D%0A
+    subdomN = re_subdomN.match(key)%0A    if subdomN:%0A        return SUBDOMN %25 int(subdomN.group(1))%0A
     path

add finer subdomains preset creationrules