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
9b2ae111
Commit
9b2ae111
authored
Feb 22, 2012
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass storage as argument
parent
0122689a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
17 deletions
+17
-17
pipeline/compilers/__init__.py
+6
-8
pipeline/compressors/__init__.py
+4
-3
pipeline/packager.py
+6
-5
pipeline/storage.py
+1
-1
No files found.
pipeline/compilers/__init__.py
View file @
9b2ae111
...
...
@@ -10,7 +10,8 @@ from pipeline.utils import to_class
class
Compiler
(
object
):
def
__init__
(
self
,
verbose
=
False
):
def
__init__
(
self
,
storage
=
default_storage
,
verbose
=
False
):
self
.
storage
=
storage
self
.
verbose
=
verbose
def
compilers
(
self
):
...
...
@@ -25,10 +26,10 @@ class Compiler(object):
new_path
=
self
.
output_path
(
path
,
compiler
.
output_extension
)
content
=
self
.
read_file
(
path
)
try
:
compiled_content
=
compiler
.
compile_file
(
content
,
default_
storage
.
path
(
path
))
compiled_content
=
compiler
.
compile_file
(
content
,
self
.
storage
.
path
(
path
))
self
.
save_file
(
new_path
,
compiled_content
)
except
CompilerError
:
if
not
default_
storage
.
exists
(
new_path
)
or
not
settings
.
PIPELINE
:
if
not
self
.
storage
.
exists
(
new_path
)
or
not
settings
.
PIPELINE
:
raise
paths
[
index
]
=
new_path
return
paths
...
...
@@ -38,13 +39,13 @@ class Compiler(object):
return
'.'
.
join
((
path
[
0
],
extension
))
def
read_file
(
self
,
path
):
file
=
default_
storage
.
open
(
path
,
'rb'
)
file
=
self
.
storage
.
open
(
path
,
'rb'
)
content
=
file
.
read
()
file
.
close
()
return
content
def
save_file
(
self
,
path
,
content
):
return
default_
storage
.
save
(
path
,
ContentFile
(
smart_str
(
content
)))
return
self
.
storage
.
save
(
path
,
ContentFile
(
smart_str
(
content
)))
class
CompilerBase
(
object
):
...
...
@@ -57,9 +58,6 @@ class CompilerBase(object):
def
compile_file
(
self
,
content
,
path
):
raise
NotImplementedError
def
save_file
(
self
,
path
,
content
):
return
default_storage
.
save
(
path
,
ContentFile
(
smart_str
(
content
)))
class
CompilerError
(
Exception
):
pass
...
...
pipeline/compressors/__init__.py
View file @
9b2ae111
...
...
@@ -6,8 +6,8 @@ import subprocess
from
itertools
import
takewhile
from
pipeline.conf
import
settings
from
pipeline.storage
import
default_storage
from
pipeline.utils
import
to_class
,
relpath
from
pipeline.storage
import
default_storage
MAX_IMAGE_SIZE
=
32700
...
...
@@ -40,7 +40,8 @@ FONT_EXTS = ['.ttf', '.otf', '.woff']
class
Compressor
(
object
):
asset_contents
=
{}
def
__init__
(
self
,
verbose
=
False
):
def
__init__
(
self
,
storage
=
default_storage
,
verbose
=
False
):
self
.
storage
=
storage
self
.
verbose
=
verbose
def
js_compressor
(
self
):
...
...
@@ -159,7 +160,7 @@ class Compressor(object):
font
=
ext
in
FONT_EXTS
if
not
variant
:
return
False
if
not
(
re
.
search
(
EMBEDDABLE
,
path
)
and
default_
storage
.
exists
(
path
)):
if
not
(
re
.
search
(
EMBEDDABLE
,
path
)
and
self
.
storage
.
exists
(
path
)):
return
False
if
not
ext
in
EMBED_EXTS
:
return
False
...
...
pipeline/packager.py
View file @
9b2ae111
...
...
@@ -61,10 +61,11 @@ class Package(object):
class
Packager
(
object
):
def
__init__
(
self
,
verbose
=
False
,
css_packages
=
None
,
js_packages
=
None
):
def
__init__
(
self
,
storage
=
default_storage
,
verbose
=
False
,
css_packages
=
None
,
js_packages
=
None
):
self
.
storage
=
storage
self
.
verbose
=
verbose
self
.
compressor
=
Compressor
(
verbose
)
self
.
compiler
=
Compiler
(
verbose
)
self
.
compressor
=
Compressor
(
storage
=
storage
,
verbose
=
verbose
)
self
.
compiler
=
Compiler
(
storage
=
storage
,
verbose
=
verbose
)
if
css_packages
is
None
:
css_packages
=
settings
.
PIPELINE_CSS
if
js_packages
is
None
:
...
...
@@ -85,7 +86,7 @@ class Packager(object):
)
def
individual_url
(
self
,
filename
):
return
default_
storage
.
url
(
filename
)
return
self
.
storage
.
url
(
filename
)
def
pack_stylesheets
(
self
,
package
,
**
kwargs
):
return
self
.
pack
(
package
,
self
.
compressor
.
compress_css
,
css_compressed
,
...
...
@@ -113,7 +114,7 @@ class Packager(object):
return
self
.
compressor
.
compile_templates
(
package
.
templates
)
def
save_file
(
self
,
path
,
content
):
return
default_
storage
.
save
(
path
,
ContentFile
(
smart_str
(
content
)))
return
self
.
storage
.
save
(
path
,
ContentFile
(
smart_str
(
content
)))
def
create_packages
(
self
,
config
):
packages
=
{}
...
...
pipeline/storage.py
View file @
9b2ae111
...
...
@@ -25,7 +25,7 @@ class PipelineStorage(StaticFilesStorage):
if
dry_run
:
return
[]
packager
=
Packager
()
packager
=
Packager
(
storage
=
self
)
for
package_name
in
packager
.
packages
[
'css'
]:
package
=
packager
.
package_for
(
'css'
,
package_name
)
output_file
=
packager
.
pack_stylesheets
(
package
)
...
...
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