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
14ee919f
Commit
14ee919f
authored
Jun 16, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve storage use
parent
1ce6a1ac
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
19 deletions
+12
-19
pipeline/compilers/__init__.py
+3
-3
pipeline/compressors/__init__.py
+1
-3
pipeline/packager.py
+5
-5
pipeline/versioning/__init__.py
+3
-8
No files found.
pipeline/compilers/__init__.py
View file @
14ee919f
import
os
import
subprocess
from
django.core.files.base
import
ContentFile
from
pipeline.conf
import
settings
from
pipeline.storage
import
storage
from
pipeline.utils
import
to_class
...
...
@@ -41,9 +43,7 @@ class Compiler(object):
return
content
def
save_file
(
self
,
path
,
content
):
file
=
storage
.
open
(
path
,
'wb'
)
file
.
write
(
content
)
file
.
close
()
return
storage
.
save
(
path
,
ContentFile
(
content
))
class
CompilerBase
(
object
):
...
...
pipeline/compressors/__init__.py
View file @
14ee919f
...
...
@@ -94,9 +94,8 @@ class Compressor(object):
def
template_name
(
self
,
path
,
base
):
name
=
os
.
path
.
basename
(
path
)
base
=
os
.
path
.
abspath
(
base
)
if
base
:
name
=
re
.
sub
(
r"^
%
s\/(.*)
%
s$"
%
(
name
=
re
.
sub
(
r"^
%
s\/
?
(.*)
%
s$"
%
(
re
.
escape
(
base
),
re
.
escape
(
settings
.
PIPELINE_TEMPLATE_EXT
)
),
r"\1"
,
path
)
return
re
.
sub
(
r"[\/\\]"
,
"_"
,
name
)
...
...
@@ -239,5 +238,4 @@ class SubProcessCompressor(CompressorBase):
if
self
.
verbose
:
print
error
return
compressed_content
pipeline/packager.py
View file @
14ee919f
...
...
@@ -2,6 +2,8 @@ import glob
import
os
import
urlparse
from
django.core.files.base
import
ContentFile
from
pipeline.conf
import
settings
from
pipeline.compilers
import
Compiler
from
pipeline.compressors
import
Compressor
...
...
@@ -54,7 +56,7 @@ class Packager(object):
self
.
versioning
.
cleanup
(
package
[
'output'
])
if
self
.
verbose
or
self
.
force
:
print
"Version:
%
s"
%
version
print
"Saving:
%
s"
%
self
.
compressor
.
relative_path
(
output_filename
)
print
"Saving:
%
s"
%
output_filename
paths
=
self
.
compile
(
package
[
'paths'
])
content
=
compress
(
paths
,
asset_url
=
self
.
individual_url
(
output_filename
),
**
kwargs
)
...
...
@@ -72,9 +74,7 @@ class Packager(object):
return
self
.
compressor
.
compile_templates
(
package
[
'templates'
])
def
save_file
(
self
,
filename
,
content
):
file
=
storage
.
open
(
filename
,
mode
=
'wb+'
)
file
.
write
(
content
)
file
.
close
()
return
storage
.
save
(
filename
,
ContentFile
(
content
))
def
create_packages
(
self
,
config
):
packages
=
{}
...
...
@@ -89,7 +89,7 @@ class Packager(object):
for
path
in
config
[
name
][
'source_filenames'
]:
full_path
=
os
.
path
.
join
(
settings
.
PIPELINE_ROOT
,
path
)
for
path
in
glob
.
glob
(
full_path
):
path
=
os
.
path
.
normpath
(
path
)
.
replace
(
settings
.
PIPELINE_ROOT
,
''
)
path
=
os
.
path
.
relpath
(
path
,
settings
.
PIPELINE_ROOT
)
if
not
path
in
paths
:
paths
.
append
(
path
)
packages
[
name
][
'paths'
]
=
[
path
for
path
in
paths
if
not
path
.
endswith
(
settings
.
PIPELINE_TEMPLATE_EXT
)]
...
...
pipeline/versioning/__init__.py
View file @
14ee919f
...
...
@@ -30,21 +30,16 @@ class Versioning(object):
def
output_filename
(
self
,
filename
,
version
):
if
settings
.
PIPELINE_VERSION
and
version
is
not
None
:
output_filename
=
filename
.
replace
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
,
return
filename
.
replace
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
,
version
)
else
:
output_filename
=
filename
.
replace
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
,
return
filename
.
replace
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
,
settings
.
PIPELINE_VERSION_DEFAULT
)
output_path
=
os
.
path
.
join
(
settings
.
PIPELINE_ROOT
,
output_filename
)
return
os
.
path
.
normpath
(
output_path
)
def
relative_path
(
self
,
filename
):
return
os
.
path
.
join
(
settings
.
PIPELINE_ROOT
,
filename
)
def
need_update
(
self
,
output_file
,
paths
):
version
=
self
.
version
(
paths
)
output_file
=
self
.
output_filename
(
output_file
,
version
)
if
not
storage
.
exists
(
self
.
relative_path
(
output_file
)
):
if
not
storage
.
exists
(
output_file
):
return
True
,
version
return
getattr
(
self
.
versionner
,
'need_update'
)(
output_file
,
paths
,
version
)
...
...
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