44
55from investing_algorithm_framework .core .exceptions import ImproperlyConfigured
66from investing_algorithm_framework .core .management .command import BaseCommand , CommandError
7- from investing_algorithm_framework .core .configuration .setup import DefaultBotProjectCreator
7+ from investing_algorithm_framework .core .configuration .setup . default_template_creators import DefaultProjectCreator
88
99
10- class CreateBotCommand (BaseCommand ):
10+ class CreateAlgorithmCommand (BaseCommand ):
1111 help = (
12- "Creates a project directory structure for the given investing_algorithm_framework name in the current directory or optionally "
13- "in the given directory."
12+ "Creates a project directory structure for the given investing_algorithm_framework instance in the current "
13+ "directory or optionally in the given directory."
1414 )
1515
16- missing_args_message = "You must provide a investing_algorithm_framework name."
17- success_message = "Bot created and initialized."
16+ missing_args_message = "You must provide a project name."
17+ success_message = "Algorithm created and initialized."
1818
1919 def add_arguments (self , parser ):
20- parser .add_argument ('name' , help = 'Name of the investing_algorithm_framework .' )
20+ parser .add_argument ('name' , help = 'Name of the algorithm/project .' )
2121 parser .add_argument ('directory' , nargs = '?' , help = 'Optional destination directory' )
2222 parser .add_argument (
2323 '--template_creator' ,
2424 help = 'Optional template creator plugin, provided by third party libraries'
2525 )
2626
27- def handle (self , ** options ) -> str :
27+ def handle (self , ** options ) -> None :
2828
2929 # Get all the default attributes
30- bot_name = options .get ('name' , None )
30+ project_name = options .get ('name' , None )
3131 directory = options .get ('directory' , None )
3232 template_creator = options .get ('template_creator' , None )
3333
34- self .validate_name (bot_name )
34+ self .validate_name (project_name )
3535
3636 # initialize the investing_algorithm_framework project directory
3737 if directory is None :
38- directory = os .path .join (os .getcwd (), bot_name )
38+ directory = os .path .join (os .getcwd (), project_name )
3939
4040 if os .path .isdir (directory ):
4141 raise ImproperlyConfigured (
42- "Directory {} already exists. Please make sure that the investing_algorithm_framework project name does not correspond to "
43- "an existing directory"
42+ "Directory {} already exists. Please make sure that the project "
43+ "name does not correspond to an existing directory" . format ( str ( directory ))
4444 )
4545
4646 os .mkdir (directory )
@@ -49,24 +49,26 @@ def handle(self, **options) -> str:
4949 directory = os .path .abspath (os .path .expanduser (directory ))
5050
5151 if not os .path .exists (directory ):
52- raise CommandError ("Destination directory {} does not exist, please create it first." .format (directory ))
52+ raise CommandError (
53+ "Destination directory {} does not exist, please create it first." .format (str (directory ))
54+ )
5355
5456 # Use default investing_algorithm_framework creator
5557 if not template_creator :
56- bot_template_creator = DefaultBotProjectCreator (directory , bot_name )
58+ template_creator = DefaultProjectCreator (directory , project_name )
5759
5860 # Creates templates
59- bot_template_creator .configure ()
60- bot_template_creator .create ()
61+ template_creator .configure ()
62+ template_creator .create ()
6163
6264 @staticmethod
6365 def validate_name (name : str ) -> None :
6466 """
65- Helper function to validate the name of a given investing_algorithm_framework
67+ Helper function to validate the name of a given project
6668 """
6769
6870 if name is None :
69- raise CommandError ("you must provide a investing_algorithm_framework name" )
71+ raise CommandError ("you must provide a project name" )
7072
7173 if not re .match ("^[a-zA-Z]+\w*$" , name ):
7274 raise CommandError ("{} is not allowed, value must begin with a letter and "
@@ -80,6 +82,6 @@ def validate_name(name: str) -> None:
8082 else :
8183 raise CommandError (
8284 "'{}' conflicts with the name of an existing Python "
83- "module and cannot be used as a investing_algorithm_framework name. Please try "
85+ "module and cannot be used as a project name. Please try "
8486 "another name." .format (name )
8587 )
0 commit comments