1717)
1818
1919
20- def new_piccolo_conf (engine_name : str , force : bool = False ):
21- print (f "Creating new piccolo_conf file ..." )
20+ def new_piccolo_conf (engine_name : str , force : bool = False , root : str = "" ):
21+ print ("Creating new piccolo_conf file ..." )
2222
23- if os .path .exists ("piccolo_conf.py" ) and not force :
23+ file_path = os .path .join (root , "piccolo_conf.py" )
24+
25+ if os .path .exists (file_path ) and not force :
2426 print ("The file already exists - exiting." )
2527 sys .exit (1 )
2628
27- with open ("piccolo_conf.py" , "w" ) as f :
29+ with open (file_path , "w" ) as f :
2830 template = JINJA_ENV .get_template ("piccolo_conf.py.jinja" )
2931 file_contents = template .render (engine_name = engine_name )
3032 file_contents = black .format_str (
@@ -34,7 +36,7 @@ def new_piccolo_conf(engine_name: str, force: bool = False):
3436 f .write (file_contents )
3537
3638
37- def new (engine : str = "postgres" , force : bool = False ):
39+ def new (engine : str = "postgres" , force : bool = False , root : str = "" ):
3840 """
3941 Creates a new Piccolo project file (piccolo_conf.py).
4042
@@ -44,6 +46,9 @@ def new(engine: str = "postgres", force: bool = False):
4446 :param force:
4547 If True, it will override the piccolo_conf.py file if it already
4648 exists.
49+ :param root:
50+ Where to create the app e.g. /my/folder. By default it creates the
51+ app in the current directory.
4752
4853 """
49- new_piccolo_conf (engine_name = engine , force = force )
54+ new_piccolo_conf (engine_name = engine , force = force , root = root )
0 commit comments