2626 'type' : 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ,
2727 },
2828]
29+
2930DOCS_DEFAULT_FORMAT = {
3031 'ext' : '' ,
3132 'download_ext' : '.pdf' ,
@@ -40,41 +41,41 @@ def is_docs_file(metadata):
4041
4142def get_mimetype_from_ext (ext ):
4243 for format_type in DOCS_FORMATS :
43- if format_type [ 'ext' ] == ext :
44- return format_type [ 'mime_type' ]
44+ if format_type . get ( 'ext' ) == ext :
45+ return format_type . get ( 'mime_type' )
4546
4647
4748def get_format (metadata ):
4849 for format_type in DOCS_FORMATS :
49- if format_type [ 'mime_type' ] == metadata [ 'mimeType' ] :
50+ if format_type . get ( 'mime_type' ) == metadata . get ( 'mimeType' ) :
5051 return format_type
5152 return DOCS_DEFAULT_FORMAT
5253
5354
5455def get_extension (metadata ):
5556 format_type = get_format (metadata )
56- return format_type [ 'ext' ]
57+ return format_type . get ( 'ext' )
5758
5859
5960def get_download_extension (metadata ):
6061 format_type = get_format (metadata )
61- return format_type [ 'download_ext' ]
62+ return format_type . get ( 'download_ext' )
6263
6364
6465def get_alt_download_extension (metadata ):
6566 format_type = get_format (metadata )
66- return format_type .get ('alt_download_ext' , None ) or format_type [ 'download_ext' ]
67+ return format_type .get ('alt_download_ext' , None ) or format_type . get ( 'download_ext' )
6768
6869
6970def get_alt_export_link (metadata ):
7071 format_type = get_format (metadata )
71- export_links = metadata [ 'exportLinks' ]
72+ export_links = metadata . get ( 'exportLinks' )
7273 if format_type .get ('alt_type' ):
73- return export_links .get (format_type [ 'alt_type' ] )
74+ return export_links .get (format_type . get ( 'alt_type' ) )
7475 else :
75- return export_links [ format_type [ 'type' ]]
76+ return export_links . get ( format_type . get ( 'type' ))
7677
7778
7879def get_export_link (metadata ):
7980 format_type = get_format (metadata )
80- return metadata [ 'exportLinks' ][ format_type [ 'type' ]]
81+ return metadata . get ( 'exportLinks' ). get ( format_type . get ( 'type' ))
0 commit comments