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
e7b412f9
Commit
e7b412f9
authored
Sep 10, 2011
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a circular reference issue
parent
c56e8ae6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
22 deletions
+18
-22
ChangeLog
+2
-1
fs/__init__.py
+1
-1
fs/commands/runner.py
+1
-1
fs/mountfs.py
+1
-1
fs/opener.py
+13
-18
No files found.
ChangeLog
View file @
e7b412f9
...
@@ -79,4 +79,5 @@
...
@@ -79,4 +79,5 @@
* Removed obsolete module fs.objectree; use fs.path.PathMap instead.
* Removed obsolete module fs.objectree; use fs.path.PathMap instead.
* Added setcontents_async method to base
* Added setcontents_async method to base
* Added `appdirfs` module to abstract per-user application directories
* Added `appdirfs` module to abstract per-user application directories
0.5:
fs/__init__.py
View file @
e7b412f9
...
@@ -15,7 +15,7 @@ implementations of this interface such as:
...
@@ -15,7 +15,7 @@ implementations of this interface such as:
"""
"""
__version__
=
"0.4.
0rc
"
__version__
=
"0.4.
1
"
__author__
=
"Will McGugan (will@willmcgugan.com)"
__author__
=
"Will McGugan (will@willmcgugan.com)"
# No longer necessary - WM
# No longer necessary - WM
...
...
fs/commands/runner.py
View file @
e7b412f9
...
@@ -82,7 +82,7 @@ class Command(object):
...
@@ -82,7 +82,7 @@ class Command(object):
self
.
verbosity_level
=
0
self
.
verbosity_level
=
0
self
.
terminal_colors
=
not
sys
.
platform
.
startswith
(
'win'
)
and
self
.
is_terminal
()
self
.
terminal_colors
=
not
sys
.
platform
.
startswith
(
'win'
)
and
self
.
is_terminal
()
if
self
.
is_terminal
():
if
self
.
is_terminal
():
w
,
h
=
getTerminalSize
()
w
,
_
h
=
getTerminalSize
()
self
.
terminal_width
=
w
self
.
terminal_width
=
w
else
:
else
:
self
.
terminal_width
=
80
self
.
terminal_width
=
80
...
...
fs/mountfs.py
View file @
e7b412f9
...
@@ -19,7 +19,7 @@ For example, lets say we have two filesystems containing config files and resour
...
@@ -19,7 +19,7 @@ For example, lets say we have two filesystems containing config files and resour
We can combine these filesystems in to a single filesystem with the following code::
We can combine these filesystems in to a single filesystem with the following code::
from fs.mountfs import MountFS
from fs.mountfs import MountFS
combined_fs = MountFS
combined_fs = MountFS
()
combined_fs.mountdir('config', config_fs)
combined_fs.mountdir('config', config_fs)
combined_fs.mountdir('resources', resources_fs)
combined_fs.mountdir('resources', resources_fs)
...
...
fs/opener.py
View file @
e7b412f9
...
@@ -67,6 +67,7 @@ __all__ = ['OpenerError',
...
@@ -67,6 +67,7 @@ __all__ = ['OpenerError',
'HTTPOpener'
]
'HTTPOpener'
]
from
fs.path
import
pathsplit
,
join
,
iswildcard
,
normpath
from
fs.path
import
pathsplit
,
join
,
iswildcard
,
normpath
from
fs.filelike
import
FileWrapper
from
os
import
getcwd
from
os
import
getcwd
import
os.path
import
os.path
import
re
import
re
...
@@ -117,6 +118,14 @@ def _split_url_path(url):
...
@@ -117,6 +118,14 @@ def _split_url_path(url):
url
=
'
%
s://
%
s'
%
(
scheme
,
netloc
)
url
=
'
%
s://
%
s'
%
(
scheme
,
netloc
)
return
url
,
path
return
url
,
path
class
_FSClosingFile
(
FileWrapper
):
"""A file like object that closes its parent FS when closed itself"""
def
close
(
self
):
fs
=
getattr
(
self
,
'_closefs'
,
None
)
ret
=
super
(
_FSClosingFile
)
.
close
()
if
fs
is
not
None
:
fs
.
close
return
ret
class
OpenerRegistry
(
object
):
class
OpenerRegistry
(
object
):
...
@@ -254,24 +263,10 @@ class OpenerRegistry(object):
...
@@ -254,24 +263,10 @@ class OpenerRegistry(object):
writeable
=
'w'
in
mode
or
'a'
in
mode
or
'+'
in
mode
writeable
=
'w'
in
mode
or
'a'
in
mode
or
'+'
in
mode
fs
,
path
=
self
.
parse
(
fs_url
,
writeable
=
writeable
)
fs
,
path
=
self
.
parse
(
fs_url
,
writeable
=
writeable
)
file_object
=
fs
.
open
(
path
,
mode
)
file_object
=
fs
.
open
(
path
,
mode
)
from
fs.filelike
import
FileWrapper
file_object
=
_FSClosingFile
(
file_object
,
mode
)
file_object
=
FileWrapper
(
file_object
,
mode
)
file_object
.
fs
=
fs
return
file_object
# If we just return the file, then fs goes out of scope and closes,
# which may make the file unusable. To get around this, we store a
# reference in the file object to the FS, and patch the file's
# close method to also close the FS.
close
=
file_object
.
close
close_fs
=
fs
def
replace_close
():
ret
=
close
()
close_fs
.
close
()
return
ret
file_object
.
close
=
replace_close
return
file_object
def
getcontents
(
self
,
fs_url
):
def
getcontents
(
self
,
fs_url
):
"""Gets the contents from a given FS url (if it references a file)
"""Gets the contents from a given FS url (if it references a file)
...
...
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