cloudpathlib.AzureBlobPath¶
Bases: CloudPath
Class for representing and operating on Azure Blob Storage URIs, in the style of the Python
standard library's pathlib
module.
Instances represent a path in Blob Storage with filesystem path semantics, and convenient
methods allow for basic operations like joining, reading, writing, iterating over contents,
etc. This class almost entirely mimics the pathlib.Path
interface, so most familiar properties and methods should be available and behave in the
expected way.
The AzureBlobClient
class handles authentication with Azure. If a
client instance is not explicitly specified on AzureBlobPath
instantiation, a default client
is used. See AzureBlobClient
's documentation for more details.
Source code in cloudpathlib/azure/azblobpath.py
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
Attributes¶
anchor: str
property
¶
blob: str
property
¶
client: AzureBlobClient
instance-attribute
¶
cloud_prefix: str = 'az://'
class-attribute
instance-attribute
¶
container: str
property
¶
drive: str
property
¶
etag
property
¶
fspath: str
property
¶
md5: str
property
¶
name: str
property
¶
parent: Self
property
¶
parents: Tuple[Self, ...]
property
¶
parser: Self
property
¶
parts: Tuple[str, ...]
property
¶
stem: str
property
¶
suffix: str
property
¶
suffixes: List[str]
property
¶
Functions¶
__init__(cloud_path: Union[str, Self, CloudPath], *parts: str, client: Optional[Client] = None) -> None
¶
Source code in cloudpathlib/cloudpath.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
absolute() -> Self
¶
Source code in cloudpathlib/cloudpath.py
929 930 |
|
as_uri() -> str
¶
Source code in cloudpathlib/cloudpath.py
445 446 |
|
as_url(presign: bool = False, expire_seconds: int = 60 * 60) -> str
¶
Source code in cloudpathlib/cloudpath.py
427 428 429 430 431 432 |
|
clear_cache()
¶
Removes cache if it exists
Source code in cloudpathlib/cloudpath.py
1442 1443 1444 1445 1446 1447 1448 |
|
copy(target: Union[str, os.PathLike, Self], follow_symlinks: bool = True, preserve_metadata: bool = False, force_overwrite_to_cloud: Optional[bool] = None) -> Union[Path, Self]
¶
copy(
target: Self,
follow_symlinks=True,
preserve_metadata=False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Self
copy(
target: Path,
follow_symlinks=True,
preserve_metadata=False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Path
copy(
target: str,
follow_symlinks=True,
preserve_metadata=False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Union[Path, CloudPath]
Copy self to target folder or file, if self is a file.
Source code in cloudpathlib/cloudpath.py
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 |
|
copy_into(target_dir: Union[str, os.PathLike, Self], follow_symlinks: bool = True, preserve_metadata: bool = False, force_overwrite_to_cloud: Optional[bool] = None) -> Union[Path, Self]
¶
copy_into(
target_dir: Self,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Self
copy_into(
target_dir: Path,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Path
copy_into(
target_dir: str,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Union[Path, CloudPath]
Copy self into target directory, preserving the filename.
Source code in cloudpathlib/cloudpath.py
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 |
|
copytree(destination, force_overwrite_to_cloud=None, ignore=None)
¶
copytree(
destination: Self,
force_overwrite_to_cloud: Optional[bool] = None,
ignore: Optional[
Callable[[str, Iterable[str]], Container[str]]
] = None,
) -> Self
copytree(
destination: Path,
force_overwrite_to_cloud: Optional[bool] = None,
ignore: Optional[
Callable[[str, Iterable[str]], Container[str]]
] = None,
) -> Path
copytree(
destination: Union[str, os.PathLike, Self],
force_overwrite_to_cloud: Optional[bool] = None,
ignore: Optional[
Callable[[str, Iterable[str]], Container[str]]
] = None,
) -> Union[Path, CloudPath]
Copy self to a directory, if self is a directory.
Source code in cloudpathlib/cloudpath.py
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 |
|
download_to(destination: Union[str, os.PathLike]) -> Path
¶
Source code in cloudpathlib/cloudpath.py
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
|
exists(follow_symlinks=True) -> bool
¶
Source code in cloudpathlib/cloudpath.py
448 449 |
|
from_uri(uri: str) -> Self
classmethod
¶
Source code in cloudpathlib/cloudpath.py
461 462 463 |
|
full_match(pattern: str, case_sensitive: Optional[bool] = None) -> bool
¶
Source code in cloudpathlib/cloudpath.py
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 |
|
glob(pattern: Union[str, os.PathLike], case_sensitive: Optional[bool] = None, recurse_symlinks: bool = True) -> Generator[Self, None, None]
¶
Source code in cloudpathlib/cloudpath.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
|
info() -> CloudPathInfo
¶
Return a CloudPathInfo object for this path.
Source code in cloudpathlib/cloudpath.py
1080 1081 1082 |
|
is_absolute() -> bool
¶
Source code in cloudpathlib/cloudpath.py
932 933 |
|
is_dir(follow_symlinks=True) -> bool
¶
Source code in cloudpathlib/cloudpath.py
451 452 |
|
is_file(follow_symlinks=True) -> bool
¶
Source code in cloudpathlib/cloudpath.py
454 455 |
|
is_junction()
¶
Source code in cloudpathlib/cloudpath.py
878 879 |
|
is_relative_to(other: Self) -> bool
¶
Source code in cloudpathlib/cloudpath.py
955 956 957 958 959 960 |
|
is_valid_cloudpath(path: Union[str, CloudPath], raise_on_error: bool = False) -> Union[bool, TypeGuard[Self]]
classmethod
¶
is_valid_cloudpath(
path: CloudPath, raise_on_error: bool = ...
) -> TypeGuard[Self]
is_valid_cloudpath(
path: str, raise_on_error: bool = ...
) -> bool
Source code in cloudpathlib/cloudpath.py
333 334 335 336 337 338 339 340 341 342 343 344 |
|
iterdir() -> Generator[Self, None, None]
¶
Source code in cloudpathlib/cloudpath.py
566 567 568 569 |
|
joinpath(*pathsegments: Union[str, os.PathLike]) -> Self
¶
Source code in cloudpathlib/cloudpath.py
926 927 |
|
match(path_pattern: str, case_sensitive: Optional[bool] = None) -> bool
¶
Source code in cloudpathlib/cloudpath.py
982 983 984 985 986 987 988 989 990 991 992 |
|
mkdir(parents=False, exist_ok=False, mode: Optional[Any] = None)
¶
Source code in cloudpathlib/azure/azblobpath.py
42 43 |
|
move(target: Union[str, os.PathLike, Self], follow_symlinks: bool = True, preserve_metadata: bool = False, force_overwrite_to_cloud: Optional[bool] = None) -> Union[Path, Self]
¶
move(
target: Self,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Self
move(
target: Path,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Path
move(
target: str,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Union[Path, CloudPath]
Move self to target location, removing the source.
Source code in cloudpathlib/cloudpath.py
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
|
move_into(target_dir: Union[str, os.PathLike, Self], follow_symlinks: bool = True, preserve_metadata: bool = False, force_overwrite_to_cloud: Optional[bool] = None) -> Union[Path, Self]
¶
move_into(
target_dir: Self,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Self
move_into(
target_dir: Path,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Path
move_into(
target_dir: str,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Union[Path, CloudPath]
Move self into target directory, preserving the filename and removing the source.
Source code in cloudpathlib/cloudpath.py
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 |
|
open(mode: str = 'r', buffering: int = -1, encoding: Optional[str] = None, errors: Optional[str] = None, newline: Optional[str] = None, force_overwrite_from_cloud: Optional[bool] = None, force_overwrite_to_cloud: Optional[bool] = None) -> IO[Any]
¶
open(
mode: OpenTextMode = "r",
buffering: int = -1,
encoding: Optional[str] = None,
errors: Optional[str] = None,
newline: Optional[str] = None,
force_overwrite_from_cloud: Optional[bool] = None,
force_overwrite_to_cloud: Optional[bool] = None,
) -> TextIOWrapper
open(
mode: OpenBinaryMode,
buffering: Literal[0],
encoding: None = None,
errors: None = None,
newline: None = None,
force_overwrite_from_cloud: Optional[bool] = None,
force_overwrite_to_cloud: Optional[bool] = None,
) -> FileIO
open(
mode: OpenBinaryModeUpdating,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = None,
newline: None = None,
force_overwrite_from_cloud: Optional[bool] = None,
force_overwrite_to_cloud: Optional[bool] = None,
) -> BufferedRandom
open(
mode: OpenBinaryModeWriting,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = None,
newline: None = None,
force_overwrite_from_cloud: Optional[bool] = None,
force_overwrite_to_cloud: Optional[bool] = None,
) -> BufferedWriter
open(
mode: OpenBinaryModeReading,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = None,
newline: None = None,
force_overwrite_from_cloud: Optional[bool] = None,
force_overwrite_to_cloud: Optional[bool] = None,
) -> BufferedReader
open(
mode: OpenBinaryMode,
buffering: int = -1,
encoding: None = None,
errors: None = None,
newline: None = None,
force_overwrite_from_cloud: Optional[bool] = None,
force_overwrite_to_cloud: Optional[bool] = None,
) -> BinaryIO
open(
mode: str,
buffering: int = -1,
encoding: Optional[str] = None,
errors: Optional[str] = None,
newline: Optional[str] = None,
force_overwrite_from_cloud: Optional[bool] = None,
force_overwrite_to_cloud: Optional[bool] = None,
) -> IO[Any]
Source code in cloudpathlib/cloudpath.py
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
|
read_bytes() -> bytes
¶
Source code in cloudpathlib/cloudpath.py
865 866 867 |
|
read_text(encoding: Optional[str] = None, errors: Optional[str] = None, newline: Optional[str] = None) -> str
¶
Source code in cloudpathlib/cloudpath.py
869 870 871 872 873 874 875 876 |
|
relative_to(other: Self, walk_up: bool = False) -> PurePosixPath
¶
Source code in cloudpathlib/cloudpath.py
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 |
|
rename(target: Self) -> Self
¶
Source code in cloudpathlib/cloudpath.py
805 806 807 808 |
|
replace(target: AzureBlobPath) -> AzureBlobPath
¶
Source code in cloudpathlib/azure/azblobpath.py
82 83 84 85 86 87 88 89 90 91 |
|
resolve(strict: bool = False) -> Self
¶
Source code in cloudpathlib/cloudpath.py
935 936 |
|
rglob(pattern: Union[str, os.PathLike], case_sensitive: Optional[bool] = None, recurse_symlinks: bool = True) -> Generator[Self, None, None]
¶
Source code in cloudpathlib/cloudpath.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
|
rmdir() -> None
¶
Source code in cloudpathlib/cloudpath.py
810 811 812 813 814 815 816 817 818 819 820 821 822 |
|
rmtree() -> None
¶
Delete an entire directory tree.
Source code in cloudpathlib/cloudpath.py
1107 1108 1109 1110 1111 1112 1113 |
|
samefile(other_path: Union[str, os.PathLike]) -> bool
¶
Source code in cloudpathlib/cloudpath.py
824 825 826 |
|
stat(follow_symlinks=True)
¶
Source code in cloudpathlib/azure/azblobpath.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
touch(exist_ok: bool = True, mode: Optional[Any] = None)
¶
Source code in cloudpathlib/azure/azblobpath.py
45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
unlink(missing_ok: bool = True) -> None
¶
Source code in cloudpathlib/cloudpath.py
828 829 830 831 832 833 834 |
|
upload_from(source: Union[str, os.PathLike], force_overwrite_to_cloud: Optional[bool] = None) -> Self
¶
Upload a file or directory to the cloud path.
Source code in cloudpathlib/cloudpath.py
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 |
|
validate(v: str) -> Self
classmethod
¶
Used as a Pydantic validator. See https://docs.pydantic.dev/2.0/usage/types/custom/
Source code in cloudpathlib/cloudpath.py
1600 1601 1602 1603 1604 |
|
walk(top_down: bool = True, on_error: Optional[Callable] = None, follow_symlinks: bool = False) -> Generator[Tuple[Self, List[str], List[str]], None, None]
¶
Source code in cloudpathlib/cloudpath.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
|
with_name(name: str) -> Self
¶
Source code in cloudpathlib/cloudpath.py
1036 1037 |
|
with_segments(*pathsegments) -> Self
¶
Create a new CloudPath with the same client out of the given segments. The first segment will be interpreted as the bucket/container name.
Source code in cloudpathlib/cloudpath.py
1039 1040 1041 1042 1043 |
|
with_stem(stem: str) -> Self
¶
Source code in cloudpathlib/cloudpath.py
1029 1030 1031 1032 1033 1034 |
|
with_suffix(suffix: str) -> Self
¶
Source code in cloudpathlib/cloudpath.py
1045 1046 |
|
write_bytes(data: bytes) -> int
¶
Open the file in bytes mode, write to it, and close the file.
NOTE: vendored from pathlib since we override open https://github.com/python/cpython/blob/3.8/Lib/pathlib.py#L1235-L1242
Source code in cloudpathlib/cloudpath.py
836 837 838 839 840 841 842 843 844 845 |
|
write_text(data: str, encoding: Optional[str] = None, errors: Optional[str] = None, newline: Optional[str] = None) -> int
¶
Open the file in text mode, write to it, and close the file.
NOTE: vendored from pathlib since we override open https://github.com/python/cpython/blob/3.10/Lib/pathlib.py#L1146-L1155
Source code in cloudpathlib/cloudpath.py
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
|