Skip to content

Commit 1fd57f4

Browse files
[Datalake] Added support for PurePosixPath (#16400)
* Added support for PurePosixPath * removed posix lib from imports * removed posix lib from imports * added type annotations * cleaned up changes
1 parent f0fbe66 commit 1fd57f4

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ._deserialize import deserialize_dir_properties
1212
from ._shared.base_client import TransportWrapper, parse_connection_str
1313
from ._data_lake_file_client import DataLakeFileClient
14-
from ._models import DirectoryProperties
14+
from ._models import DirectoryProperties, FileProperties
1515
from ._path_client import PathClient
1616

1717

@@ -502,12 +502,12 @@ def get_file_client(self, file # type: Union[FileProperties, str]
502502
or an instance of FileProperties. eg. directory/subdirectory/file
503503
:type file: str or ~azure.storage.filedatalake.FileProperties
504504
:returns: A DataLakeFileClient.
505-
:rtype: ~azure.storage.filedatalake..DataLakeFileClient
505+
:rtype: ~azure.storage.filedatalake.DataLakeFileClient
506506
"""
507507
try:
508-
file_path = file.name
508+
file_path = file.get('name')
509509
except AttributeError:
510-
file_path = self.path_name + '/' + file
510+
file_path = self.path_name + '/' + str(file)
511511

512512
_pipeline = Pipeline(
513513
transport=TransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
@@ -535,9 +535,9 @@ def get_sub_directory_client(self, sub_directory # type: Union[DirectoryPropert
535535
:rtype: ~azure.storage.filedatalake.DataLakeDirectoryClient
536536
"""
537537
try:
538-
subdir_path = sub_directory.name
538+
subdir_path = sub_directory.get('name')
539539
except AttributeError:
540-
subdir_path = self.path_name + '/' + sub_directory
540+
subdir_path = self.path_name + '/' + str(sub_directory)
541541

542542
_pipeline = Pipeline(
543543
transport=TransportWrapper(self._pipeline._transport), # pylint: disable = protected-access

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from azure.storage.blob import ContainerClient
1818
from ._shared.base_client import TransportWrapper, StorageAccountHostsMixin, parse_query, parse_connection_str
1919
from ._serialize import convert_dfs_url_to_blob_url
20-
from ._models import LocationMode, FileSystemProperties, PublicAccess
20+
from ._models import LocationMode, FileSystemProperties, PublicAccess, FileProperties, DirectoryProperties
2121
from ._data_lake_file_client import DataLakeFileClient
2222
from ._data_lake_directory_client import DataLakeDirectoryClient
2323
from ._data_lake_lease import DataLakeLeaseClient
@@ -737,9 +737,9 @@ def get_directory_client(self, directory # type: Union[DirectoryProperties, str
737737
:caption: Getting the directory client to interact with a specific directory.
738738
"""
739739
try:
740-
directory_name = directory.name
740+
directory_name = directory.get('name')
741741
except AttributeError:
742-
directory_name = directory
742+
directory_name = str(directory)
743743
_pipeline = Pipeline(
744744
transport=TransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
745745
policies=self._pipeline._impl_policies # pylint: disable = protected-access
@@ -777,9 +777,9 @@ def get_file_client(self, file_path # type: Union[FileProperties, str]
777777
:caption: Getting the file client to interact with a specific file.
778778
"""
779779
try:
780-
file_path = file_path.name
780+
file_path = file_path.get('name')
781781
except AttributeError:
782-
pass
782+
file_path = str(file_path)
783783
_pipeline = Pipeline(
784784
transport=TransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
785785
policies=self._pipeline._impl_policies # pylint: disable = protected-access

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from azure.core.pipeline import AsyncPipeline
1212
from ._data_lake_file_client_async import DataLakeFileClient
1313
from .._data_lake_directory_client import DataLakeDirectoryClient as DataLakeDirectoryClientBase
14-
from .._models import DirectoryProperties
14+
from .._models import DirectoryProperties, FileProperties
1515
from .._deserialize import deserialize_dir_properties
1616
from ._path_client_async import PathClient
1717
from .._shared.base_client_async import AsyncTransportWrapper
@@ -483,9 +483,9 @@ def get_file_client(self, file # type: Union[FileProperties, str]
483483
:caption: Getting the file client to interact with a specific file.
484484
"""
485485
try:
486-
file_path = file.name
486+
file_path = file.get('name')
487487
except AttributeError:
488-
file_path = self.path_name + '/' + file
488+
file_path = self.path_name + '/' + str(file)
489489

490490
_pipeline = AsyncPipeline(
491491
transport=AsyncTransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
@@ -522,9 +522,9 @@ def get_sub_directory_client(self, sub_directory # type: Union[DirectoryPropert
522522
:caption: Getting the directory client to interact with a specific directory.
523523
"""
524524
try:
525-
subdir_path = sub_directory.name
525+
subdir_path = sub_directory.get('name')
526526
except AttributeError:
527-
subdir_path = self.path_name + '/' + sub_directory
527+
subdir_path = self.path_name + '/' + str(sub_directory)
528528

529529
_pipeline = AsyncPipeline(
530530
transport=AsyncTransportWrapper(self._pipeline._transport), # pylint: disable = protected-access

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from .._generated.aio import AzureDataLakeStorageRESTAPI
2727
from .._shared.base_client_async import AsyncTransportWrapper, AsyncStorageAccountHostsMixin
2828
from .._shared.policies_async import ExponentialRetry
29-
from .._models import FileSystemProperties, PublicAccess
29+
from .._models import FileSystemProperties, PublicAccess, DirectoryProperties, FileProperties
3030

3131
if TYPE_CHECKING:
3232
from datetime import datetime
@@ -696,9 +696,9 @@ def get_directory_client(self, directory # type: Union[DirectoryProperties, str
696696
:caption: Getting the directory client to interact with a specific directory.
697697
"""
698698
try:
699-
directory_name = directory.name
699+
directory_name = directory.get('name')
700700
except AttributeError:
701-
directory_name = directory
701+
directory_name = str(directory)
702702
_pipeline = AsyncPipeline(
703703
transport=AsyncTransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
704704
policies=self._pipeline._impl_policies # pylint: disable = protected-access
@@ -737,9 +737,9 @@ def get_file_client(self, file_path # type: Union[FileProperties, str]
737737
:caption: Getting the file client to interact with a specific file.
738738
"""
739739
try:
740-
file_path = file_path.name
740+
file_path = file_path.get('name')
741741
except AttributeError:
742-
pass
742+
file_path = str(file_path)
743743
_pipeline = AsyncPipeline(
744744
transport=AsyncTransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
745745
policies=self._pipeline._impl_policies # pylint: disable = protected-access

0 commit comments

Comments
 (0)