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
...
@@ -10,7 +10,8 @@ from pipeline.utils import to_class
class
Compiler
(
object
):
class
Compiler
(
object
):
def
__init__
(
self
,
verbose
=
False
):
def
__init__
(
self
,
storage
=
default_storage
,
verbose
=
False
):
self
.
storage
=
storage
self
.
verbose
=
verbose
self
.
verbose
=
verbose
def
compilers
(
self
):
def
compilers
(
self
):
...
@@ -25,10 +26,10 @@ class Compiler(object):
...
@@ -25,10 +26,10 @@ class Compiler(object):
new_path
=
self
.
output_path
(
path
,
compiler
.
output_extension
)
new_path
=
self
.
output_path
(
path
,
compiler
.
output_extension
)
content
=
self
.
read_file
(
path
)
content
=
self
.
read_file
(
path
)
try
:
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
)
self
.
save_file
(
new_path
,
compiled_content
)
except
CompilerError
:
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
raise
paths
[
index
]
=
new_path
paths
[
index
]
=
new_path
return
paths
return
paths
...
@@ -38,13 +39,13 @@ class Compiler(object):
...
@@ -38,13 +39,13 @@ class Compiler(object):
return
'.'
.
join
((
path
[
0
],
extension
))
return
'.'
.
join
((
path
[
0
],
extension
))
def
read_file
(
self
,
path
):
def
read_file
(
self
,
path
):
file
=
default_
storage
.
open
(
path
,
'rb'
)
file
=
self
.
storage
.
open
(
path
,
'rb'
)
content
=
file
.
read
()
content
=
file
.
read
()
file
.
close
()
file
.
close
()
return
content
return
content
def
save_file
(
self
,
path
,
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
):
class
CompilerBase
(
object
):
...
@@ -57,9 +58,6 @@ class CompilerBase(object):
...
@@ -57,9 +58,6 @@ class CompilerBase(object):
def
compile_file
(
self
,
content
,
path
):
def
compile_file
(
self
,
content
,
path
):
raise
NotImplementedError
raise
NotImplementedError
def
save_file
(
self
,
path
,
content
):
return
default_storage
.
save
(
path
,
ContentFile
(
smart_str
(
content
)))
class
CompilerError
(
Exception
):
class
CompilerError
(
Exception
):
pass
pass
...
...
pipeline/compressors/__init__.py
View file @
9b2ae111
...
@@ -6,8 +6,8 @@ import subprocess
...
@@ -6,8 +6,8 @@ import subprocess
from
itertools
import
takewhile
from
itertools
import
takewhile
from
pipeline.conf
import
settings
from
pipeline.conf
import
settings
from
pipeline.storage
import
default_storage
from
pipeline.utils
import
to_class
,
relpath
from
pipeline.utils
import
to_class
,
relpath
from
pipeline.storage
import
default_storage
MAX_IMAGE_SIZE
=
32700
MAX_IMAGE_SIZE
=
32700
...
@@ -40,7 +40,8 @@ FONT_EXTS = ['.ttf', '.otf', '.woff']
...
@@ -40,7 +40,8 @@ FONT_EXTS = ['.ttf', '.otf', '.woff']
class
Compressor
(
object
):
class
Compressor
(
object
):
asset_contents
=
{}
asset_contents
=
{}
def
__init__
(
self
,
verbose
=
False
):
def
__init__
(
self
,
storage
=
default_storage
,
verbose
=
False
):
self
.
storage
=
storage
self
.
verbose
=
verbose
self
.
verbose
=
verbose
def
js_compressor
(
self
):
def
js_compressor
(
self
):
...
@@ -159,7 +160,7 @@ class Compressor(object):
...
@@ -159,7 +160,7 @@ class Compressor(object):
font
=
ext
in
FONT_EXTS
font
=
ext
in
FONT_EXTS
if
not
variant
:
if
not
variant
:
return
False
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
return
False
if
not
ext
in
EMBED_EXTS
:
if
not
ext
in
EMBED_EXTS
:
return
False
return
False
...
...
pipeline/packager.py
View file @
9b2ae111
...
@@ -61,10 +61,11 @@ class Package(object):
...
@@ -61,10 +61,11 @@ class Package(object):
class
Packager
(
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
.
verbose
=
verbose
self
.
compressor
=
Compressor
(
verbose
)
self
.
compressor
=
Compressor
(
storage
=
storage
,
verbose
=
verbose
)
self
.
compiler
=
Compiler
(
verbose
)
self
.
compiler
=
Compiler
(
storage
=
storage
,
verbose
=
verbose
)
if
css_packages
is
None
:
if
css_packages
is
None
:
css_packages
=
settings
.
PIPELINE_CSS
css_packages
=
settings
.
PIPELINE_CSS
if
js_packages
is
None
:
if
js_packages
is
None
:
...
@@ -85,7 +86,7 @@ class Packager(object):
...
@@ -85,7 +86,7 @@ class Packager(object):
)
)
def
individual_url
(
self
,
filename
):
def
individual_url
(
self
,
filename
):
return
default_
storage
.
url
(
filename
)
return
self
.
storage
.
url
(
filename
)
def
pack_stylesheets
(
self
,
package
,
**
kwargs
):
def
pack_stylesheets
(
self
,
package
,
**
kwargs
):
return
self
.
pack
(
package
,
self
.
compressor
.
compress_css
,
css_compressed
,
return
self
.
pack
(
package
,
self
.
compressor
.
compress_css
,
css_compressed
,
...
@@ -113,7 +114,7 @@ class Packager(object):
...
@@ -113,7 +114,7 @@ class Packager(object):
return
self
.
compressor
.
compile_templates
(
package
.
templates
)
return
self
.
compressor
.
compile_templates
(
package
.
templates
)
def
save_file
(
self
,
path
,
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
)))
def
create_packages
(
self
,
config
):
def
create_packages
(
self
,
config
):
packages
=
{}
packages
=
{}
...
...
pipeline/storage.py
View file @
9b2ae111
...
@@ -25,7 +25,7 @@ class PipelineStorage(StaticFilesStorage):
...
@@ -25,7 +25,7 @@ class PipelineStorage(StaticFilesStorage):
if
dry_run
:
if
dry_run
:
return
[]
return
[]
packager
=
Packager
()
packager
=
Packager
(
storage
=
self
)
for
package_name
in
packager
.
packages
[
'css'
]:
for
package_name
in
packager
.
packages
[
'css'
]:
package
=
packager
.
package_for
(
'css'
,
package_name
)
package
=
packager
.
package_for
(
'css'
,
package_name
)
output_file
=
packager
.
pack_stylesheets
(
package
)
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