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
334e3dd2
Commit
334e3dd2
authored
Aug 26, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve and cache version_from_file calculations
parent
2aaf293f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
pipeline/signals.py
+12
-1
pipeline/versioning/__init__.py
+15
-9
No files found.
pipeline/signals.py
View file @
334e3dd2
from
django.dispatch
import
Signal
import
os
from
django.core.cache
import
cache
from
django.dispatch
import
Signal
,
receiver
css_compressed
=
Signal
(
providing_args
=
[
"package"
,
"version"
])
css_compressed
=
Signal
(
providing_args
=
[
"package"
,
"version"
])
js_compressed
=
Signal
(
providing_args
=
[
"package"
,
"version"
])
js_compressed
=
Signal
(
providing_args
=
[
"package"
,
"version"
])
@receiver
(
css_compressed
)
@receiver
(
js_compressed
)
def
invalidate_cache
(
sender
,
package
,
version
,
**
kwargs
):
filename_base
,
filename
=
os
.
path
.
split
(
package
[
'output'
])
cache
.
set
(
"pipeline:
%
s"
%
filename
,
str
(
version
))
pipeline/versioning/__init__.py
View file @
334e3dd2
import
os
import
os
import
re
import
re
from
django.core.cache
import
cache
from
pipeline.conf
import
settings
from
pipeline.conf
import
settings
from
pipeline.storage
import
storage
from
pipeline.storage
import
storage
from
pipeline.utils
import
to_class
from
pipeline.utils
import
to_class
...
@@ -18,15 +20,18 @@ class Versioning(object):
...
@@ -18,15 +20,18 @@ class Versioning(object):
return
getattr
(
self
.
versioner
,
'version'
)(
paths
)
return
getattr
(
self
.
versioner
,
'version'
)(
paths
)
def
version_from_file
(
self
,
path
,
filename
):
def
version_from_file
(
self
,
path
,
filename
):
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
version
=
cache
.
get
(
"pipeline:
%
s"
%
filename
)
if
not
version
:
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
regex
=
re
.
compile
(
r'^
%
s$'
%
self
.
output_filename
(
filename
,
r'([A-Za-z0-9]+)'
))
regex
=
re
.
compile
(
r'^
%
s$'
%
self
.
output_filename
(
filename
,
r'([A-Za-z0-9]+)'
))
versions
=
[]
for
f
in
storage
.
listdir
(
path
)[
1
]:
for
f
in
sorted
(
storage
.
listdir
(
path
)[
1
],
reverse
=
True
):
match
=
regex
.
match
(
f
)
version
=
regex
.
match
(
f
)
if
match
and
match
.
groups
():
if
version
and
version
.
groups
():
version
=
match
.
group
(
1
)
versions
.
append
(
version
.
group
(
1
))
break
versions
.
sort
(
)
cache
.
set
(
"pipeline:
%
s"
%
filename
,
version
)
return
versions
[
-
1
]
return
str
(
version
)
def
output_filename
(
self
,
filename
,
version
):
def
output_filename
(
self
,
filename
,
version
):
if
settings
.
PIPELINE_VERSION
and
version
is
not
None
:
if
settings
.
PIPELINE_VERSION
and
version
is
not
None
:
...
@@ -46,7 +51,8 @@ class Versioning(object):
...
@@ -46,7 +51,8 @@ class Versioning(object):
return
# Nothing to delete here
return
# Nothing to delete here
path
=
os
.
path
.
dirname
(
filename
)
path
=
os
.
path
.
dirname
(
filename
)
filename
=
os
.
path
.
basename
(
filename
)
filename
=
os
.
path
.
basename
(
filename
)
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
regex
=
re
.
compile
(
r'^
%
s$'
%
self
.
output_filename
(
filename
,
r'([A-Za-z0-9]+)'
))
regex
=
re
.
compile
(
r'^
%
s$'
%
self
.
output_filename
(
filename
,
r'([A-Za-z0-9]+)'
))
try
:
try
:
for
f
in
storage
.
listdir
(
path
)[
1
]:
for
f
in
storage
.
listdir
(
path
)[
1
]:
...
...
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