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