File: make_jsmin_optional

package info (click to toggle)
django-pipeline 1.3.24-0.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 544 kB
  • ctags: 349
  • sloc: python: 1,706; makefile: 114
file content (24 lines) | stat: -rw-r--r-- 935 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Description: Make JSMin dependency optional
 JSMin is a JavaScript compressor. It's known to be non-free due to
 additional statement to MIT license (The Software shall be used for Good,
 not Evil.)
 .
 This patchs stubs out JSMin usage. Instead uncompressed JS will be
 returned. This should be ok since it is not default compressor at all.
Author: Dmitry Nezhevenko <dion@dion.org.ua>
Bug: https://github.com/cyberdelia/django-pipeline/issues/99

--- django-pipeline-1.2.2.orig/pipeline/compressors/jsmin.py
+++ django-pipeline-1.2.2/pipeline/compressors/jsmin.py
@@ -7,5 +7,9 @@ class JSMinCompressor(CompressorBase):
     (http://pypi.python.org/pypi/jsmin/).
     """
     def compress_js(self, js):
-        from jsmin import jsmin
-        return jsmin(js)
+        try:
+            from jsmin import jsmin
+            return jsmin(js)
+        except ImportError:
+            # JSMin is not available
+            return js