PageRenderTime 24ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/gluon/myregex.py

https://code.google.com/p/web2py/
Python | 33 lines | 18 code | 4 blank | 11 comment | 0 complexity | 7ce45a5ecc64f189a217fe1c64e45303 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, MIT, BSD-3-Clause, Apache-2.0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. | This file is part of the web2py Web Framework
  5. | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
  6. | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  7. Useful regexes
  8. ---------------
  9. """
  10. import re
  11. # pattern to find defined tables
  12. regex_tables = re.compile(
  13. """^[\w]+\.define_table\(\s*[\'\"](?P<name>\w+)[\'\"]""",
  14. flags=re.M)
  15. # pattern to find exposed functions in controller
  16. regex_expose = re.compile(
  17. '^def\s+(?P<name>_?[a-zA-Z0-9]\w*)\( *\)\s*:',
  18. flags=re.M)
  19. regex_longcomments = re.compile('(""".*?"""|'+"'''.*?''')",re.DOTALL)
  20. regex_include = re.compile(
  21. '(?P<all>\{\{\s*include\s+[\'"](?P<name>[^\'"]*)[\'"]\s*\}\})')
  22. regex_extend = re.compile(
  23. '^\s*(?P<all>\{\{\s*extend\s+[\'"](?P<name>[^\'"]+)[\'"]\s*\}\})', re.MULTILINE)