Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
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
pyfs
Commits
4a5b5409
Commit
4a5b5409
authored
Dec 22, 2012
by
gcode@loowis.durge.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made normpath('/.') and normpath('/..') behave more consistently
parent
43854af5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
fs/path.py
+3
-2
fs/tests/test_path.py
+3
-0
No files found.
fs/path.py
View file @
4a5b5409
...
@@ -46,7 +46,8 @@ def normpath(path):
...
@@ -46,7 +46,8 @@ def normpath(path):
if
not
_requires_normalization
(
path
):
if
not
_requires_normalization
(
path
):
return
path
.
rstrip
(
'/'
)
return
path
.
rstrip
(
'/'
)
components
=
[
''
]
if
path
.
startswith
(
'/'
)
else
[]
prefix
=
u'/'
if
path
.
startswith
(
'/'
)
else
u''
components
=
[]
append
=
components
.
append
append
=
components
.
append
special
=
(
'..'
,
'.'
,
''
)
.
__contains__
special
=
(
'..'
,
'.'
,
''
)
.
__contains__
try
:
try
:
...
@@ -61,7 +62,7 @@ def normpath(path):
...
@@ -61,7 +62,7 @@ def normpath(path):
# causing a circular import.
# causing a circular import.
from
fs.errors
import
BackReferenceError
from
fs.errors
import
BackReferenceError
raise
BackReferenceError
(
'Too many backrefs in
\'
%
s
\'
'
%
path
)
raise
BackReferenceError
(
'Too many backrefs in
\'
%
s
\'
'
%
path
)
return
u'/'
.
join
(
components
)
return
prefix
+
u'/'
.
join
(
components
)
if
os
.
sep
!=
'/'
:
if
os
.
sep
!=
'/'
:
...
...
fs/tests/test_path.py
View file @
4a5b5409
...
@@ -18,6 +18,7 @@ class TestPathFunctions(unittest.TestCase):
...
@@ -18,6 +18,7 @@ class TestPathFunctions(unittest.TestCase):
(
"."
,
""
),
(
"."
,
""
),
(
"./"
,
""
),
(
"./"
,
""
),
(
""
,
""
),
(
""
,
""
),
(
"/."
,
"/"
),
(
"/a/b/c"
,
"/a/b/c"
),
(
"/a/b/c"
,
"/a/b/c"
),
(
"a/b/c"
,
"a/b/c"
),
(
"a/b/c"
,
"a/b/c"
),
(
"a/b/../c/"
,
"a/c"
),
(
"a/b/../c/"
,
"a/c"
),
...
@@ -50,7 +51,9 @@ class TestPathFunctions(unittest.TestCase):
...
@@ -50,7 +51,9 @@ class TestPathFunctions(unittest.TestCase):
result
=
testpaths
[
-
1
]
result
=
testpaths
[
-
1
]
self
.
assertEqual
(
pathjoin
(
*
paths
),
result
)
self
.
assertEqual
(
pathjoin
(
*
paths
),
result
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
".."
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"../"
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"../"
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"/.."
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"./../"
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"./../"
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"a/b"
,
"../../.."
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"a/b"
,
"../../.."
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"a/b/../../../d"
)
self
.
assertRaises
(
ValueError
,
pathjoin
,
"a/b/../../../d"
)
...
...
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