mirror of https://github.com/flaggo/pydu.git
adjust file doc
This commit is contained in:
parent
d3cb89ceec
commit
a3fab64caa
|
@ -3,10 +3,10 @@ File
|
||||||
|
|
||||||
.. py:function:: pydu.file.makedirs(path, mode=0o755, ignore_errors=False, exist_ok=False)
|
.. py:function:: pydu.file.makedirs(path, mode=0o755, ignore_errors=False, exist_ok=False)
|
||||||
|
|
||||||
Based on `os.makedirs`,create a leaf directory and all intermediate ones.
|
Based on ``os.makedirs``,create a leaf directory and all intermediate ones.
|
||||||
`mode` default is `0o755`.When make an exists path,if exist_ok is false,
|
``mode`` default is ``0o755``. When make an exists path, if exist_ok is false,
|
||||||
`makedirs` will raise an `Exception`.If `ignore_errors` which will ignore
|
``makedirs`` will raise an ``Exception``. If ``ignore_errors`` which will ignore
|
||||||
all errors raised by `os.makedirs`.
|
all errors raised by ``os.makedirs``.
|
||||||
|
|
||||||
>>> from pydu.file import makedirs
|
>>> from pydu.file import makedirs
|
||||||
>>> makedirs('test1/test2')
|
>>> makedirs('test1/test2')
|
||||||
|
@ -17,13 +17,14 @@ File
|
||||||
|
|
||||||
|
|
||||||
.. py:function:: pydu.file.remove(path, mode=0o755, ignore_errors=False, onerror)
|
.. py:function:: pydu.file.remove(path, mode=0o755, ignore_errors=False, onerror)
|
||||||
|
|
||||||
Remove a file or directory.
|
Remove a file or directory.
|
||||||
|
|
||||||
If ignore_errors is set, errors are ignored; otherwise, if onerror
|
If ``ignore_errors`` is set, errors are ignored; otherwise, if onerror
|
||||||
is set, it is called to handle the error with arguments (func,
|
is set, it is called to handle the error with arguments (func,
|
||||||
path, exc_info) where func is platform and implementation dependent;
|
path, exc_info) where func is platform and implementation dependent;
|
||||||
path is the argument to that function that caused it to fail; and
|
path is the argument to that function that caused it to fail; and
|
||||||
exc_info is a tuple returned by sys.exc_info(). If ignore_errors
|
exc_info is a tuple returned by sys.exc_info(). If ``ignore_errors``
|
||||||
is False and onerror is None, an exception is raised.
|
is False and onerror is None, an exception is raised.
|
||||||
|
|
||||||
>>> from pydu.file import makedirs
|
>>> from pydu.file import makedirs
|
||||||
|
@ -40,7 +41,7 @@ File
|
||||||
|
|
||||||
.. py:function:: pydu.file.removes(paths, mode=0o755, ignore_errors=False, onerror)
|
.. py:function:: pydu.file.removes(paths, mode=0o755, ignore_errors=False, onerror)
|
||||||
|
|
||||||
Remove a list of file and/or directory.Other parameters same as `remove`
|
Remove a list of file and/or directory.Other parameters same as `remove`.
|
||||||
|
|
||||||
>>> from pydu.file import makedirs
|
>>> from pydu.file import makedirs
|
||||||
>>> from pydu.file import remove
|
>>> from pydu.file import remove
|
||||||
|
@ -52,8 +53,8 @@ File
|
||||||
|
|
||||||
.. py:function:: pydu.file.open_file(path, mode='wb+', buffer_size=-1, ignore_errors=False):
|
.. py:function:: pydu.file.open_file(path, mode='wb+', buffer_size=-1, ignore_errors=False):
|
||||||
|
|
||||||
Open a file, defualt mode 'wb+'.If path not exists, it will be created
|
Open a file, defualt mode ``wb+``. If path not exists, it will be created
|
||||||
automatically. If ignore_errors is set, errors are ignored.
|
automatically. If ``ignore_errors`` is set, errors are ignored.
|
||||||
|
|
||||||
>>> from pydu.file import open_file
|
>>> from pydu.file import open_file
|
||||||
>>> open_file('test.txt')
|
>>> open_file('test.txt')
|
||||||
|
@ -79,20 +80,8 @@ File
|
||||||
>>> from pydu.file import makedirs,open_fle
|
>>> from pydu.file import makedirs,open_fle
|
||||||
>>> open_fle('test/test.txt')
|
>>> open_fle('test/test.txt')
|
||||||
>>> symlink('test/test.txt','test/test.link')
|
>>> symlink('test/test.txt','test/test.link')
|
||||||
>>> ll test
|
|
||||||
test.txt
|
|
||||||
test.link -> test.txt
|
|
||||||
>>> copy('test/test.link','test/test_copy1.link')
|
>>> copy('test/test.link','test/test_copy1.link')
|
||||||
>>> ll test
|
|
||||||
test.txt
|
|
||||||
test_copy1.link
|
|
||||||
test.link -> test.txt
|
|
||||||
>>> copy('test/test.link','test/test_copy2.link',follow_symlink=False)
|
>>> copy('test/test.link','test/test_copy2.link',follow_symlink=False)
|
||||||
>>> ll test
|
|
||||||
test.txt
|
|
||||||
test_copy1.link
|
|
||||||
test.link -> test.txt
|
|
||||||
test_copy2.link -> test.txt
|
|
||||||
|
|
||||||
.. py:function:: pydu.file.touch(path):
|
.. py:function:: pydu.file.touch(path):
|
||||||
|
|
||||||
|
@ -103,7 +92,7 @@ File
|
||||||
|
|
||||||
.. py:function:: pydu.file.symlink(src, dst, overwrite=False, ignore_errors=False)
|
.. py:function:: pydu.file.symlink(src, dst, overwrite=False, ignore_errors=False)
|
||||||
|
|
||||||
`symlink` only work on `Linux/Unix`,it create a symbolic link pointing
|
``symlink`` only work on `Unix-like` system, it create a symbolic link pointing
|
||||||
to source named link_name.If dist is exist and overwrite is true,a new
|
to source named link_name.If dist is exist and overwrite is true,a new
|
||||||
symlink will be created.
|
symlink will be created.
|
||||||
|
|
||||||
|
@ -112,7 +101,7 @@ File
|
||||||
|
|
||||||
.. py:function:: pydu.file.link(src, dst, overwrite=False, ignore_errors=False):
|
.. py:function:: pydu.file.link(src, dst, overwrite=False, ignore_errors=False):
|
||||||
|
|
||||||
`link` only work on `Linux/Unix`,it create a hard link pointing to
|
``link`` only work on `Unix-like` system, it create a hard link pointing to
|
||||||
source named link_name.If dist is exist and overwrite is true,a
|
source named link_name.If dist is exist and overwrite is true,a
|
||||||
new symlink will be created.
|
new symlink will be created.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue