$71 GRAYBYTE WORDPRESS FILE MANAGER $89

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.217.149
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
..
--
9 Apr 2026 8.31 AM
root / root
0755
__pycache__
--
11 Feb 2026 9.30 AM
root / root
0755
__init__.py
1.121 KB
20 Jan 2026 1.01 PM
root / root
0644
_compat.py
0.501 KB
20 Jan 2026 1.01 PM
root / root
0644
_utils.py
3.927 KB
20 Jan 2026 1.01 PM
root / root
0644
api.py
6.899 KB
20 Jan 2026 1.01 PM
root / root
0644
container.py
27.531 KB
20 Jan 2026 1.01 PM
root / root
0644
exceptions.py
5.358 KB
20 Jan 2026 1.01 PM
root / root
0644
items.py
50.483 KB
20 Jan 2026 1.01 PM
root / root
0644
parser.py
36.952 KB
20 Jan 2026 1.01 PM
root / root
0644
py.typed
0 KB
20 Jan 2026 1.01 PM
root / root
0644
source.py
4.71 KB
20 Jan 2026 1.01 PM
root / root
0644
toml_char.py
1.261 KB
20 Jan 2026 1.01 PM
root / root
0644
toml_document.py
0.107 KB
20 Jan 2026 1.01 PM
root / root
0644
toml_file.py
1.562 KB
20 Jan 2026 1.01 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF