/tests/genre_test.py
Python | 73 lines | 47 code | 18 blank | 8 comment | 1 complexity | 9af4d30e1f9153724fe67b5dba6d2e46 MD5 | raw file
- # -*- coding: utf-8 -*-
- '''
- Created on 2010-7-23
-
- @author: GL
- '''
-
- from gae_rproxy.genre import *
- from gae_rproxy.rproxy import proxy_data_2, _build_pattern
-
- print gen('a\w+', ['b\s*'], ['c', 'd'], {"protocal":"(http|https)://"},)
-
- print gen('a', 'b', ['c', 'd', ('e', ['f']), {'g':'h'}], {'x':'y'}, {'l':'m'})
-
- print is_captured('(asdfasdfa)')
- print is_captured('(asdfasdfa\))a')
- print is_captured('(asdfasdf\)a)')
- print is_captured('(asdfa)(sdf\)a)')
- print is_captured('((\(asdfa)(sdf\)a))')
- print nullable('(asdfasdfa)')
- print nullable('asd(fas)dfa')
-
- query_anchor = r"[\?#][\w-_\\:/%&=\?#]*"
- path = r"(?:\\/|/)[\w-_\\/%&=]*"
- domain = "[^\\/'\"]*"
- port = ":(?<port>\d+)"
- domain_port = join(cap(domain, 'domain'), le1(port))
- path_query = join(cap(path, 'path'), le1(query_anchor, 'query'))
- domain_path = join(domain_port, le1(path_query))
-
- query_anchor = cap(query_anchor)
- print query_anchor
- query_anchor = cap(query_anchor, 'what')
- print query_anchor
- print domain_path
- print r"a\b"
-
- import re
- re.compile(r"(\\/|/)[\w_\\/%&=-]*")
-
- print '----------------------------------'
- for p in _build_pattern():
- print p
- re.compile(p)
-
-
-
-
- """
- ((?P<prefix>[^\w]url\s * \(\s * ['"]?'"\s*\))
- (?P<sep_1>//)
- (?P<domain>[^\/'"]*)((:(?P<port>\d+))?)
- ((?P<path>(?:\\/|/)[\w\-_\\/%&=]*)((?P<query>[\?#][\w\-_\\:/%&=\?#]*)?))?
- (?P<suffix>'\"\s*\)))
-
-
- ((?P<prefix>([^\w](\\?'|\\?\"|'|'|")?
- (src|href|HREF|action|embed|url|server)
- (\\?'|\\?\"|'|'|")?\s*(:|=|==|!=)\s*
- (\\?'|\\?\"|'|'|"))|
- ([^\w](url|replace)\s*\(\s*['"]?'"\s*\)))
-
- ((?P<protocal>http|https)
- (?P<sep_1>:\\?/\\?/)
- (?P<domain>[^\/'"]*)
- ((:(?P<port>\d+))?))?
- ((?P<path>(?:\\/|/)[\w\-_\\/%&=]*)
- ((?P<query>[\?#][\w\-_\\:/%&=\?#]*)?))?
- (?P<suffix>(\\?'|\\?\"|'|'|")|'\"\s*\)))
-
-
-
- """