Unverified Commit 84ebabc3 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

fix line lengths

parent 3e3bd2e9
Pipeline #16656 failed with stages
in 1 minute and 5 seconds
......@@ -9,7 +9,10 @@ from kafka.errors import KafkaError
from kubernetes import config
def _try_fetch_from_json_object(record_json_data, record_values_for_db, fetch_from_obj_fun, access_status):
def _try_fetch_from_json_object(record_json_data,
record_values_for_db,
fetch_from_obj_fun,
access_status):
if 'locator' in record_json_data:
values = fetch_from_obj_fun(record_json_data, access_status)
record_values_for_db.append(values)
......@@ -92,7 +95,8 @@ def _get_access_status(graph):
for resource in graph:
if 'type' in resource and resource['type'] == 'access' and \
'regulates' in resource and \
resource['regulates'].startswith('https://memobase.ch/digital/') and 'name' in 'resource':
resource['regulates'].startswith('https://memobase.ch/digital/') and \
'name' in 'resource':
if resource['name'] == 'public':
return 'public'
elif resource['name'] == 'private':
......@@ -134,7 +138,8 @@ def _create_audio_snippet_entry(record, mariadbCursor):
snippet_record = record.copy()
snippet_record['sig'] = snippet_record['sig'] + '-intro'
snippet_record['duration'] = \
30.0 if float(snippet_record['duration']) >= 30.0 else float(snippet_record['duration'])
30.0 if float(snippet_record['duration']) >= 30.0 \
else float(snippet_record['duration'])
snippet_record['mimetype'] = 'audio/mpeg'
snippet_record['uri'] = \
'.'.join(snippet_record['uri'].split('.')[0:-1]) + '-intro.mp3'
......@@ -216,12 +221,16 @@ class MediametadataToDB():
access_status = _get_access_status(recordsJsonData)
if access_status == 'public' or access_status == 'closed':
for recordJsonData in recordsJsonData:
if 'type' in recordJsonData and recordJsonData['type'] == 'digitalObject':
if 'type' in recordJsonData and \
recordJsonData['type'] == 'digitalObject':
_try_fetch_from_json_object(recordJsonData, recordValuesForDB,
_get_values_from_digital_object, access_status)
if 'type' in recordJsonData and recordJsonData['type'] == 'thumbnail':
_get_values_from_digital_object,
access_status)
if 'type' in recordJsonData and \
recordJsonData['type'] == 'thumbnail':
_try_fetch_from_json_object(recordJsonData, recordValuesForDB,
_get_values_from_thumbnail_object, access_status)
_get_values_from_thumbnail_object,
access_status)
# if readMessageCounter >= 100:
# break
# to consider: we could skip this next block and rely on max_records instead
......@@ -238,7 +247,8 @@ class MediametadataToDB():
# if readMessageCounter >= 100:
# break
else:
logging.info('Ignoring record since access of digitalObject is {}'.format(access_status))
logging.info('Ignoring record since access of digitalObject is {}'
.format(access_status))
except KafkaError as ex:
status = 'It was not possible to consume the Kafka messages.' + '\n' + str(ex)
logging.error(status)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment