@@ -14,25 +14,53 @@ def __init__(self):
1414 pass
1515
1616 def add_arguments (self , parser ):
17+ """
18+ This method is for adding arguments to a command.
19+ When extending this class we define the arguments
20+ by adding it to the parser passed in.
21+
22+ :param parser: The parser to add arguments to (standard argparse)
23+ """
1724 pass
1825
1926 def handle (self , * args , ** options ):
27+ """
28+ The actual run logic for the command.
29+
30+ :param args: arguments from the argparser
31+ :param options: keyword arguments from the argparser
32+ """
2033 raise NotImplementedError
2134
2235 def run_from_argv (self , argv ):
36+ """
37+ Called by the system when executing the command from the command line.
38+ This should not be overridden.
39+
40+ :param argv: Arguments from command line
41+ """
2342 parser = self .create_parser (argv [0 ], argv [1 ])
2443 options = parser .parse_args (argv [2 :])
2544 cmd_options = vars (options )
2645 args = cmd_options .pop ('args' , ())
2746 self .handle (* args , ** cmd_options )
2847
2948 def print_help (self , prog_name , subcommand ):
49+ """
50+ Prints the help text generated by the argument parser defined for this command.
51+ This method should not be overridden.
52+
53+ :param prog_name: name of the program that started the command.
54+ :param subcommand: The subcommand name
55+ """
3056 parser = self .create_parser (prog_name , subcommand )
3157 parser .print_help ()
3258
3359 def create_parser (self , prog_name , subcommand ):
3460 """
3561 Create argument parser and deal with ``add_arguments``.
62+ This method should not be overriden.
63+
3664 :param prog_name: Name of the command (argv[0])
3765 :return: ArgumentParser
3866 """
@@ -46,7 +74,12 @@ class CreateCommand(BaseCommand):
4674 """Used for createproject and createeffect"""
4775
4876 def validate_name (self , name ):
49- """Can the name be used as a python module or package?"""
77+ """
78+ Can the name be used as a python module or package?
79+ Raises ``ValueError`` if the name is invalid.
80+
81+ :param name: the name to check
82+ """
5083 if not name :
5184 raise ValueError ("Name cannot be empty" )
5285
@@ -55,10 +88,15 @@ def validate_name(self, name):
5588 raise ValueError ("{} is not a valid identifier" .format (name ))
5689
5790 def try_import (self , name ):
58- """Attemt to import the name"""
91+ """
92+ Attempt to import the name.
93+ Raises ``ImportError`` if the name cannot be imported.
94+
95+ :param name: the name to import
96+ """
5997 try :
6098 import_module (name )
6199 except ImportError :
62100 pass
63101 else :
64- raise ValueError ("{} conflicts with an existing python module" .format (name ))
102+ raise ImportError ("{} conflicts with an existing python module" .format (name ))
0 commit comments