django.contrib.staticfiles.management.commands.findstatic: 21 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/findstatic.py

Stats: 0 executed, 16 missed, 5 excluded, 10 ignored

  1. import os
  2. from optparse import make_option
  3. from django.core.management.base import LabelCommand
  4. from django.utils.encoding import smart_str, smart_unicode
  5. from django.contrib.staticfiles import finders
  6. class Command(LabelCommand):
  7. help = "Finds the absolute paths for the given static file(s)."
  8. args = "[file ...]"
  9. label = 'static file'
  10. option_list = LabelCommand.option_list + (
  11. make_option('--first', action='store_false', dest='all', default=True,
  12. help="Only return the first match for each static file."),
  13. )
  14. def handle_label(self, path, **options):
  15. verbosity = int(options.get('verbosity', 1))
  16. result = finders.find(path, all=options['all'])
  17. path = smart_unicode(path)
  18. if result:
  19. if not isinstance(result, (list, tuple)):
  20. result = [result]
  21. output = u'\n '.join(
  22. (smart_unicode(os.path.realpath(path)) for path in result))
  23. self.stdout.write(
  24. smart_str(u"Found '%s' here:\n %s\n" % (path, output)))
  25. else:
  26. if verbosity >= 1:
  27. self.stderr.write(
  28. smart_str("No matching file found for '%s'.\n" % path))