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.'),
10 help = 'Updates and compresses CSS and JavsScript on-demand, without restarting Django'
13 def handle_noargs(self, **options):
15 force = options.get('force', False)
16 verbosity = int(options.get('verbosity', 1))
18 from compress.utils import needs_update, filter_css, filter_js
20 for name, css in settings.COMPRESS_CSS.items():
21 u, version = needs_update(css['output_filename'],
22 css['source_filenames'])
24 if (force or u) or verbosity >= 2:
25 msg = 'CSS Group \'%s\'' % name
28 print "Version: %s" % version
31 filter_css(css, verbosity)
33 if (force or u) or verbosity >= 2:
36 for name, js in settings.COMPRESS_JS.items():
37 u, version = needs_update(js['output_filename'],
38 js['source_filenames'])
40 if (force or u) or verbosity >= 2:
41 msg = 'JavaScript Group \'%s\'' % name
44 print "Version: %s" % version
47 filter_js(js, verbosity)
49 if (force or u) or verbosity >= 2:
52 # Backwards compatibility for Django r9110
53 if not [opt for opt in Command.option_list if opt.dest=='verbosity']:
54 Command.option_list += (
55 make_option('--verbosity', '-v', action="store", dest="verbosity",
56 default='1', type='choice', choices=['0', '1', '2'],
57 help="Verbosity level; 0=minimal output, 1=normal output, 2=all output"),