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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
11 deletions
+28
-11
pipeline/signals.py
+12
-1
pipeline/versioning/__init__.py
+16
-10
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"
])
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
re
from
django.core.cache
import
cache
from
pipeline.conf
import
settings
from
pipeline.storage
import
storage
from
pipeline.utils
import
to_class
...
...
@@ -18,15 +20,18 @@ class Versioning(object):
return
getattr
(
self
.
versioner
,
'version'
)(
paths
)
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
)])
regex
=
re
.
compile
(
r'^
%
s$'
%
self
.
output_filename
(
filename
,
r'([A-Za-z0-9]+)'
))
versions
=
[]
for
f
in
sorted
(
storage
.
listdir
(
path
)[
1
],
reverse
=
True
):
version
=
regex
.
match
(
f
)
if
version
and
version
.
groups
():
versions
.
append
(
version
.
group
(
1
))
versions
.
sort
()
return
versions
[
-
1
]
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]+)'
))
for
f
in
storage
.
listdir
(
path
)[
1
]:
match
=
regex
.
match
(
f
)
if
match
and
match
.
groups
():
version
=
match
.
group
(
1
)
break
cache
.
set
(
"pipeline:
%
s"
%
filename
,
version
)
return
str
(
version
)
def
output_filename
(
self
,
filename
,
version
):
if
settings
.
PIPELINE_VERSION
and
version
is
not
None
:
...
...
@@ -46,7 +51,8 @@ class Versioning(object):
return
# Nothing to delete here
path
=
os
.
path
.
dirname
(
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]+)'
))
try
:
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