1
1
import os
2
2
import sys
3
- from imp import find_module
4
3
from django .core .management .base import CommandError , AppCommand , _make_writeable
5
- from optparse import make_option
6
4
7
5
class Command (AppCommand ):
8
- option_list = AppCommand .option_list + (
9
- )
10
-
11
- help = ("Creates a Django jobs command directory structure for the given app name"
12
- " in the current directory." )
6
+ help = ("Creates a Django jobs command directory structure for the given app name in the current directory." )
13
7
args = "[appname]"
14
8
label = 'application name'
15
9
@@ -19,35 +13,9 @@ class Command(AppCommand):
19
13
can_import_settings = True
20
14
21
15
def handle_app (self , app , ** options ):
22
- parts = app .__name__ .split ('.' )[0 :- 1 ]
23
- parts .reverse ()
24
- app_dir = None
25
- original_parts = list (parts )
26
- paths = list (sys .path )
27
- while parts :
28
- part = parts .pop ()
29
-
30
- # A part may be missing if namespace packages are being used.
31
- # Try to import, and if it fails, boot the whole failing app_dir out
32
- # of our path search list. Reraise the import error if we run out of
33
- # paths to try.
34
- try :
35
- f , app_dir , descr = find_module (part , app_dir and [app_dir ] or paths )
36
- except ImportError :
37
- paths = [p for p in paths if not app_dir .startswith (p )]
38
- if not paths :
39
- raise
40
- app_dir = None
41
- parts = list (original_parts )
42
-
43
- if not os .path .exists (app_dir ):
44
- try :
45
- os .mkdir (app_dir )
46
- except OSError , e :
47
- raise CommandError (e )
48
-
16
+ app_dir = os .path .dirname (app .__file__ )
49
17
copy_template ('jobs_template' , app_dir )
50
-
18
+
51
19
def copy_template (template_name , copy_to ):
52
20
"""copies the specified template directory to the copy_to location"""
53
21
import django_extensions
0 commit comments