Package gluon :: Module myregex
[hide private]
[frames] | no frames]

Source Code for Module gluon.myregex

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  """ 
 5  | This file is part of the web2py Web Framework 
 6  | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> 
 7  | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) 
 8   
 9  Useful regexes 
10  --------------- 
11  """ 
12   
13  import re 
14   
15  # pattern to find defined tables 
16   
17  regex_tables = re.compile( 
18      """^[\w]+\.define_table\(\s*[\'\"](?P<name>\w+)[\'\"]""", 
19      flags=re.M) 
20   
21  # pattern to find exposed functions in controller 
22   
23  regex_expose = re.compile( 
24      '^def\s+(?P<name>_?[a-zA-Z0-9]\w*)\( *\)\s*:', 
25      flags=re.M) 
26   
27  regex_longcomments = re.compile('(""".*?"""|'+"'''.*?''')",re.DOTALL) 
28   
29  regex_include = re.compile( 
30      '(?P<all>\{\{\s*include\s+[\'"](?P<name>[^\'"]*)[\'"]\s*\}\})') 
31   
32  regex_extend = re.compile( 
33      '^\s*(?P<all>\{\{\s*extend\s+[\'"](?P<name>[^\'"]+)[\'"]\s*\}\})', re.MULTILINE) 
34