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: Sequence[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], client: Optional[Client] = None) -> None
¶
Source code in cloudpathlib/cloudpath.py
236 237 238 239 240 241 242 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 |
|
absolute() -> Self
¶
Source code in cloudpathlib/cloudpath.py
898 899 |
|
as_uri() -> str
¶
Source code in cloudpathlib/cloudpath.py
427 428 |
|
as_url(presign: bool = False, expire_seconds: int = 60 * 60) -> str
¶
Source code in cloudpathlib/cloudpath.py
409 410 411 412 413 414 |
|
clear_cache()
¶
Removes cache if it exists
Source code in cloudpathlib/cloudpath.py
1234 1235 1236 1237 1238 1239 1240 |
|
copy(destination, force_overwrite_to_cloud=None)
¶
copy(
destination: Self,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Self
copy(
destination: Path,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Path
copy(
destination: str,
force_overwrite_to_cloud: Optional[bool] = None,
) -> Union[Path, CloudPath]
Copy self to destination folder of file, if self is a file.
Source code in cloudpathlib/cloudpath.py
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 |
|
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: str,
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
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 |
|
download_to(destination: Union[str, os.PathLike]) -> Path
¶
Source code in cloudpathlib/cloudpath.py
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 |
|
exists() -> bool
¶
Source code in cloudpathlib/cloudpath.py
430 431 |
|
from_uri(uri: str) -> Self
classmethod
¶
Source code in cloudpathlib/cloudpath.py
443 444 445 |
|
full_match(pattern: str, case_sensitive: Optional[bool] = None) -> bool
¶
Source code in cloudpathlib/cloudpath.py
935 936 937 938 939 940 941 942 943 944 945 946 |
|
glob(pattern: Union[str, os.PathLike], case_sensitive: Optional[bool] = None) -> Generator[Self, None, None]
¶
Source code in cloudpathlib/cloudpath.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
|
is_absolute() -> bool
¶
Source code in cloudpathlib/cloudpath.py
901 902 |
|
is_dir(follow_symlinks=True) -> bool
¶
Source code in cloudpathlib/cloudpath.py
433 434 |
|
is_file(follow_symlinks=True) -> bool
¶
Source code in cloudpathlib/cloudpath.py
436 437 |
|
is_junction()
¶
Source code in cloudpathlib/cloudpath.py
847 848 |
|
is_relative_to(other: Self) -> bool
¶
Source code in cloudpathlib/cloudpath.py
924 925 926 927 928 929 |
|
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
318 319 320 321 322 323 324 325 326 327 328 329 |
|
iterdir() -> Generator[Self, None, None]
¶
Source code in cloudpathlib/cloudpath.py
542 543 544 545 |
|
joinpath(*pathsegments: Union[str, os.PathLike]) -> Self
¶
Source code in cloudpathlib/cloudpath.py
895 896 |
|
match(path_pattern: str, case_sensitive: Optional[bool] = None) -> bool
¶
Source code in cloudpathlib/cloudpath.py
948 949 950 951 952 953 954 955 956 957 958 |
|
mkdir(parents=False, exist_ok=False)
¶
Source code in cloudpathlib/azure/azblobpath.py
42 43 |
|
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
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 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 |
|
read_bytes() -> bytes
¶
Source code in cloudpathlib/cloudpath.py
834 835 836 |
|
read_text(encoding: Optional[str] = None, errors: Optional[str] = None, newline: Optional[str] = None) -> str
¶
Source code in cloudpathlib/cloudpath.py
838 839 840 841 842 843 844 845 |
|
relative_to(other: Self, walk_up: bool = False) -> PurePosixPath
¶
Source code in cloudpathlib/cloudpath.py
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
|
rename(target: Self) -> Self
¶
Source code in cloudpathlib/cloudpath.py
774 775 776 777 |
|
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
904 905 |
|
rglob(pattern: Union[str, os.PathLike], case_sensitive: Optional[bool] = None) -> Generator[Self, None, None]
¶
Source code in cloudpathlib/cloudpath.py
530 531 532 533 534 535 536 537 538 539 540 |
|
rmdir() -> None
¶
Source code in cloudpathlib/cloudpath.py
779 780 781 782 783 784 785 786 787 788 789 790 791 |
|
rmtree() -> None
¶
Delete an entire directory tree.
Source code in cloudpathlib/cloudpath.py
1069 1070 1071 1072 1073 1074 1075 |
|
samefile(other_path: Union[str, os.PathLike]) -> bool
¶
Source code in cloudpathlib/cloudpath.py
793 794 795 |
|
stat()
¶
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)
¶
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
797 798 799 800 801 802 803 |
|
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
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
|
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
1392 1393 1394 1395 1396 |
|
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
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
|
with_name(name: str) -> Self
¶
Source code in cloudpathlib/cloudpath.py
1002 1003 |
|
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
1005 1006 1007 1008 1009 |
|
with_stem(stem: str) -> Self
¶
Source code in cloudpathlib/cloudpath.py
995 996 997 998 999 1000 |
|
with_suffix(suffix: str) -> Self
¶
Source code in cloudpathlib/cloudpath.py
1011 1012 |
|
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
805 806 807 808 809 810 811 812 813 814 |
|
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
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
|