Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
7b4075d5
Commit
7b4075d5
authored
Oct 20, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve less and sass compilers
parent
8fcaffdb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
27 deletions
+22
-27
docs/compilers.rst
+1
-1
pipeline/compilers/__init__.py
+5
-3
pipeline/compilers/coffee/__init__.py
+5
-2
pipeline/compilers/less/__init__.py
+3
-15
pipeline/compilers/sass/__init__.py
+7
-5
tests/tests/compiler.py
+1
-1
No files found.
docs/compilers.rst
View file @
7b4075d5
...
...
@@ -112,6 +112,6 @@ A custom compiler for a imaginary compiler called jam ::
def match_file(self, filename):
return path.endswith('.jam')
def compile_file(self, content):
def compile_file(self, content
, path
):
return jam.compile(content)
pipeline/compilers/__init__.py
View file @
7b4075d5
...
...
@@ -22,7 +22,7 @@ class Compiler(object):
new_path
=
self
.
output_path
(
path
,
compiler
.
output_extension
)
content
=
self
.
read_file
(
path
)
try
:
compiled_content
=
compiler
.
compile_file
(
content
)
compiled_content
=
compiler
.
compile_file
(
content
,
storage
.
path
(
path
)
)
self
.
save_file
(
new_path
,
compiled_content
)
except
CompilerError
:
if
not
storage
.
exists
(
new_path
)
or
not
settings
.
PIPELINE
:
...
...
@@ -53,7 +53,7 @@ class CompilerBase(object):
def
match_file
(
self
,
filename
):
raise
NotImplementedError
def
compile_file
(
self
,
content
):
def
compile_file
(
self
,
content
,
path
):
raise
NotImplementedError
def
save_file
(
self
,
path
,
content
):
...
...
@@ -68,9 +68,11 @@ class CompilerError(Exception):
class
SubProcessCompiler
(
CompilerBase
):
def
execute_command
(
self
,
command
,
content
):
def
execute_command
(
self
,
command
,
content
=
None
):
pipe
=
subprocess
.
Popen
(
command
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
content
:
pipe
.
stdin
.
write
(
content
)
pipe
.
stdin
.
close
()
...
...
pipeline/compilers/coffee/__init__.py
View file @
7b4075d5
...
...
@@ -8,6 +8,9 @@ class CoffeeScriptCompiler(SubProcessCompiler):
def
match_file
(
self
,
path
):
return
path
.
endswith
(
'.coffee'
)
def
compile_file
(
self
,
content
):
command
=
"
%
s -sc
%
s"
%
(
settings
.
PIPELINE_COFFEE_SCRIPT_BINARY
,
settings
.
PIPELINE_COFFEE_SCRIPT_ARGUMENTS
)
def
compile_file
(
self
,
content
,
path
):
command
=
"
%
s -sc
%
s"
%
(
settings
.
PIPELINE_COFFEE_SCRIPT_BINARY
,
settings
.
PIPELINE_COFFEE_SCRIPT_ARGUMENTS
)
return
self
.
execute_command
(
command
,
content
)
pipeline/compilers/less/__init__.py
View file @
7b4075d5
import
os
import
tempfile
from
pipeline.conf
import
settings
from
pipeline.compilers
import
SubProcessCompiler
...
...
@@ -11,20 +8,11 @@ class LessCompiler(SubProcessCompiler):
def
match_file
(
self
,
filename
):
return
filename
.
endswith
(
'.less'
)
def
compile_file
(
self
,
content
):
in_file
,
in_filename
=
tempfile
.
mkstemp
()
in_file
=
os
.
fdopen
(
in_file
,
'w+b'
)
in_file
.
write
(
content
)
in_file
.
flush
()
def
compile_file
(
self
,
content
,
path
):
command
=
'
%
s
%
s
%
s'
%
(
settings
.
PIPELINE_LESS_BINARY
,
settings
.
PIPELINE_LESS_ARGUMENTS
,
in_filename
path
)
content
=
self
.
execute_command
(
command
,
content
)
in_file
.
close
()
os
.
remove
(
in_filename
)
content
=
self
.
execute_command
(
command
)
return
content
pipeline/compilers/sass/__init__.py
View file @
7b4075d5
...
...
@@ -8,8 +8,10 @@ class SASSCompiler(SubProcessCompiler):
def
match_file
(
self
,
filename
):
return
filename
.
endswith
(
'.scss'
)
def
compile_file
(
self
,
content
):
command
=
"
%
s --scss
%
s"
%
(
settings
.
PIPELINE_SASS_BINARY
,
settings
.
PIPELINE_SASS_ARGUMENTS
)
if
self
.
verbose
:
command
+=
'--verbose'
return
self
.
execute_command
(
command
,
content
)
def
compile_file
(
self
,
content
,
path
):
command
=
"
%
s --scss
%
s
%
s"
%
(
settings
.
PIPELINE_SASS_BINARY
,
settings
.
PIPELINE_SASS_ARGUMENTS
,
path
)
return
self
.
execute_command
(
command
)
tests/tests/compiler.py
View file @
7b4075d5
...
...
@@ -10,7 +10,7 @@ class DummyCompiler(CompilerBase):
def
match_file
(
self
,
path
):
return
path
.
endswith
(
'.coffee'
)
def
compile_file
(
self
,
content
):
def
compile_file
(
self
,
content
,
path
):
return
content
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment