From 3aa4ddfff974e02dc78c8fb61a2335f79530666d Mon Sep 17 00:00:00 2001 From: kovalch Date: Mon, 5 Aug 2024 21:56:47 +0200 Subject: [PATCH] fix: Return a value of a dict --- ckanext/dcatapchharvest/dcat_helpers.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/ckanext/dcatapchharvest/dcat_helpers.py b/ckanext/dcatapchharvest/dcat_helpers.py index 0f8e609..68c1d6e 100644 --- a/ckanext/dcatapchharvest/dcat_helpers.py +++ b/ckanext/dcatapchharvest/dcat_helpers.py @@ -247,24 +247,17 @@ def get_license_ref_uri_by_name(self, vocabulary_name): def get_license_ref_uri_by_homepage_uri(self, vocabulary_name): _, _, license_homepage_ref_vocabulary = self._get_license_values() - return next((value for key, value in - license_homepage_ref_vocabulary.items() - if unicode(vocabulary_name) == key), - None) + return license_homepage_ref_vocabulary.get(unicode(vocabulary_name)) def get_license_name_by_ref_uri(self, vocabulary_uri): _, license_ref_literal_vocabulary, _ = self._get_license_values() - return next((value for key, value in - license_ref_literal_vocabulary.items() - if unicode(vocabulary_uri) == key), - None) + return license_ref_literal_vocabulary.get( + unicode(vocabulary_uri)) def get_license_name_by_homepage_uri(self, vocabulary_uri): license_homepages_literal_vocabulary, _, _ = self._get_license_values() - return next((value for key, value in - license_homepages_literal_vocabulary.items() - if unicode(vocabulary_uri) == key), - None) + return license_homepages_literal_vocabulary.get( + unicode(vocabulary_uri)) def get_license_homepage_uri_by_name(self, vocabulary_name): license_homepages_literal_vocabulary, _, _ = self._get_license_values()