Skip to content

Commit

Permalink
Merge pull request #21 from acdh-oeaw/20-filter-collections-by-nameids
Browse files Browse the repository at this point in the history
new method to filter collections by name added
  • Loading branch information
csae8092 committed Aug 5, 2023
2 parents 286beb0 + 16e9345 commit 1394d9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="acdh-transkribus-utils",
version="2.6",
version="2.7",
description="""some utility function to interact with the Transkribus-API""",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down
5 changes: 5 additions & 0 deletions tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ def test_008_iiif_title(self):
iiif_url = "https://iiif.onb.ac.at/presentation/ANNO/wrz17500103/manifestasdf/"
label = get_title_from_iiif(iiif_url)
self.assertEqual(label, iiif_url)

def test_009_filter_cols_by_name(self):
client = CLIENT
cols = client.filter_collections_by_name("acdh-transkribus-utils")
self.assertEqual(len(cols), 1)
9 changes: 9 additions & 0 deletions transkribus_utils/transkribus_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ def list_collections(self):
response = requests.get(url, cookies=self.login_cookie)
return response.json()

def filter_collections_by_name(self, filter_string):
""" lists all collections which names contains 'filter_string' collections
:param filter_string: a string the collection name should contain
:return: A list with all filtered the collections
"""
cols = self.list_collections()
filtered_cols = [x for x in cols if filter_string in x["colName"]]
return filtered_cols

def list_docs(self, col_id):
"""Helper function to list all documents in a given collection
:param col_id: Collection ID
Expand Down

0 comments on commit 1394d9e

Please sign in to comment.