1 from django.core.management.base import NoArgsCommand
2 from optparse import make_option
4 from django.conf import settings
6 class Command(NoArgsCommand):
7 option_list = NoArgsCommand.option_list + (
8 make_option('--force', action='store_true', default=False, help='Force update of all files, even if the source files are older than the current compressed file.'),
9 make_option('--verbosity', action='store', dest='verbosity', default='1',
10 type='choice', choices=['0', '1', '2'],
11 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
13 help = 'Updates and compresses CSS and JavsScript on-demand, without restarting Django'
16 def handle_noargs(self, **options):
18 force = options.get('force', False)
19 verbosity = int(options.get('verbosity', 1))
21 from compress.utils import needs_update, filter_css, filter_js
23 for name, css in settings.COMPRESS_CSS.items():
24 u, version = needs_update(css['output_filename'], css['source_filenames'])
26 if (force or u) or verbosity >= 2:
27 msg = 'CSS Group \'%s\'' % name
30 print "Version: %s" % version
33 filter_css(css, verbosity)
35 if (force or u) or verbosity >= 2:
38 for name, js in settings.COMPRESS_JS.items():
39 u, version = needs_update(js['output_filename'], js['source_filenames'])
41 if (force or u) or verbosity >= 2:
42 msg = 'JavaScript Group \'%s\'' % name
45 print "Version: %s" % version
48 filter_js(js, verbosity)
50 if (force or u) or verbosity >= 2: