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
492fec24
Commit
492fec24
authored
Feb 22, 2016
by
David Trowbridge
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into compiler-is_outdated
parents
c4ff03e5
7198db4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
pipeline/compilers/__init__.py
+12
-10
tests/tests/test_compiler.py
+9
-3
No files found.
pipeline/compilers/__init__.py
View file @
492fec24
...
...
@@ -35,12 +35,12 @@ class Compiler(object):
infile
=
self
.
storage
.
path
(
input_path
)
except
NotImplementedError
:
infile
=
finders
.
find
(
input_path
)
outfile
=
self
.
output_path
(
infile
,
compiler
.
output_extension
)
outfile
=
compiler
.
output_path
(
infile
,
compiler
.
output_extension
)
outdated
=
compiler
.
is_outdated
(
infile
,
outfile
)
compiler
.
compile_file
(
infile
,
outfile
,
outdated
=
outdated
,
force
=
force
)
return
self
.
output_path
(
input_path
,
compiler
.
output_extension
)
return
compiler
.
output_path
(
input_path
,
compiler
.
output_extension
)
else
:
return
input_path
...
...
@@ -53,10 +53,6 @@ class Compiler(object):
with
futures
.
ThreadPoolExecutor
(
max_workers
=
multiprocessing
.
cpu_count
())
as
executor
:
return
list
(
executor
.
map
(
_compile
,
paths
))
def
output_path
(
self
,
path
,
extension
):
path
=
os
.
path
.
splitext
(
path
)
return
'.'
.
join
((
path
[
0
],
extension
))
class
CompilerBase
(
object
):
def
__init__
(
self
,
verbose
,
storage
):
...
...
@@ -78,6 +74,10 @@ class CompilerBase(object):
file
.
close
()
return
content
def
output_path
(
self
,
path
,
extension
):
path
=
os
.
path
.
splitext
(
path
)
return
'.'
.
join
((
path
[
0
],
extension
))
def
is_outdated
(
self
,
infile
,
outfile
):
if
not
self
.
storage
.
exists
(
outfile
):
return
True
...
...
@@ -111,6 +111,7 @@ class SubProcessCompiler(CompilerBase):
else
:
argument_list
.
extend
(
flattening_arg
)
stdout
=
None
try
:
# We always catch stdout in a file, but we may not have a use for it.
temp_file_container
=
cwd
or
os
.
path
.
dirname
(
stdout_captured
or
""
)
or
os
.
getcwd
()
...
...
@@ -135,7 +136,8 @@ class SubProcessCompiler(CompilerBase):
raise
CompilerError
(
e
)
finally
:
# Decide what to do with captured stdout.
if
stdout_captured
:
os
.
rename
(
stdout
.
name
,
os
.
path
.
join
(
cwd
or
os
.
curdir
,
stdout_captured
))
else
:
os
.
remove
(
stdout
.
name
)
if
stdout
:
if
stdout_captured
:
os
.
rename
(
stdout
.
name
,
os
.
path
.
join
(
cwd
or
os
.
curdir
,
stdout_captured
))
else
:
os
.
remove
(
stdout
.
name
)
tests/tests/test_compiler.py
View file @
492fec24
...
...
@@ -81,7 +81,9 @@ class DummyCompilerTest(TestCase):
self
.
compiler
=
Compiler
()
def
test_output_path
(
self
):
output_path
=
self
.
compiler
.
output_path
(
"js/helpers.coffee"
,
"js"
)
compiler_class
=
self
.
compiler
.
compilers
[
0
]
compiler
=
compiler_class
(
verbose
=
self
.
compiler
.
verbose
,
storage
=
self
.
compiler
.
storage
)
output_path
=
compiler
.
output_path
(
"js/helpers.coffee"
,
"js"
)
self
.
assertEqual
(
output_path
,
"js/helpers.js"
)
def
test_compilers_class
(
self
):
...
...
@@ -107,7 +109,9 @@ class CompilerStdoutTest(TestCase):
self
.
compiler
=
Compiler
()
def
test_output_path
(
self
):
output_path
=
self
.
compiler
.
output_path
(
"js/helpers.coffee"
,
"js"
)
compiler_class
=
self
.
compiler
.
compilers
[
0
]
compiler
=
compiler_class
(
verbose
=
self
.
compiler
.
verbose
,
storage
=
self
.
compiler
.
storage
)
output_path
=
compiler
.
output_path
(
"js/helpers.coffee"
,
"js"
)
self
.
assertEqual
(
output_path
,
"js/helpers.js"
)
def
test_compile
(
self
):
...
...
@@ -126,7 +130,9 @@ class CompilerSelfWriterTest(TestCase):
self
.
compiler
=
Compiler
()
def
test_output_path
(
self
):
output_path
=
self
.
compiler
.
output_path
(
"js/helpers.coffee"
,
"js"
)
compiler_class
=
self
.
compiler
.
compilers
[
0
]
compiler
=
compiler_class
(
verbose
=
self
.
compiler
.
verbose
,
storage
=
self
.
compiler
.
storage
)
output_path
=
compiler
.
output_path
(
"js/helpers.coffee"
,
"js"
)
self
.
assertEqual
(
output_path
,
"js/helpers.js"
)
def
test_compile
(
self
):
...
...
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