@@ -9,7 +9,12 @@ def add_arguments(self, parser):
99 parser .add_argument ("name" , help = "Name of the effect" )
1010
1111 def handle (self , * args , ** options ):
12- name = options ['name' ]
12+ name = os .path .basename (options ['name' ])
13+ path = os .path .dirname (options ['name' ])
14+
15+ # Does the name have a path prefix?
16+ if path and not os .path .exists (path ):
17+ raise ValueError ("{} directory does not exist" .format (path ))
1318
1419 # Check for python module collision
1520 self .try_import (name )
@@ -22,16 +27,16 @@ def handle(self, *args, **options):
2227 print ("Directory {} already exist. Aborting." .format (name ))
2328 return
2429
25- os .mkdir (name )
26- os .makedirs (os .path .join (name , 'textures' , name ))
27- os .makedirs (os .path .join (name , 'shaders' , name ))
30+ os .mkdir (os . path . join ( path , name ) )
31+ os .makedirs (os .path .join (path , name , 'textures' , name ))
32+ os .makedirs (os .path .join (path , name , 'shaders' , name ))
2833
2934 # Create effect.py
30- with open (os .path .join (name , 'effect.py' ), 'w' ) as fd :
35+ with open (os .path .join (path , name , 'effect.py' ), 'w' ) as fd :
3136 fd .write (default_effect (name ))
3237
3338 # Create default.glsl
34- with open (os .path .join (name , 'shaders' , name , 'default.glsl' ), 'w' ) as fd :
39+ with open (os .path .join (path , name , 'shaders' , name , 'default.glsl' ), 'w' ) as fd :
3540 fd .write (default_shader ())
3641
3742
0 commit comments