mirror of
https://github.com/gryf/ebook-converter.git
synced 2025-12-18 21:20:17 +01:00
Initialize mime in cli module
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import html
|
import html
|
||||||
import math
|
import math
|
||||||
import mimetypes
|
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@@ -11,18 +9,6 @@ from ebook_converter import constants_old
|
|||||||
from ebook_converter.ebooks.html_entities import html5_entities
|
from ebook_converter.ebooks.html_entities import html5_entities
|
||||||
|
|
||||||
|
|
||||||
def init_mimetypes():
|
|
||||||
mimetypes.init([pkg_resources.resource_filename('ebook_converter',
|
|
||||||
'data/mime.types')])
|
|
||||||
|
|
||||||
|
|
||||||
def guess_extension(*args, **kwargs):
|
|
||||||
ext = mimetypes.guess_extension(*args, **kwargs)
|
|
||||||
if not ext and args and args[0] == 'application/x-palmreader':
|
|
||||||
ext = '.pdb'
|
|
||||||
return ext
|
|
||||||
|
|
||||||
|
|
||||||
def sanitize_file_name(name, substitute='_'):
|
def sanitize_file_name(name, substitute='_'):
|
||||||
"""
|
"""
|
||||||
Sanitize the filename `name`. All invalid characters are replaced by
|
Sanitize the filename `name`. All invalid characters are replaced by
|
||||||
|
|||||||
@@ -3,16 +3,17 @@ Command line interface to conversion sub-system
|
|||||||
"""
|
"""
|
||||||
import collections
|
import collections
|
||||||
import json
|
import json
|
||||||
|
import mimetypes
|
||||||
import numbers
|
import numbers
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
|
import pkg_resources
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ebook_converter.utils.config import OptionParser
|
from ebook_converter.utils.config import OptionParser
|
||||||
from ebook_converter.utils.logging import Log
|
from ebook_converter.utils.logging import Log
|
||||||
from ebook_converter.customize.conversion import OptionRecommendation
|
from ebook_converter.customize.conversion import OptionRecommendation
|
||||||
from ebook_converter import init_mimetypes
|
|
||||||
|
|
||||||
|
|
||||||
USAGE = '%prog ' + '''\
|
USAGE = '%prog ' + '''\
|
||||||
@@ -352,7 +353,8 @@ def read_sr_patterns(path, log=None):
|
|||||||
|
|
||||||
def main(args=sys.argv):
|
def main(args=sys.argv):
|
||||||
log = Log()
|
log = Log()
|
||||||
init_mimetypes()
|
mimetypes.init([pkg_resources.resource_filename('ebook_converter',
|
||||||
|
'data/mime.types')])
|
||||||
parser, plumber = create_option_parser(args, log)
|
parser, plumber = create_option_parser(args, log)
|
||||||
opts, leftover_args = parser.parse_args(args)
|
opts, leftover_args = parser.parse_args(args)
|
||||||
if len(leftover_args) > 3:
|
if len(leftover_args) > 3:
|
||||||
|
|||||||
Reference in New Issue
Block a user