mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DRYer
This commit is contained in:
parent
7c061e3f5f
commit
4174efda6c
@ -15,12 +15,9 @@ _xml_types = {'application/oebps-page-map+xml', 'application/vnd.adobe-page-temp
|
|||||||
guess_type('a.'+x) for x in ('ncx', 'opf', 'svg', 'xpgt', 'xml')}
|
guess_type('a.'+x) for x in ('ncx', 'opf', 'svg', 'xpgt', 'xml')}
|
||||||
|
|
||||||
def syntax_from_mime(name, mime):
|
def syntax_from_mime(name, mime):
|
||||||
if mime in OEB_DOCS:
|
for syntax, types in (('html', OEB_DOCS), ('css', OEB_STYLES), ('xml', _xml_types)):
|
||||||
return 'html'
|
if mime in types:
|
||||||
if mime in OEB_STYLES:
|
return syntax
|
||||||
return 'css'
|
|
||||||
if mime in _xml_types:
|
|
||||||
return 'xml'
|
|
||||||
if mime.startswith('text/'):
|
if mime.startswith('text/'):
|
||||||
return 'text'
|
return 'text'
|
||||||
if mime.startswith('image/') and mime.partition('/')[-1].lower() in {
|
if mime.startswith('image/') and mime.partition('/')[-1].lower() in {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user