Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_note_fields(note, get_empty=False):
- """
- Get a list of field data for download.
- Check all field names and return source and destination fields for
- downloading audio.
- """
- field_names = [item[0] for item in note.items()]
- field_data_list = []
- for afk in audio_field_keys:
- for fn in field_names:
- if afk in fn.lower():
- if meaning_in_reading_field:
- try:
- # Here, too, first try reading, then try other
- # fields.
- field_data_list.append(
- field_data(
- note, fn, readings=True, get_empty=get_empty))
- except (KeyError, ValueError):
- # No or empty readings field.
- pass
- try:
- field_data_list.append(
- field_data(
- note, fn, readings=False, get_empty=get_empty))
- except (KeyError, ValueError):
- # No or empty 'normal' field
- pass
- else:
- # We have to call field_data twice to get the base
- # text and reading.
- try:
- fd_base = field_data(
- note, fn, readings=False, get_empty=get_empty)
- except (KeyError, ValueError):
- continue
- try:
- fd_read = field_data(
- note, fn, readings=True, get_empty=get_empty)
- except (KeyError, ValueError):
- # No reading field after all.
- pass
- else:
- # Now we have to put together the two
- # results. I guess i could have used a named
- # tuple above. Oh, well. Kludge branch.
- field_data_list.append(
- (fd_base[0], fd_base[1], fd_base[2], fd_base[3],
- fd_read[4], True))
- # Use what we have from the first try, so that we
- # try GoogleTTS (wiktionary) as well.
- field_data_list.append(fd_base)
- return field_data_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement