Skip to content

Commit 7aeb30c

Browse files
committed
createffect: allow path prefix
1 parent b8f091f commit 7aeb30c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

demosys/core/management/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def execute_from_command_line(argv=None):
6969
if command in commands:
7070
cmd = load_command_class('demosys.core', command)
7171
cmd.run_from_argv(argv)
72-
if command in project_commands:
72+
elif command in project_commands:
7373
cmd = load_command_class(project_package, command)
7474
cmd.run_from_argv(argv)
7575
else:

demosys/core/management/commands/createeffect.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)