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
2490d82a
Commit
2490d82a
authored
Nov 19, 2009
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a 'makeopendir' method which makes and opens a directory in one. Made FS objects iterable
parent
08428cd2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
fs/base.py
+22
-2
No files found.
fs/base.py
View file @
2490d82a
...
@@ -246,6 +246,12 @@ class FS(object):
...
@@ -246,6 +246,12 @@ class FS(object):
raise
UnsupportedError
(
"check for file"
)
raise
UnsupportedError
(
"check for file"
)
def
__iter__
(
self
):
""" Iterates over paths returned by listdir method with default params. """
for
f
in
self
.
listdir
():
yield
f
def
listdir
(
self
,
path
=
"./"
,
def
listdir
(
self
,
path
=
"./"
,
wildcard
=
None
,
wildcard
=
None
,
full
=
False
,
full
=
False
,
...
@@ -689,11 +695,26 @@ class FS(object):
...
@@ -689,11 +695,26 @@ class FS(object):
return
False
return
False
def
makeopendir
(
self
,
path
,
recursive
=
False
):
"""Makes a directory (if it doesn't exist) and returns an FS object for
the newly created directory.
path -- Path to the new directory
recursive -- If True any intermediate directories will be created
"""
self
.
makedir
(
path
,
allow_recreate
=
True
,
recursive
=
recursive
)
dir_fs
=
self
.
opendir
(
path
)
return
dir_fs
class
SubFS
(
FS
):
class
SubFS
(
FS
):
"""A SubFS represents a sub directory of another filesystem object.
"""A SubFS represents a sub directory of another filesystem object.
SubFS objects are returned by opendir, which effectively creates a
'sandbox'
SubFS objects are returned by opendir, which effectively creates a
'sandbox' filesystem that can only access files/dirs under a root path
'sandbox' filesystem that can only access files/dirs under a root path
within its 'parent' dir.
within its 'parent' dir.
"""
"""
...
@@ -825,4 +846,3 @@ def flags_to_mode(flags):
...
@@ -825,4 +846,3 @@ def flags_to_mode(flags):
else
:
else
:
mode
=
"r"
mode
=
"r"
return
mode
return
mode
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