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
7b9bbbb4
Commit
7b9bbbb4
authored
Jan 05, 2012
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for console colours
parent
e9042dcd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
25 deletions
+10
-25
fs/utils.py
+10
-25
No files found.
fs/utils.py
View file @
7b9bbbb4
...
...
@@ -12,18 +12,18 @@ __all__ = ['copyfile',
'isfile'
,
'isdir'
,
'find_duplicates'
,
'print_fs'
]
'print_fs'
,
'wrap_file'
]
import
os
import
sys
import
stat
from
fs.mountfs
import
MountFS
from
fs.path
import
pathjoin
from
fs.errors
import
DestinationExistsError
from
fs.base
import
FS
def
copyfile
(
src_fs
,
src_path
,
dst_fs
,
dst_path
,
overwrite
=
True
,
chunk_size
=
64
*
1024
):
"""Copy a file from one filesystem to another. Will use system copyfile, if both files have a syspath.
Otherwise file will be copied a chunk at a time.
...
...
@@ -446,7 +446,7 @@ def print_fs(fs, path='/', max_levels=5, file_out=None, terminal_colors=None, hi
if
sys
.
platform
.
startswith
(
'win'
):
terminal_colors
=
False
else
:
terminal_colors
=
True
terminal_colors
=
hasattr
(
file_out
,
'isatty'
)
and
file_out
.
isatty
()
def
write
(
line
):
file_out
.
write
(
line
.
encode
(
file_encoding
,
'replace'
)
+
'
\n
'
)
...
...
@@ -518,27 +518,12 @@ def print_fs(fs, path='/', max_levels=5, file_out=None, terminal_colors=None, hi
print_dir
(
fs
,
path
)
if
__name__
==
"__main__"
:
#from osfs import *
#fs = OSFS('~/copytest')
#from memoryfs import *
#m = MemoryFS()
#m.makedir('maps')
#copydir((fs, 'maps'), (m, 'maps'))
#from browsewin import browse
#browse(m)
from
osfs
import
*
#f = OSFS('/home/will/projects')
f
=
OSFS
(
'/home/will/tests'
)
from
fs.memoryfs
import
MemoryFS
mem
=
MemoryFS
()
from
fs.utils
import
copydir
copydir
(
f
,
mem
)
print_fs
(
mem
)
m
=
MemoryFS
()
m
.
setcontents
(
"test"
,
"Hello, World!"
*
10000
)
f
=
m
.
open
(
"test"
)
print
f
tf
=
wrap_file
(
f
,
"r"
)
print
repr
(
tf
.
read
(
10
))
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