Django

Code

Changeset 6870

Show
Ignore:
Timestamp:
12/03/07 23:46:46 (1 year ago)
Author:
adrian
Message:

Cleaned up some docstrings and removed some unnecessary long-line breaking in django/core/management/init.py as I try to figure out why django-admin.py runserver has stopped working

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management/__init__.py

    r6853 r6870  
    1111 
    1212# A cache of loaded commands, so that call_command 
    13 # doesn't have to reload every time it is called 
     13# doesn't have to reload every time it's called. 
    1414_commands = None 
    1515 
     
    3030def find_management_module(app_name): 
    3131    """ 
    32     Determines the path to the management module for the application named
    33     without acutally importing the application or the management module. 
     32    Determines the path to the management module for the given app_name
     33    without actually importing the application or the management module. 
    3434 
    3535    Raises ImportError if the management module cannot be found for any reason. 
     
    4747    """ 
    4848    Given a command name and an application name, returns the Command 
    49     class instance. All errors raised by the importation process 
     49    class instance. All errors raised by the import process 
    5050    (ImportError, AttributeError) are allowed to propagate. 
    5151    """ 
     
    5555def get_commands(): 
    5656    """ 
    57     Returns a dictionary of commands against the application in which 
    58     those commands can be found. This works by looking for a 
    59     management.commands package in django.core, and in each installe
    60     application -- if a commands package exists, all commands in that 
    61     package are registered. 
     57    Returns a dictionary mapping command names to their callback applications. 
     58 
     59    This works by looking for a management.commands package in django.core, an
     60    in each installed application -- if a commands package exists, all commands 
     61    in that package are registered. 
    6262 
    6363    Core commands are always included. If a settings module has been 
     
    7474    dictionary in place of the application name. 
    7575 
    76     The dictionary is cached on the first call, and reused on subsequent 
     76    The dictionary is cached on the first call and reused on subsequent 
    7777    calls. 
    7878    """ 
    7979    global _commands 
    8080    if _commands is None: 
    81         _commands = dict([(name, 'django.core') 
    82                           for name in find_commands(__path__[0])]) 
     81        _commands = dict([(name, 'django.core') for name in find_commands(__path__[0])]) 
    8382        # Get commands from all installed apps. 
    8483        try: 
     
    9190            try: 
    9291                path = find_management_module(app_name) 
    93                 _commands.update(dict([(name, app_name) 
    94                                        for name in find_commands(path)])) 
     92                _commands.update(dict([(name, app_name) for name in find_commands(path)])) 
    9593            except ImportError: 
    9694                pass # No management module - ignore this app 
     
    164162        """ 
    165163        usage = ['%s <subcommand> [options] [args]' % self.prog_name] 
    166         usage.append('Django command line tool,' 
    167                      ' version %s' % django.get_version()) 
    168         usage.append("Type '%s help <subcommand>' for help on a specific" 
    169                      " subcommand." % self.prog_name) 
     164        usage.append('Django command line tool, version %s' % django.get_version()) 
     165        usage.append("Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name) 
    170166        usage.append('Available subcommands:') 
    171167        commands = get_commands().keys() 
     
    179175        Tries to fetch the given subcommand, printing a message with the 
    180176        appropriate command called from the command line (usually 
    181         django-admin.py or manage.py) if it can't be found. 
     177        "django-admin.py" or "manage.py") if it can't be found. 
    182178        """ 
    183179        try: 
     
    189185                klass = load_command_class(app_name, subcommand) 
    190186        except KeyError: 
    191             sys.stderr.write("Unknown command: %r\nType '%s help' for" 
    192                              " usage.\n" % (subcommand, self.prog_name)) 
     187            sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % \ 
     188                (subcommand, self.prog_name)) 
    193189            sys.exit(1) 
    194190        return klass 
     
    202198        # These options could affect the commands that are available, so they 
    203199        # must be processed early. 
    204         parser = LaxOptionParser(version=get_version(), 
    205                                  option_list=BaseCommand.option_list) 
     200        parser = LaxOptionParser(version=get_version(), option_list=BaseCommand.option_list) 
    206201        try: 
    207202            options, args = parser.parse_args(self.argv) 
     
    264259 
    265260    # Set DJANGO_SETTINGS_MODULE appropriately. 
    266     os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, 
    267                                                       settings_name) 
     261    os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name) 
    268262    return project_directory 
    269263