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
2f4bc57f
Commit
2f4bc57f
authored
Dec 05, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid using broken os.path.commonprefix
parent
d0a012d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletions
+17
-1
.gitignore
+2
-0
pipeline/compressors/__init__.py
+9
-1
tests/tests/compressor.py
+6
-0
No files found.
.gitignore
View file @
2f4bc57f
...
...
@@ -10,6 +10,7 @@ docs/_build/
*.egg-info
.coverage
coverage/
tests/static/
tests/assets/js/dummy.js
.tox/
.DS_Store
\ No newline at end of file
pipeline/compressors/__init__.py
View file @
2f4bc57f
...
...
@@ -3,6 +3,8 @@ import os
import
re
import
subprocess
from
itertools
import
takewhile
from
pipeline.conf
import
settings
from
pipeline.storage
import
storage
from
pipeline.utils
import
to_class
,
relpath
...
...
@@ -80,7 +82,7 @@ class Compressor(object):
if
not
paths
:
return
compiled
namespace
=
settings
.
PIPELINE_TEMPLATE_NAMESPACE
base_path
=
os
.
path
.
commonprefix
(
paths
)
base_path
=
self
.
base_path
(
paths
)
for
path
in
paths
:
contents
=
self
.
read_file
(
path
)
contents
=
re
.
sub
(
r"\r?\n"
,
""
,
contents
)
...
...
@@ -97,6 +99,12 @@ class Compressor(object):
compiled
])
def
base_path
(
self
,
paths
):
def
names_equal
(
name
):
return
all
(
n
==
name
[
0
]
for
n
in
name
[
1
:])
directory_levels
=
zip
(
*
[
p
.
split
(
os
.
sep
)
for
p
in
paths
])
return
os
.
sep
.
join
(
x
[
0
]
for
x
in
takewhile
(
names_equal
,
directory_levels
))
def
template_name
(
self
,
path
,
base
):
"""Find out the name of a JS template"""
if
not
base
:
...
...
tests/tests/compressor.py
View file @
2f4bc57f
...
...
@@ -50,6 +50,12 @@ class CompressorTest(TestCase):
relative_path
=
self
.
compressor
.
relative_path
(
'/var/www/static/images/sprite.png'
)
self
.
assertEquals
(
relative_path
,
'/images/sprite.png'
)
def
test_base_path
(
self
):
base_path
=
self
.
compressor
.
base_path
([
'js/templates/form.jst'
,
'js/templates/field.jst'
])
self
.
assertEquals
(
base_path
,
'js/templates'
)
def
test_absolute_path
(
self
):
absolute_path
=
self
.
compressor
.
absolute_path
(
'../../images/sprite.png'
,
'css/plugins/'
)
...
...
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