File: fileutils.rst

package info (click to toggle)
python-boltons 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,236 kB
  • sloc: python: 12,133; makefile: 159; sh: 7
file content (59 lines) | stat: -rw-r--r-- 1,677 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
``fileutils`` - Filesystem helpers
==================================

.. automodule:: boltons.fileutils

Creating, Finding, and Copying
------------------------------

Python's :mod:`os`, :mod:`os.path`, and :mod:`shutil` modules provide
good coverage of file wrangling fundamentals, and these functions help
close a few remaining gaps.

.. autofunction:: boltons.fileutils.mkdir_p

.. autofunction:: boltons.fileutils.iter_find_files

.. autofunction:: boltons.fileutils.copytree

.. autofunction:: boltons.fileutils.rotate_file


Atomic File Saving
------------------

Ideally, the road to success should never put current progress at
risk. And that's exactly why :func:`atomic_save` and
:class:`AtomicSaver` exist.

Using the same API as a writable file, all output is saved to a
temporary file, and when the file is closed, the old file is replaced
by the new file in a single system call, portable across all major
operating systems. No more partially-written or partially-overwritten
files.

.. autofunction:: boltons.fileutils.atomic_save

.. autoclass:: boltons.fileutils.AtomicSaver

.. autofunction:: boltons.fileutils.atomic_rename

.. autofunction:: boltons.fileutils.replace

File Permissions
----------------

Linux, BSD, Mac OS, and other Unix-like operating systems all share a
simple, foundational file permission structure that is commonly
complicit in accidental access denial, as well as file
leakage. :class:`FilePerms` was built to increase clarity and cut down
on permission-related accidents when working with files from Python
code.

.. autoclass:: boltons.fileutils.FilePerms


Miscellaneous
-------------

.. autoclass:: boltons.fileutils.DummyFile