file ¶
Type Aliases:
-
FileDescriptor– -
FilePathType– -
OpenBinaryMode– -
OpenBinaryModeReading– -
OpenBinaryModeUpdating– -
OpenBinaryModeWriting– -
OpenTextMode– -
OpenTextModeReading– -
OpenTextModeUpdating– -
OpenTextModeWriting– -
SPathLike–
Classes:
-
SPath–Modified version of pathlib.Path
OpenBinaryMode ¶
OpenBinaryMode = (
OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting
)
OpenBinaryModeReading ¶
OpenBinaryModeReading = Literal[
"rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"
]
OpenBinaryModeUpdating ¶
OpenBinaryModeUpdating = Literal[
"rb+",
"r+b",
"+rb",
"br+",
"b+r",
"+br",
"wb+",
"w+b",
"+wb",
"bw+",
"b+w",
"+bw",
"ab+",
"a+b",
"+ab",
"ba+",
"b+a",
"+ba",
"xb+",
"x+b",
"+xb",
"bx+",
"b+x",
"+bx",
]
OpenTextModeReading ¶
OpenTextModeReading = Literal[
"r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"
]
OpenTextModeUpdating ¶
OpenTextModeUpdating = Literal[
"r+",
"+r",
"rt+",
"r+t",
"+rt",
"tr+",
"t+r",
"+tr",
"w+",
"+w",
"wt+",
"w+t",
"+wt",
"tw+",
"t+w",
"+tw",
"a+",
"+a",
"at+",
"a+t",
"+at",
"ta+",
"t+a",
"+ta",
"x+",
"+x",
"xt+",
"x+t",
"+xt",
"tx+",
"t+x",
"+tx",
]
OpenTextModeWriting ¶
OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
SPath ¶
Bases: Path
Modified version of pathlib.Path
Methods:
-
append_to_stem–Append a suffix to the stem of the path
-
copy_dir–Copy the directory to the specified destination.
-
fglob–Glob the path and return the first match.
-
find_newest_file–Find the most recently modified file matching the given pattern in the directory.
-
format–Format the path with the given arguments.
-
get_folder–Get the folder of the path.
-
get_size–Get the size of the file or directory in bytes.
-
is_empty_dir–Check if the directory is empty.
-
is_executable–Check if the path is executable.
-
lglob–Glob the path and return the list of paths.
-
mkdirp–Make the dir path with its parents.
-
move_dir–Move the directory to the specified destination.
-
read_lines–Read the file and return its lines.
-
rmdirs–Remove the dir path with its contents.
-
to_str–Cast the path to a string.
-
write_lines–Open the file and write the given lines.
append_to_stem ¶
Append a suffix to the stem of the path
Source code in jetpytools/types/file.py
153 154 155 156 157 158 | |
copy_dir ¶
Copy the directory to the specified destination.
Source code in jetpytools/types/file.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
fglob ¶
Glob the path and return the first match.
Source code in jetpytools/types/file.py
205 206 207 208 209 210 211 212 213 214 | |
find_newest_file ¶
find_newest_file(
pattern: str = "*",
*,
case_sensitive: bool | None = None,
recurse_symlinks: bool = False,
) -> SPath | None
Find the most recently modified file matching the given pattern in the directory.
Source code in jetpytools/types/file.py
216 217 218 219 220 221 222 223 224 225 | |
format ¶
Format the path with the given arguments.
Source code in jetpytools/types/file.py
105 106 107 108 | |
get_folder ¶
get_folder() -> SPath
Get the folder of the path.
Source code in jetpytools/types/file.py
115 116 117 118 119 120 121 122 123 | |
get_size ¶
get_size() -> int
Get the size of the file or directory in bytes.
Source code in jetpytools/types/file.py
227 228 229 230 231 232 233 234 235 236 237 238 | |
is_empty_dir ¶
is_empty_dir() -> bool
Check if the directory is empty.
Source code in jetpytools/types/file.py
160 161 162 163 | |
is_executable ¶
is_executable() -> bool
Check if the path is executable.
Source code in jetpytools/types/file.py
240 241 242 243 | |
lglob ¶
Glob the path and return the list of paths.
Source code in jetpytools/types/file.py
200 201 202 203 | |
mkdirp ¶
mkdirp(mode: int = 511) -> None
Make the dir path with its parents.
Source code in jetpytools/types/file.py
125 126 127 128 | |
move_dir ¶
Move the directory to the specified destination.
Source code in jetpytools/types/file.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
read_lines ¶
read_lines(
encoding: str | None = None,
errors: str | None = None,
keepends: bool = False,
) -> list[str]
Read the file and return its lines.
Source code in jetpytools/types/file.py
141 142 143 144 | |
rmdirs ¶
Remove the dir path with its contents.
Source code in jetpytools/types/file.py
130 131 132 133 134 135 136 137 138 139 | |
to_str ¶
to_str() -> str
Cast the path to a string.
Source code in jetpytools/types/file.py
110 111 112 113 | |
write_lines ¶
write_lines(
data: Iterable[str],
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> int
Open the file and write the given lines.
Source code in jetpytools/types/file.py
146 147 148 149 150 151 | |