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
f03463f0
Commit
f03463f0
authored
Jan 16, 2011
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with normpath('.') and added test
parent
d52cc3fb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
fs/path.py
+2
-2
fs/tests/test_path.py
+2
-0
No files found.
fs/path.py
View file @
f03463f0
...
@@ -12,7 +12,7 @@ optional leading slash).
...
@@ -12,7 +12,7 @@ optional leading slash).
import
re
import
re
_requires_normalization
=
re
.
compile
(
r'/\.\.|\./|//|\\'
)
.
search
_requires_normalization
=
re
.
compile
(
r'/\.\.|\./|
\.|
//|\\'
)
.
search
def
normpath
(
path
):
def
normpath
(
path
):
"""Normalizes a path to be in the format expected by FS objects.
"""Normalizes a path to be in the format expected by FS objects.
...
@@ -40,7 +40,7 @@ def normpath(path):
...
@@ -40,7 +40,7 @@ def normpath(path):
if
path
in
(
''
,
'/'
):
if
path
in
(
''
,
'/'
):
return
path
return
path
# An early out if there is no need to normalize this pa
a
th
# An early out if there is no need to normalize this path
if
not
_requires_normalization
(
path
):
if
not
_requires_normalization
(
path
):
return
path
.
rstrip
(
'/'
)
return
path
.
rstrip
(
'/'
)
...
...
fs/tests/test_path.py
View file @
f03463f0
...
@@ -15,6 +15,8 @@ class TestPathFunctions(unittest.TestCase):
...
@@ -15,6 +15,8 @@ class TestPathFunctions(unittest.TestCase):
def
test_normpath
(
self
):
def
test_normpath
(
self
):
tests
=
[
(
"
\\
a
\\
b
\\
c"
,
"/a/b/c"
),
tests
=
[
(
"
\\
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/b/c"
),
...
...
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