Ticket #19085: custom-commands.diff

File custom-commands.diff, 779 bytes (added by Daniel Swarbrick, 12 years ago)
  • django/core/management/__init__.py

    diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
    index c61ab2b..aa02828 100644
    a b def find_commands(management_dir):  
    2525
    2626    Returns an empty list if no commands are defined.
    2727    """
     28    import re
     29
    2830    command_dir = os.path.join(management_dir, 'commands')
     31    command_set = set()
    2932    try:
    30         return [f[:-3] for f in os.listdir(command_dir)
    31                 if not f.startswith('_') and f.endswith('.py')]
     33        for f in os.listdir(command_dir):
     34            if re.match(r'^[^_].*\.py[co]?$', f):
     35                command_set.add(os.path.splitext(f)[0])
     36        return list(command_set)
    3237    except OSError:
    3338        return []
    3439
Back to Top