forked from mandubian/play-crud-siena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.py
47 lines (38 loc) · 1.38 KB
/
commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# CRUDSIENA (only modification of CRUD commands.py)
import getopt
from play.utils import *
COMMANDS = ['crudsiena:ov', 'crudsiena:override']
HELP = {
'crudsiena:override': 'Override a view'
}
# ~~~~~~~~~~~~~~~~~~~~~~ [crudsiena:ov] Override a view
def execute(**kargs):
app = kargs.get("app")
remaining_args = kargs.get("args")
play_env = kargs.get("env")
try:
optlist, args = getopt.getopt(remaining_args, 't:', ['css','layout','template='])
for o, a in optlist:
if o in ('-t', '--template'):
c = a.split('/')[0]
t = a.split('/')[1]
app.override('app/views/CRUD/%s.html' % t, 'app/views/%s/%s.html' % (c, t))
print "~ "
return
if o == '--layout':
app.override('app/views/CRUD/layout.html', 'app/views/CRUD/layout.html')
print "~ "
return
if o == '--css':
app.override('public/stylesheets/crud.css', 'public/stylesheets/crud.css')
print "~ "
return
except getopt.GetoptError, err:
print "~ %s" % str(err)
print "~ "
sys.exit(-1)
print "~ Specify the template to override, ex : -t Users/list"
print "~ "
print "~ Use --css to override the CRUD css"
print "~ Use --layout to override the CRUD layout"
print "~ "