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
1c87de9a
Commit
1c87de9a
authored
Jul 30, 2012
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add read/save_file method to CompilerBase
parent
7f87d3f2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
pipeline/compilers/__init__.py
+15
-2
No files found.
pipeline/compilers/__init__.py
View file @
1c87de9a
...
...
@@ -6,6 +6,9 @@ try:
except
ImportError
:
from
django.contrib.staticfiles
import
finders
# noqa
from
django.core.files.base
import
ContentFile
from
django.utils.encoding
import
smart_str
from
pipeline.conf
import
settings
from
pipeline.storage
import
default_storage
from
pipeline.utils
import
to_class
...
...
@@ -23,7 +26,7 @@ class Compiler(object):
def
compile
(
self
,
paths
,
force
=
False
):
for
index
,
input_path
in
enumerate
(
paths
):
for
compiler
in
self
.
compilers
:
compiler
=
compiler
(
self
.
verbos
e
)
compiler
=
compiler
(
verbose
=
self
.
verbose
,
storage
=
self
.
storag
e
)
if
compiler
.
match_file
(
input_path
):
output_path
=
self
.
output_path
(
input_path
,
compiler
.
output_extension
)
paths
[
index
]
=
output_path
...
...
@@ -53,8 +56,9 @@ class Compiler(object):
class
CompilerBase
(
object
):
def
__init__
(
self
,
verbose
):
def
__init__
(
self
,
verbose
,
storage
):
self
.
verbose
=
verbose
self
.
storage
=
storage
def
match_file
(
self
,
filename
):
raise
NotImplementedError
...
...
@@ -62,6 +66,15 @@ class CompilerBase(object):
def
compile_file
(
self
,
infile
,
outfile
,
outdated
=
False
,
force
=
False
):
raise
NotImplementedError
def
save_file
(
self
,
path
,
content
):
return
self
.
storage
.
save
(
path
,
ContentFile
(
smart_str
(
content
)))
def
read_file
(
self
,
path
):
file
=
self
.
storage
.
open
(
path
,
'rb'
)
content
=
file
.
read
()
file
.
close
()
return
content
class
CompilerError
(
Exception
):
pass
...
...
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