file ¶
Type Aliases:
Classes:
-
SPath–Modified version of pathlib.Path
Attributes:
-
FileDescriptor(TypeAlias) – -
FilePathType(TypeAlias) – -
OpenBinaryMode(TypeAlias) – -
OpenBinaryModeReading(TypeAlias) – -
OpenBinaryModeUpdating(TypeAlias) – -
OpenBinaryModeWriting(TypeAlias) – -
OpenTextMode(TypeAlias) – -
OpenTextModeReading(TypeAlias) – -
OpenTextModeUpdating(TypeAlias) – -
OpenTextModeWriting(TypeAlias) –
FilePathType module-attribute ¶
OpenBinaryMode module-attribute ¶
OpenBinaryMode: TypeAlias = (
OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting
)
OpenBinaryModeReading module-attribute ¶
OpenBinaryModeUpdating module-attribute ¶
OpenBinaryModeUpdating: TypeAlias = 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",
]
OpenBinaryModeWriting module-attribute ¶
OpenTextMode module-attribute ¶
OpenTextMode: TypeAlias = (
OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading
)
OpenTextModeReading module-attribute ¶
OpenTextModeReading: TypeAlias = Literal[
"r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"
]
OpenTextModeUpdating module-attribute ¶
OpenTextModeUpdating: TypeAlias = 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 module-attribute ¶
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
152 153 154 155 156 157 | |
copy_dir ¶
Copy the directory to the specified destination.
Source code in jetpytools/types/file.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
fglob ¶
Glob the path and return the first match.
Source code in jetpytools/types/file.py
201 202 203 204 205 206 207 208 209 210 | |
find_newest_file ¶
Find the most recently modified file matching the given pattern in the directory.
Source code in jetpytools/types/file.py
212 213 214 215 216 217 218 219 220 221 222 | |
format ¶
Format the path with the given arguments.
Source code in jetpytools/types/file.py
104 105 106 107 | |
get_folder ¶
get_folder() -> SPath
Get the folder of the path.
Source code in jetpytools/types/file.py
114 115 116 117 118 119 120 121 122 | |
get_size ¶
get_size() -> int
Get the size of the file or directory in bytes.
Source code in jetpytools/types/file.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
is_empty_dir ¶
is_empty_dir() -> bool
Check if the directory is empty.
Source code in jetpytools/types/file.py
159 160 161 162 | |
is_executable ¶
is_executable() -> bool
Check if the path is executable.
Source code in jetpytools/types/file.py
237 238 239 240 | |
lglob ¶
Glob the path and return the list of paths.
Source code in jetpytools/types/file.py
196 197 198 199 | |
mkdirp ¶
mkdirp(mode: int = 511) -> None
Make the dir path with its parents.
Source code in jetpytools/types/file.py
124 125 126 127 | |
move_dir ¶
Move the directory to the specified destination.
Source code in jetpytools/types/file.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
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
140 141 142 143 | |
rmdirs ¶
Remove the dir path with its contents.
Source code in jetpytools/types/file.py
129 130 131 132 133 134 135 136 137 138 | |
to_str ¶
to_str() -> str
Cast the path to a string.
Source code in jetpytools/types/file.py
109 110 111 112 | |
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
145 146 147 148 149 150 | |