Skip to content

Commit

Permalink
Update azure_sdk.py
Browse files Browse the repository at this point in the history
* Add `_list_filter` method
  • Loading branch information
jzsmoreno committed Nov 10, 2023
1 parent 5f22531 commit 648ce16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion pydbsmgr/utils/azure_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ def show_all_blobs(self) -> None:
if len(blob["name"].split("/")) > 1:
print("\tBlob name : {}".format(blob["name"]))

def get_all_blob(self) -> List[str]:
def get_all_blob(self, filter_criteria: str = None) -> List[str]:
"""Get all blob names from a container"""
blob_names = []
for blob in self._container_client.list_blobs():
if len(blob["name"].split("/")) > 1:
blob_names.append(blob["name"])
if filter_criteria != None:
blob_names = self._list_filter(blob_names, filter_criteria)
return blob_names

def show_blobs(self, directory_name) -> None:
Expand All @@ -207,6 +209,22 @@ def _get_BlobPrefix(self, directory_name: str) -> BlobPrefix:
def set_BlobPrefix(self, file_list: list) -> None:
self.file_list = self._list_to_BlobPrefix(file_list)

def _list_filter(self, elements: list, character: str) -> List[str]:
"""Function that filters a list from a criteria
Args:
elements (list): list of values to be filtered
character (str): filter criteria
Returns:
List[str]: list of filtered elements
"""
filter_elements = []
for element in elements:
if element.find(character) != -1:
filter_elements.append(element)
return filter_elements

def _print_BlobItem(self) -> None:
for file in self.file_list:
print("File name : ", file["name"].split("/")[-1])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pydbsmgr",
version="0.6.3",
version="0.6.4",
author="J. A. Moreno-Guerra",
author_email="[email protected]",
description="Testing installation of Package",
Expand Down

0 comments on commit 648ce16

Please sign in to comment.