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
36b626d8
Commit
36b626d8
authored
Jul 24, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just some tweaks
parent
e6834c21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
+18
-15
fs/fs.py
+18
-15
No files found.
fs/fs.py
View file @
36b626d8
...
@@ -134,12 +134,12 @@ def makerelative(path):
...
@@ -134,12 +134,12 @@ def makerelative(path):
return
path
return
path
def
_iteratepath
(
path
,
numsplits
=
None
):
def
_iteratepath
(
path
,
numsplits
=
None
):
path
=
resolvepath
(
path
)
path
=
resolvepath
(
path
)
if
not
path
:
if
not
path
:
return
[]
return
[]
if
numsplits
==
None
:
if
numsplits
==
None
:
return
filter
(
lambda
p
:
bool
(
p
),
path
.
split
(
'/'
))
return
filter
(
lambda
p
:
bool
(
p
),
path
.
split
(
'/'
))
else
:
else
:
...
@@ -175,7 +175,7 @@ class FS(object):
...
@@ -175,7 +175,7 @@ class FS(object):
def
_resolve
(
self
,
pathname
):
def
_resolve
(
self
,
pathname
):
resolved_path
=
resolvepath
(
pathname
)
resolved_path
=
resolvepath
(
pathname
)
return
resolved_path
return
resolved_path
...
@@ -267,12 +267,12 @@ class OSFS(FS):
...
@@ -267,12 +267,12 @@ class OSFS(FS):
def
__init__
(
self
,
root_path
):
def
__init__
(
self
,
root_path
):
expanded_path
=
normpath
(
os
.
path
.
expanduser
(
root_path
))
expanded_path
=
normpath
(
os
.
path
.
expanduser
(
root_path
))
if
not
os
.
path
.
exists
(
expanded_path
):
if
not
os
.
path
.
exists
(
expanded_path
):
raise
FSError
(
"NO_DIR"
,
expanded_path
,
msg
=
"Root directory does not exist:
%(path)
s"
)
raise
FSError
(
"NO_DIR"
,
expanded_path
,
msg
=
"Root directory does not exist:
%(path)
s"
)
if
not
os
.
path
.
isdir
(
expanded_path
):
if
not
os
.
path
.
isdir
(
expanded_path
):
raise
FSError
(
"NO_DIR"
,
expanded_path
,
msg
=
"Root path is not a directory:
%(path)
s"
)
raise
FSError
(
"NO_DIR"
,
expanded_path
,
msg
=
"Root path is not a directory:
%(path)
s"
)
self
.
root_path
=
normpath
(
os
.
path
.
abspath
(
expanded_path
))
self
.
root_path
=
normpath
(
os
.
path
.
abspath
(
expanded_path
))
#print "Root path", self.root_path
#print "Root path", self.root_path
...
@@ -282,8 +282,8 @@ class OSFS(FS):
...
@@ -282,8 +282,8 @@ class OSFS(FS):
def
getsyspath
(
self
,
pathname
):
def
getsyspath
(
self
,
pathname
):
sys_path
=
os
.
path
.
join
(
self
.
root_path
,
makerelative
(
self
.
_resolve
(
pathname
)))
sys_path
=
os
.
path
.
join
(
self
.
root_path
,
makerelative
(
self
.
_resolve
(
pathname
)))
return
sys_path
return
sys_path
...
@@ -327,17 +327,17 @@ class OSFS(FS):
...
@@ -327,17 +327,17 @@ class OSFS(FS):
def
mkdir
(
self
,
path
,
mode
=
0777
,
recursive
=
False
):
def
mkdir
(
self
,
path
,
mode
=
0777
,
recursive
=
False
):
sys_path
=
self
.
getsyspath
(
path
)
sys_path
=
self
.
getsyspath
(
path
)
if
recursive
:
if
recursive
:
makedirs
(
sys_path
,
mode
)
makedirs
(
sys_path
,
mode
)
else
:
else
:
makedir
(
sys_path
,
mode
)
makedir
(
sys_path
,
mode
)
def
remove
(
self
,
path
):
def
remove
(
self
,
path
):
sys_path
=
self
.
getsyspath
(
path
)
sys_path
=
self
.
getsyspath
(
path
)
os
.
remove
(
sys_path
)
os
.
remove
(
sys_path
)
...
@@ -474,7 +474,10 @@ if __name__ == "__main__":
...
@@ -474,7 +474,10 @@ if __name__ == "__main__":
print
osfs
print
osfs
#print osfs
#print osfs
print_fs
(
osfs
)
import
browsewin
browsewin
.
browse
(
osfs
)
#print_fs(osfs)
#print osfs.listdir("/projects/fs")
#print osfs.listdir("/projects/fs")
...
...
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