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
835067c9
Commit
835067c9
authored
Oct 18, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add python 2.5 support
parent
8b018a13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
3 deletions
+56
-3
pipeline/compressors/__init__.py
+2
-3
pipeline/utils.py
+54
-0
No files found.
pipeline/compressors/__init__.py
View file @
835067c9
...
...
@@ -2,11 +2,10 @@ import base64
import
os
import
re
import
subprocess
import
urlparse
from
pipeline.conf
import
settings
from
pipeline.storage
import
storage
from
pipeline.utils
import
to_class
from
pipeline.utils
import
to_class
,
relpath
MAX_IMAGE_SIZE
=
32700
...
...
@@ -200,7 +199,7 @@ class Compressor(object):
def
relative_path
(
self
,
absolute_path
):
"""Rewrite paths relative to the output stylesheet path"""
absolute_path
=
self
.
absolute_path
(
absolute_path
,
settings
.
PIPELINE_ROOT
)
return
os
.
path
.
join
(
os
.
sep
,
os
.
path
.
relpath
(
absolute_path
,
settings
.
PIPELINE_ROOT
))
return
os
.
path
.
join
(
os
.
sep
,
relpath
(
absolute_path
,
settings
.
PIPELINE_ROOT
))
def
read_file
(
self
,
path
):
"""Read file content in binary mode"""
...
...
pipeline/utils.py
View file @
835067c9
import
os
import
sys
from
django.utils
import
importlib
...
...
@@ -6,3 +9,54 @@ def to_class(class_str):
module_path
,
class_name
=
'.'
.
join
(
module_bits
[:
-
1
]),
module_bits
[
-
1
]
module
=
importlib
.
import_module
(
module_path
)
return
getattr
(
module
,
class_name
,
None
)
def
_relpath_nt
(
path
,
start
=
os
.
path
.
curdir
):
"""Return a relative version of a path"""
if
not
path
:
raise
ValueError
(
"no path specified"
)
start_list
=
os
.
path
.
abspath
(
start
)
.
split
(
os
.
path
.
sep
)
path_list
=
os
.
path
.
abspath
(
path
)
.
split
(
os
.
path
.
sep
)
if
start_list
[
0
]
.
lower
()
!=
path_list
[
0
]
.
lower
():
unc_path
,
rest
=
os
.
path
.
splitunc
(
path
)
unc_start
,
rest
=
os
.
path
.
splitunc
(
start
)
if
bool
(
unc_path
)
^
bool
(
unc_start
):
raise
ValueError
(
"Cannot mix UNC and non-UNC paths (
%
s and
%
s)"
%
(
path
,
start
))
else
:
raise
ValueError
(
"path is on drive
%
s, start on drive
%
s"
%
(
path_list
[
0
],
start_list
[
0
]))
# Work out how much of the filepath is shared by start and path.
for
i
in
range
(
min
(
len
(
start_list
),
len
(
path_list
))):
if
start_list
[
i
]
.
lower
()
!=
path_list
[
i
]
.
lower
():
break
else
:
i
+=
1
rel_list
=
[
os
.
path
.
pardir
]
*
(
len
(
start_list
)
-
i
)
+
path_list
[
i
:]
if
not
rel_list
:
return
os
.
path
.
curdir
return
os
.
path
.
join
(
*
rel_list
)
def
_relpath_posix
(
path
,
start
=
os
.
path
.
curdir
):
"""Return a relative version of a path"""
if
not
path
:
raise
ValueError
(
"no path specified"
)
start_list
=
os
.
path
.
abspath
(
start
)
.
split
(
os
.
path
.
sep
)
path_list
=
os
.
path
.
abspath
(
path
)
.
split
(
os
.
path
.
sep
)
# Work out how much of the filepath is shared by start and path.
i
=
len
(
os
.
path
.
commonprefix
([
start_list
,
path_list
]))
rel_list
=
[
os
.
path
.
pardir
]
*
(
len
(
start_list
)
-
i
)
+
path_list
[
i
:]
if
not
rel_list
:
return
os
.
path
.
curdir
return
os
.
path
.
join
(
*
rel_list
)
if
os
.
path
is
sys
.
modules
.
get
(
'ntpath'
):
relpath
=
_relpath_nt
else
:
relpath
=
_relpath_posix
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