pep8 in scripts/*.py
This commit is contained in:
+31
-21
@@ -40,48 +40,58 @@ domain3.com /app3/defcon3
|
||||
'''
|
||||
if not config.strip():
|
||||
try:
|
||||
config_file = open('routes.conf','r')
|
||||
config_file = open('routes.conf', 'r')
|
||||
try:
|
||||
config = config_file.read()
|
||||
finally:
|
||||
config_file.close()
|
||||
except:
|
||||
config=''
|
||||
config = ''
|
||||
|
||||
|
||||
def auto_in(apps):
|
||||
routes = [
|
||||
('/robots.txt','/welcome/static/robots.txt'),
|
||||
('/favicon.ico','/welcome/static/favicon.ico'),
|
||||
('/admin$anything','/admin$anything'),
|
||||
]
|
||||
for domain,path in [x.strip().split() for x in apps.split('\n') if x.strip() and not x.strip().startswith('#')]:
|
||||
if not path.startswith('/'): path = '/'+path
|
||||
if path.endswith('/'): path = path[:-1]
|
||||
('/robots.txt', '/welcome/static/robots.txt'),
|
||||
('/favicon.ico', '/welcome/static/favicon.ico'),
|
||||
('/admin$anything', '/admin$anything'),
|
||||
]
|
||||
for domain, path in [x.strip().split() for x in apps.split('\n') if x.strip() and not x.strip().startswith('#')]:
|
||||
if not path.startswith('/'):
|
||||
path = '/' + path
|
||||
if path.endswith('/'):
|
||||
path = path[:-1]
|
||||
app = path.split('/')[1]
|
||||
routes += [
|
||||
('.*:https?://(.*\.)?%s:$method /' % domain,'%s' % path),
|
||||
('.*:https?://(.*\.)?%s:$method /static/$anything' % domain,'/%s/static/$anything' % app),
|
||||
('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % domain,'/%s/appadmin/$anything' % app),
|
||||
('.*:https?://(.*\.)?%s:$method /$anything' % domain,'%s/$anything' % path),
|
||||
]
|
||||
('.*:https?://(.*\.)?%s:$method /' % domain, '%s' % path),
|
||||
('.*:https?://(.*\.)?%s:$method /static/$anything' %
|
||||
domain, '/%s/static/$anything' % app),
|
||||
('.*:https?://(.*\.)?%s:$method /appadmin/$anything' %
|
||||
domain, '/%s/appadmin/$anything' % app),
|
||||
('.*:https?://(.*\.)?%s:$method /$anything' %
|
||||
domain, '%s/$anything' % path),
|
||||
]
|
||||
return routes
|
||||
|
||||
|
||||
def auto_out(apps):
|
||||
routes = []
|
||||
for domain,path in [x.strip().split() for x in apps.split('\n') if x.strip() and not x.strip().startswith('#')]:
|
||||
if not path.startswith('/'): path = '/'+path
|
||||
if path.endswith('/'): path = path[:-1]
|
||||
for domain, path in [x.strip().split() for x in apps.split('\n') if x.strip() and not x.strip().startswith('#')]:
|
||||
if not path.startswith('/'):
|
||||
path = '/' + path
|
||||
if path.endswith('/'):
|
||||
path = path[:-1]
|
||||
app = path.split('/')[1]
|
||||
routes += [
|
||||
('/%s/static/$anything' % app,'/static/$anything'),
|
||||
('/%s/static/$anything' % app, '/static/$anything'),
|
||||
('/%s/appadmin/$anything' % app, '/appadmin/$anything'),
|
||||
('%s/$anything' % path, '/$anything'),
|
||||
]
|
||||
]
|
||||
return routes
|
||||
|
||||
routes_in = auto_in(config)
|
||||
routes_out = auto_out(config)
|
||||
|
||||
|
||||
def __routes_doctest():
|
||||
'''
|
||||
Dummy function for doctesting autoroutes.py.
|
||||
@@ -128,7 +138,8 @@ if __name__ == '__main__':
|
||||
try:
|
||||
import gluon.main
|
||||
except ImportError:
|
||||
import sys, os
|
||||
import sys
|
||||
import os
|
||||
os.chdir(os.path.dirname(os.path.dirname(__file__)))
|
||||
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
|
||||
import gluon.main
|
||||
@@ -138,4 +149,3 @@ if __name__ == '__main__':
|
||||
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user