PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/genre_test.py

https://bitbucket.org/guilin/gae-rproxy/
Python | 73 lines | 47 code | 18 blank | 8 comment | 1 complexity | 9af4d30e1f9153724fe67b5dba6d2e46 MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Created on 2010-7-23
  4. @author: GL
  5. '''
  6. from gae_rproxy.genre import *
  7. from gae_rproxy.rproxy import proxy_data_2, _build_pattern
  8. print gen('a\w+', ['b\s*'], ['c', 'd'], {"protocal":"(http|https)://"},)
  9. print gen('a', 'b', ['c', 'd', ('e', ['f']), {'g':'h'}], {'x':'y'}, {'l':'m'})
  10. print is_captured('(asdfasdfa)')
  11. print is_captured('(asdfasdfa\))a')
  12. print is_captured('(asdfasdf\)a)')
  13. print is_captured('(asdfa)(sdf\)a)')
  14. print is_captured('((\(asdfa)(sdf\)a))')
  15. print nullable('(asdfasdfa)')
  16. print nullable('asd(fas)dfa')
  17. query_anchor = r"[\?#][\w-_\\:/%&=\?#]*"
  18. path = r"(?:\\/|/)[\w-_\\/%&=]*"
  19. domain = "[^\\/'\"]*"
  20. port = ":(?<port>\d+)"
  21. domain_port = join(cap(domain, 'domain'), le1(port))
  22. path_query = join(cap(path, 'path'), le1(query_anchor, 'query'))
  23. domain_path = join(domain_port, le1(path_query))
  24. query_anchor = cap(query_anchor)
  25. print query_anchor
  26. query_anchor = cap(query_anchor, 'what')
  27. print query_anchor
  28. print domain_path
  29. print r"a\b"
  30. import re
  31. re.compile(r"(\\/|/)[\w_\\/%&=-]*")
  32. print '----------------------------------'
  33. for p in _build_pattern():
  34. print p
  35. re.compile(p)
  36. """
  37. ((?P<prefix>[^\w]url\s * \(\s * ['"]?'"\s*\))
  38. (?P<sep_1>//)
  39. (?P<domain>[^\/'"]*)((:(?P<port>\d+))?)
  40. ((?P<path>(?:\\/|/)[\w\-_\\/%&=]*)((?P<query>[\?#][\w\-_\\:/%&=\?#]*)?))?
  41. (?P<suffix>'\"\s*\)))
  42. ((?P<prefix>([^\w](\\?'|\\?\"|&#39;|&apos;|&quot;)?
  43. (src|href|HREF|action|embed|url|server)
  44. (\\?'|\\?\"|&#39;|&apos;|&quot;)?\s*(:|=|==|!=)\s*
  45. (\\?'|\\?\"|&#39;|&apos;|&quot;))|
  46. ([^\w](url|replace)\s*\(\s*['"]?'"\s*\)))
  47. ((?P<protocal>http|https)
  48. (?P<sep_1>:\\?/\\?/)
  49. (?P<domain>[^\/'"]*)
  50. ((:(?P<port>\d+))?))?
  51. ((?P<path>(?:\\/|/)[\w\-_\\/%&=]*)
  52. ((?P<query>[\?#][\w\-_\\:/%&=\?#]*)?))?
  53. (?P<suffix>(\\?'|\\?\"|&#39;|&apos;|&quot;)|'\"\s*\)))
  54. """