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
7ce7ce4b
Commit
7ce7ce4b
authored
Feb 27, 2012
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move processing in a mixin
parent
4bac1a4d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
22 deletions
+15
-22
pipeline/storage.py
+15
-22
No files found.
pipeline/storage.py
View file @
7ce7ce4b
...
@@ -2,10 +2,10 @@ import os
...
@@ -2,10 +2,10 @@ import os
try
:
try
:
from
staticfiles
import
finders
from
staticfiles
import
finders
from
staticfiles.storage
import
Cached
StaticFilesStorage
,
StaticFilesStorage
from
staticfiles.storage
import
Cached
FilesMixin
,
StaticFilesStorage
except
ImportError
:
except
ImportError
:
from
django.contrib.staticfiles
import
finders
from
django.contrib.staticfiles
import
finders
from
django.contrib.staticfiles.storage
import
Cached
StaticFilesStorage
,
StaticFilesStorage
from
django.contrib.staticfiles.storage
import
Cached
FilesMixin
,
StaticFilesStorage
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.files.storage
import
get_storage_class
from
django.core.files.storage
import
get_storage_class
...
@@ -14,17 +14,12 @@ from django.utils.functional import LazyObject
...
@@ -14,17 +14,12 @@ from django.utils.functional import LazyObject
from
pipeline.conf
import
settings
from
pipeline.conf
import
settings
class
PipelineStorage
(
StaticFilesStorage
):
class
PipelineMixin
(
object
):
def
get_available_name
(
self
,
name
):
if
self
.
exists
(
name
):
self
.
delete
(
name
)
return
name
def
post_process
(
self
,
paths
,
dry_run
=
False
,
**
options
):
def
post_process
(
self
,
paths
,
dry_run
=
False
,
**
options
):
from
pipeline.packager
import
Packager
if
dry_run
:
if
dry_run
:
return
[]
return
[]
from
pipeline.packager
import
Packager
packager
=
Packager
(
storage
=
self
)
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
)
...
@@ -35,7 +30,7 @@ class PipelineStorage(StaticFilesStorage):
...
@@ -35,7 +30,7 @@ class PipelineStorage(StaticFilesStorage):
output_file
=
packager
.
pack_javascripts
(
package
)
output_file
=
packager
.
pack_javascripts
(
package
)
paths
[
output_file
]
=
(
self
,
output_file
)
paths
[
output_file
]
=
(
self
,
output_file
)
super_class
=
super
(
Pipeline
Storage
,
self
)
super_class
=
super
(
Pipeline
Mixin
,
self
)
if
hasattr
(
super_class
,
'post_process'
):
if
hasattr
(
super_class
,
'post_process'
):
return
super_class
.
post_process
(
paths
,
dry_run
,
**
options
)
return
super_class
.
post_process
(
paths
,
dry_run
,
**
options
)
...
@@ -44,20 +39,18 @@ class PipelineStorage(StaticFilesStorage):
...
@@ -44,20 +39,18 @@ class PipelineStorage(StaticFilesStorage):
for
path
in
paths
for
path
in
paths
]
]
def
get_available_name
(
self
,
name
):
if
self
.
exists
(
name
):
self
.
delete
(
name
)
return
name
class
PipelineCachedStorage
(
PipelineStorage
,
CachedStaticFilesStorage
):
def
post_process
(
self
,
paths
,
dry_run
=
False
,
**
options
):
from
pipeline.packager
import
Packager
packager
=
Packager
(
storage
=
self
)
class
PipelineStorage
(
PipelineMixin
,
StaticFilesStorage
):
if
dry_run
:
pass
for
asset_type
in
[
'css'
,
'js'
]:
for
package_name
in
packager
.
packages
[
asset_type
]:
package
=
packager
.
package_for
(
'js'
,
package_name
)
class
PipelineCachedStorage
(
CachedFilesMixin
,
PipelineStorage
):
paths
[
package
.
output_filename
]
=
(
self
,
package
.
output_filename
)
pass
self
.
cache
.
delete_many
([
self
.
cache_key
(
path
)
for
path
in
paths
])
return
[]
return
super
(
PipelineCachedStorage
,
self
)
.
post_process
(
paths
,
dry_run
,
**
options
)
class
BaseFinderStorage
(
PipelineStorage
):
class
BaseFinderStorage
(
PipelineStorage
):
...
...
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