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
7198db4b
Commit
7198db4b
authored
Feb 22, 2016
by
David Trowbridge
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #540 from davidt/compiler-paths
Allow compilers to override output_path.
parents
76da0626
2899300f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
pipeline/compilers/__init__.py
+6
-6
tests/tests/test_compiler.py
+9
-3
No files found.
pipeline/compilers/__init__.py
View file @
7198db4b
...
...
@@ -31,12 +31,12 @@ class Compiler(object):
for
compiler
in
self
.
compilers
:
compiler
=
compiler
(
verbose
=
self
.
verbose
,
storage
=
self
.
storage
)
if
compiler
.
match_file
(
input_path
):
output_path
=
self
.
output_path
(
input_path
,
compiler
.
output_extension
)
output_path
=
compiler
.
output_path
(
input_path
,
compiler
.
output_extension
)
try
:
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
(
input_path
,
output_path
)
compiler
.
compile_file
(
infile
,
outfile
,
outdated
=
outdated
,
force
=
force
)
...
...
@@ -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
...
...
tests/tests/test_compiler.py
View file @
7198db4b
...
...
@@ -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