diff --git a/.doctrees/api/audeer.doctree b/.doctrees/api/audeer.doctree
index 1a0ab96..70dedca 100644
Binary files a/.doctrees/api/audeer.doctree and b/.doctrees/api/audeer.doctree differ
diff --git a/.doctrees/api/audeer.list_dir_names.doctree b/.doctrees/api/audeer.list_dir_names.doctree
index 552358a..5e09971 100644
Binary files a/.doctrees/api/audeer.list_dir_names.doctree and b/.doctrees/api/audeer.list_dir_names.doctree differ
diff --git a/.doctrees/api/audeer.list_file_names.doctree b/.doctrees/api/audeer.list_file_names.doctree
index 640b545..ffe33b6 100644
Binary files a/.doctrees/api/audeer.list_file_names.doctree and b/.doctrees/api/audeer.list_file_names.doctree differ
diff --git a/.doctrees/api/audeer.mkdir.doctree b/.doctrees/api/audeer.mkdir.doctree
index 497fd16..38797a8 100644
Binary files a/.doctrees/api/audeer.mkdir.doctree and b/.doctrees/api/audeer.mkdir.doctree differ
diff --git a/.doctrees/api/audeer.move.doctree b/.doctrees/api/audeer.move.doctree
new file mode 100644
index 0000000..56b701f
Binary files /dev/null and b/.doctrees/api/audeer.move.doctree differ
diff --git a/.doctrees/api/audeer.move_file.doctree b/.doctrees/api/audeer.move_file.doctree
index dba2f7c..1cb7f6b 100644
Binary files a/.doctrees/api/audeer.move_file.doctree and b/.doctrees/api/audeer.move_file.doctree differ
diff --git a/.doctrees/api/audeer.rmdir.doctree b/.doctrees/api/audeer.rmdir.doctree
index a321032..6947843 100644
Binary files a/.doctrees/api/audeer.rmdir.doctree and b/.doctrees/api/audeer.rmdir.doctree differ
diff --git a/.doctrees/api/audeer.touch.doctree b/.doctrees/api/audeer.touch.doctree
index 41514b3..8cb3bc9 100644
Binary files a/.doctrees/api/audeer.touch.doctree and b/.doctrees/api/audeer.touch.doctree differ
diff --git a/.doctrees/changelog.doctree b/.doctrees/changelog.doctree
index f51b34c..686c972 100644
Binary files a/.doctrees/changelog.doctree and b/.doctrees/changelog.doctree differ
diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle
index 3badcc5..736a3b3 100644
Binary files a/.doctrees/environment.pickle and b/.doctrees/environment.pickle differ
diff --git a/_modules/audeer/core/config.html b/_modules/audeer/core/config.html
index 516068c..1d4dda8 100644
--- a/_modules/audeer/core/config.html
+++ b/_modules/audeer/core/config.html
@@ -63,7 +63,7 @@
FileNotFoundError: if path does not exists
Examples:
- >>> _ = mkdir('path/a/.b/c')
+ >>> _ = mkdir('path', 'a', '.b', 'c')
>>> list_dir_names(
... 'path',
... basenames=True,
@@ -716,12 +716,12 @@ Source code for audeer.core.io
Examples:
>>> dir_path = mkdir('path')
- >>> _ = touch(os.path.join(dir_path, 'file.wav'))
- >>> _ = touch(os.path.join(dir_path, 'File.wav'))
- >>> _ = touch(os.path.join(dir_path, '.lock'))
- >>> sub_dir_path = mkdir(os.path.join('path', 'sub'))
- >>> _ = touch(os.path.join(sub_dir_path, 'file.ogg'))
- >>> _ = touch(os.path.join(sub_dir_path, '.lock'))
+ >>> _ = touch(dir_path, 'file.wav')
+ >>> _ = touch(dir_path, 'File.wav')
+ >>> _ = touch(dir_path, '.lock')
+ >>> sub_dir_path = mkdir('path', 'sub')
+ >>> _ = touch(sub_dir_path, 'file.ogg')
+ >>> _ = touch(sub_dir_path, '.lock')
>>> list_file_names(
... dir_path,
... basenames=True,
@@ -854,7 +854,7 @@ Source code for audeer.core.io
[docs]def mkdir(
path: typing.Union[str, bytes],
-
*,
+
*paths: typing.Sequence[typing.Union[str, bytes]],
mode: int = 0o777
) -> str:
"""Create directory.
@@ -878,18 +878,21 @@
Source code for audeer.core.io
Args:
path: absolute or relative path of directory to create
+ *paths: additional arguments
+ to be joined with ``path``
+ by :func:`os.path.join`
mode: set permissions of created folders
Returns:
absolute path to the created directory
Examples:
- >>> p = mkdir('path1/path2/path3')
+ >>> p = mkdir('path1', 'path2', 'path3')
>>> os.path.basename(p)
'path3'
"""
- path = safe_path(path)
+ path = safe_path(path, *paths)
if path:
os.makedirs(path, mode=mode, exist_ok=True)
return path
@@ -979,6 +982,48 @@
Source code for audeer.core.io
yield data
+[docs]def move(
+
src_path,
+
dst_path,
+
):
+
"""Move a file or folder independent of operating system.
+
+
As :func:`os.rename` works differently
+
under Unix and Windows
+
and :func:`shutil.move` can be slow,
+
we use :func:`os.replace`
+
to move the file/folder.
+
+
Args:
+
src_path: source file/folder path
+
dst_path: destination file/folder path
+
+
Raises:
+
OSError: if ``src_path`` is a file
+
and ``dst_path`` is an existing folder
+
OSError: if ``src_path`` is a folder
+
and ``dst_path`` is an existing file
+
(not raised under Windows)
+
OSError: if ``dst_path`` is a non-empty folder,
+
different from ``src_path``,
+
and ``src_path`` is also a folder
+
OSError: if ``dst_path`` is an empty folder,
+
different from ``src_path``
+
and ``src_path`` is also a folder
+
(raised only under Windows)
+
+
Examples:
+
>>> path = mkdir('folder')
+
>>> src_path = touch(path, 'file1')
+
>>> dst_path = os.path.join(path, 'file2')
+
>>> move(src_path, dst_path)
+
>>> list_file_names(path, basenames=True)
+
['file2']
+
+
"""
+
os.replace(src_path, dst_path)
+
+
[docs]def move_file(
src_path,
dst_path,
@@ -991,20 +1036,24 @@
Source code for audeer.core.io
we use :func:`os.replace`
to move the file.
+ Warning:
+ :func:`audeer.move_file` is deprecated,
+ please use :func:`audeer.move` instead.
+
Args:
src_path: source file path
dst_path: destination file path
Examples:
>>> path = mkdir('folder')
- >>> src_path = touch(os.path.join(path, 'file1'))
+ >>> src_path = touch(path, 'file1')
>>> dst_path = os.path.join(path, 'file2')
>>> move_file(src_path, dst_path)
>>> list_file_names(path, basenames=True)
['file2']
"""
- os.replace(src_path, dst_path)
+
move(src_path, dst_path)
[docs]def replace_file_extension(
@@ -1074,6 +1123,7 @@
Source code for audeer.core.io
[docs]def rmdir(
path: typing.Union[str, bytes],
+
*paths: typing.Sequence[typing.Union[str, bytes]],
):
"""Remove directory.
@@ -1083,26 +1133,30 @@
Source code for audeer.core.io
Args:
path: absolute or relative path of directory to remove
+ *paths: additional arguments
+ to be joined with ``path``
+ by :func:`os.path.join`
Raises:
NotADirectoryError: if path is not a directory
Examples:
- >>> _ = mkdir('path1/path2/path3')
+ >>> _ = mkdir('path1', 'path2', 'path3')
>>> list_dir_names('path1', basenames=True)
['path2']
- >>> rmdir('path1/path2')
+ >>> rmdir('path1', 'path2')
>>> list_dir_names('path1')
[]
"""
- path = safe_path(path)
+ path = safe_path(path, *paths)
if os.path.exists(path):
shutil.rmtree(path)
[docs]def touch(
-
path: typing.Union[str, bytes]
+
path: typing.Union[str, bytes],
+
*paths: typing.Sequence[typing.Union[str, bytes]],
) -> str:
"""Create an empty file.
@@ -1112,6 +1166,9 @@
Source code for audeer.core.io
Args:
path: path to file
+ *paths: additional arguments
+ to be joined with ``path``
+ by :func:`os.path.join`
Returns:
expanded path to file
@@ -1122,7 +1179,7 @@ Source code for audeer.core.io
'file.txt'
"""
- path = safe_path(path)
+ path = safe_path(path, *paths)
if os.path.exists(path):
os.utime(path, None)
else:
@@ -1143,7 +1200,7 @@ Source code for audeer.core.io
diff --git a/_modules/audeer/core/path.html b/_modules/audeer/core/path.html
index d6bc4ca..463427f 100644
--- a/_modules/audeer/core/path.html
+++ b/_modules/audeer/core/path.html
@@ -63,7 +63,7 @@
- v1.20.2
+ v1.21.0
@@ -253,7 +253,7 @@ Source code for audeer.core.path
diff --git a/_modules/audeer/core/tqdm.html b/_modules/audeer/core/tqdm.html
index 6498041..92e39dc 100644
--- a/_modules/audeer/core/tqdm.html
+++ b/_modules/audeer/core/tqdm.html
@@ -63,7 +63,7 @@
- v1.20.2
+ v1.21.0
@@ -254,7 +254,7 @@ Source code for audeer.core.tqdm
diff --git a/_modules/audeer/core/utils.html b/_modules/audeer/core/utils.html
index b04786d..c64b1ce 100644
--- a/_modules/audeer/core/utils.html
+++ b/_modules/audeer/core/utils.html
@@ -63,7 +63,7 @@
- v1.20.2
+ v1.21.0
@@ -976,7 +976,7 @@ Source code for audeer.core.utils
diff --git a/_modules/audeer/core/version.html b/_modules/audeer/core/version.html
index 1cd99f9..029d07c 100644
--- a/_modules/audeer/core/version.html
+++ b/_modules/audeer/core/version.html
@@ -63,7 +63,7 @@
- v1.20.2
+ v1.21.0
@@ -525,7 +525,7 @@ Source code for audeer.core.version
diff --git a/_modules/index.html b/_modules/index.html
index 2415726..948a372 100644
--- a/_modules/index.html
+++ b/_modules/index.html
@@ -63,7 +63,7 @@
- v1.20.2
+ v1.21.0
@@ -158,7 +158,7 @@ All modules for which code is available
- Built with Sphinx on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/_sources/api/audeer.move.rst.txt b/_sources/api/audeer.move.rst.txt
new file mode 100644
index 0000000..a2b1456
--- /dev/null
+++ b/_sources/api/audeer.move.rst.txt
@@ -0,0 +1,6 @@
+move\(\)
+========
+
+.. currentmodule:: audeer
+
+.. autofunction:: audeer.move
\ No newline at end of file
diff --git a/_sources/api/audeer.rst.txt b/_sources/api/audeer.rst.txt
index f6e4611..6171999 100644
--- a/_sources/api/audeer.rst.txt
+++ b/_sources/api/audeer.rst.txt
@@ -31,6 +31,7 @@ audeer
LooseVersion
md5
mkdir
+ move
move_file
path
progress_bar
diff --git a/api/audeer.LooseVersion.html b/api/audeer.LooseVersion.html
index 42e8726..d8f3868 100644
--- a/api/audeer.LooseVersion.html
+++ b/api/audeer.LooseVersion.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -133,6 +133,7 @@
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -364,7 +365,7 @@
version_re on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.StrictVersion.html b/api/audeer.StrictVersion.html
index a33360d..553b97d 100644
--- a/api/audeer.StrictVersion.html
+++ b/api/audeer.StrictVersion.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -391,7 +392,7 @@
version_re on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.basename_wo_ext.html b/api/audeer.basename_wo_ext.html
index bd2e6fb..72ed751 100644
--- a/api/audeer.basename_wo_ext.html
+++ b/api/audeer.basename_wo_ext.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -231,7 +232,7 @@
basename_wo_ext() on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.common_directory.html b/api/audeer.common_directory.html
index b209478..7749a88 100644
--- a/api/audeer.common_directory.html
+++ b/api/audeer.common_directory.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -235,7 +236,7 @@
common_directory() on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.config.html b/api/audeer.config.html
index f2f03ef..1f59a9c 100644
--- a/api/audeer.config.html
+++ b/api/audeer.config.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -134,6 +134,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -329,7 +330,7 @@
TQDM_LEAVE on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.create_archive.html b/api/audeer.create_archive.html
index b25633c..b57e59a 100644
--- a/api/audeer.create_archive.html
+++ b/api/audeer.create_archive.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -257,7 +258,7 @@
create_archive() on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.deprecated.html b/api/audeer.deprecated.html
index fd9892e..c56e55d 100644
--- a/api/audeer.deprecated.html
+++ b/api/audeer.deprecated.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -237,7 +238,7 @@
deprecated() on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.deprecated_default_value.html b/api/audeer.deprecated_default_value.html
index 7977205..821bd3e 100644
--- a/api/audeer.deprecated_default_value.html
+++ b/api/audeer.deprecated_default_value.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -238,7 +239,7 @@
deprecated_default_value() on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.deprecated_keyword_argument.html b/api/audeer.deprecated_keyword_argument.html
index 556a926..69f0108 100644
--- a/api/audeer.deprecated_keyword_argument.html
+++ b/api/audeer.deprecated_keyword_argument.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -245,7 +246,7 @@
deprecated_keyword_argument() on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.download_url.html b/api/audeer.download_url.html
index fd67553..f3de4ab 100644
--- a/api/audeer.download_url.html
+++ b/api/audeer.download_url.html
@@ -65,7 +65,7 @@
- v1.20.2
+ v1.21.0
@@ -121,6 +121,7 @@
LooseVersion
md5()
mkdir()
+
move()
move_file()
path()
progress_bar()
@@ -234,7 +235,7 @@
download_url() on 2023/11/28 using the audEERING theme
+ Built with Sphinx on 2023/12/06 using the audEERING theme
diff --git a/api/audeer.extract_archive.html b/api/audeer.extract_archive.html
index 7517066..33b61d7 100644
--- a/api/audeer.extract_archive.html
+++ b/api/audeer.extract_archive.html
@@ -65,7 +65,7 @@