$19 GRAYBYTE WORDPRESS FILE MANAGER $64

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cloudlinux/venv/lib/python3.11/site-packages/tomlkit/

HOME
Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/tomlkit//toml_file.py
import os
import re

from typing import TYPE_CHECKING

from tomlkit.api import loads
from tomlkit.toml_document import TOMLDocument


if TYPE_CHECKING:
    from _typeshed import StrPath as _StrPath
else:
    from typing import Union

    _StrPath = Union[str, os.PathLike]


class TOMLFile:
    """
    Represents a TOML file.

    :param path: path to the TOML file
    """

    def __init__(self, path: _StrPath) -> None:
        self._path = path
        self._linesep = os.linesep

    def read(self) -> TOMLDocument:
        """Read the file content as a :class:`tomlkit.toml_document.TOMLDocument`."""
        with open(self._path, encoding="utf-8", newline="") as f:
            content = f.read()

            # check if consistent line endings
            num_newline = content.count("\n")
            if num_newline > 0:
                num_win_eol = content.count("\r\n")
                if num_win_eol == num_newline:
                    self._linesep = "\r\n"
                elif num_win_eol == 0:
                    self._linesep = "\n"
                else:
                    self._linesep = "mixed"

            return loads(content)

    def write(self, data: TOMLDocument) -> None:
        """Write the TOMLDocument to the file."""
        content = data.as_string()

        # apply linesep
        if self._linesep == "\n":
            content = content.replace("\r\n", "\n")
        elif self._linesep == "\r\n":
            content = re.sub(r"(?<!\r)\n", "\r\n", content)

        with open(self._path, "w", encoding="utf-8", newline="") as f:
            f.write(content)

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
17 Dec 2025 3.08 AM
root / root
0755
__pycache__
--
14 Aug 2025 9.24 PM
root / root
0755
__init__.py
1.121 KB
17 Apr 2025 8.10 PM
root / root
0644
_compat.py
0.501 KB
17 Apr 2025 8.10 PM
root / root
0644
_utils.py
3.927 KB
17 Apr 2025 8.10 PM
root / root
0644
api.py
6.899 KB
17 Apr 2025 8.10 PM
root / root
0644
container.py
27.531 KB
17 Apr 2025 8.10 PM
root / root
0644
exceptions.py
5.358 KB
17 Apr 2025 8.10 PM
root / root
0644
items.py
50.483 KB
17 Apr 2025 8.10 PM
root / root
0644
parser.py
36.952 KB
17 Apr 2025 8.10 PM
root / root
0644
py.typed
0 KB
17 Apr 2025 8.10 PM
root / root
0644
source.py
4.71 KB
17 Apr 2025 8.10 PM
root / root
0644
toml_char.py
1.261 KB
17 Apr 2025 8.10 PM
root / root
0644
toml_document.py
0.107 KB
17 Apr 2025 8.10 PM
root / root
0644
toml_file.py
1.562 KB
17 Apr 2025 8.10 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF