1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-01-06 03:04:11 +01:00

Removing unneeded from __future__ import statements.

Since we are on Python 3.6 and up, we don't need those anymore.
This commit is contained in:
2020-04-19 17:38:58 +02:00
parent 41b687ee27
commit 48fedea799
331 changed files with 1178 additions and 2067 deletions

View File

@@ -1,9 +1,5 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2010, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
import re
from ebook_converter.polyglot.builtins import codepoint_to_chr, map, range, filter
from ebook_converter.polyglot.html_entities import name2codepoint
from ebook_converter.constants import plugins, preferred_encoding

View File

@@ -1,13 +1,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
'''
"""
Manage application-wide preferences.
'''
"""
import optparse
import os
from copy import deepcopy
@@ -24,6 +17,11 @@ from ebook_converter.utils.lock import ExclusiveFile
from ebook_converter.polyglot.builtins import string_or_bytes, native_string_type
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
# optparse uses gettext.gettext instead of _ from builtins, so we
# monkey patch it.
optparse._ = _

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re
from datetime import datetime, time as dtime, timedelta, MINYEAR, MAXYEAR
from functools import partial
@@ -16,6 +8,11 @@ from ebook_converter.utils.iso8601 import utc_tz, local_tz, UNDEFINED_DATE
from ebook_converter.utils.localization import lcdata
from ebook_converter.polyglot.builtins import unicode_type, native_string_type
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
_utc_tz = utc_tz
_local_tz = local_tz

View File

@@ -1,9 +1,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
'''
"""
Make strings safe for use as ASCII filenames, while trying to preserve as much
meaning as possible.
'''
"""
import errno
import os
import shutil

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from io import BytesIO
from struct import calcsize, unpack, unpack_from
from collections import namedtuple
@@ -14,6 +6,11 @@ from ebook_converter.utils.fonts.utils import get_font_names2, get_font_characte
from ebook_converter.polyglot.builtins import range, unicode_type
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class UnsupportedFont(ValueError):
pass

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
from collections import defaultdict
from threading import Thread
@@ -17,6 +9,11 @@ from ebook_converter.utils.fonts.metadata import FontMetadata, UnsupportedFont
from ebook_converter.polyglot.builtins import itervalues, unicode_type, filter
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class NoFonts(ValueError):
pass

View File

@@ -1,13 +1,10 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
from datetime import datetime, timedelta
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from datetime import datetime, timedelta
def align_block(raw, multiple=4, pad=b'\0'):
'''

View File

@@ -1,7 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'

View File

@@ -1,14 +1,11 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
from struct import pack, unpack_from
from ebook_converter.polyglot.builtins import range, unicode_type
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import pack, unpack_from
from ebook_converter.polyglot.builtins import range, unicode_type
t1_operand_encoding = [None] * 256
t1_operand_encoding[0:32] = (32) * ["do_operator"]
t1_operand_encoding[32:247] = (247 - 32) * ["read_byte"]

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import unpack_from, unpack, calcsize
from functools import partial
@@ -16,6 +8,11 @@ from ebook_converter.utils.fonts.sfnt.cff.constants import (cff_standard_strings
STANDARD_CHARSETS)
from ebook_converter.polyglot.builtins import iteritems, itervalues, range
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
# Useful links
# http://www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5176.CFF.pdf
# http://www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5177.Type2.pdf

View File

@@ -1,14 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
# Note that the code for creating a BMP table (cmap format 4) is taken with
# thanks from the fonttools project (BSD licensed).
from struct import unpack_from, calcsize, pack
from collections import OrderedDict
@@ -18,6 +7,14 @@ from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont
from ebook_converter.polyglot.builtins import range
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
# Note that the code for creating a BMP table (cmap format 4) is taken with
# thanks from the fonttools project (BSD licensed).
def split_range(start_code, end_code, cmap): # {{{
# Try to split a range of character codes into subranges with consecutive
# glyph IDs in such a way that the cmap4 subtable can be stored "most"

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import unpack_from, calcsize
from collections import OrderedDict, namedtuple
@@ -13,6 +5,11 @@ from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont
from ebook_converter.polyglot.builtins import range, iteritems
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class Unpackable(object):
def __init__(self, raw, offset):

View File

@@ -1,8 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
# License: GPLv3 Copyright: 2012, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import OrderedDict
from io import BytesIO
from struct import calcsize, pack
@@ -21,6 +16,7 @@ from ebook_converter.utils.fonts.sfnt.loca import LocaTable
from ebook_converter.utils.fonts.sfnt.maxp import MaxpTable
from ebook_converter.utils.fonts.utils import checksum_of_block, get_tables, verify_checksums
# OpenType spec: http://www.microsoft.com/typography/otspec/otff.htm

View File

@@ -1,7 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'

View File

@@ -1,17 +1,14 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import unpack_from
from collections import OrderedDict
from ebook_converter.utils.fonts.sfnt import UnknownTable
from ebook_converter.polyglot.builtins import iteritems
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
ARG_1_AND_2_ARE_WORDS = 0x0001 # if set args are words otherwise they are bytes
ARGS_ARE_XY_VALUES = 0x0002 # if set args are xy values, otherwise they are points
ROUND_XY_TO_GRID = 0x0004 # for the xy values if above is true

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import unpack_from
from functools import partial
@@ -17,6 +9,11 @@ from ebook_converter.utils.fonts.sfnt.common import (ScriptListTable, FeatureLis
from ebook_converter.polyglot.builtins import iteritems, itervalues
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class SingleSubstitution(UnknownLookupSubTable):
formats = {1, 2}

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import unpack_from, pack, calcsize
from ebook_converter.utils.fonts.sfnt import UnknownTable, DateTimeProperty, FixedProperty
@@ -14,6 +6,11 @@ from ebook_converter.utils.fonts.sfnt.loca import read_array
from ebook_converter.polyglot.builtins import zip
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class HeadTable(UnknownTable):
created = DateTimeProperty('_created')

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import unpack_from, calcsize, pack, error as struct_error
from ebook_converter.utils.fonts.sfnt import (UnknownTable, FixedProperty,
@@ -14,6 +6,11 @@ from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont
from ebook_converter.polyglot.builtins import range
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class KernTable(UnknownTable):
version = FixedProperty('_version')

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import array, sys
from operator import itemgetter
from itertools import repeat
@@ -14,6 +6,11 @@ from ebook_converter.utils.fonts.sfnt import UnknownTable
from ebook_converter.polyglot.builtins import iteritems, range
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
def four_byte_type_code():
for c in 'IL':
a = array.array(c)

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from struct import unpack_from, pack
from ebook_converter.utils.fonts.sfnt import UnknownTable, FixedProperty
@@ -13,6 +5,11 @@ from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont
from ebook_converter.polyglot.builtins import zip
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class MaxpTable(UnknownTable):
version = FixedProperty('_version')

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import traceback
from collections import OrderedDict
from operator import itemgetter
@@ -16,6 +8,11 @@ from ebook_converter.utils.fonts.sfnt.container import Sfnt
from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont, NoGlyphs
from ebook_converter.polyglot.builtins import unicode_type, range, iteritems, itervalues, map
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
# TrueType outlines {{{

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import struct
from io import BytesIO
from collections import defaultdict
@@ -13,6 +5,11 @@ from collections import defaultdict
from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type, range, as_bytes
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class UnsupportedFont(ValueError):
pass

View File

@@ -1,14 +1,8 @@
from __future__ import absolute_import, division, print_function, unicode_literals
'''
"""
Created on 23 Sep 2010
@author: charles
'''
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
"""
import re, string, traceback, numbers
from ebook_converter import prints
@@ -17,6 +11,11 @@ from ebook_converter.utils.formatter_functions import formatter_functions
from ebook_converter.polyglot.builtins import unicode_type, error_message
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class _Parser(object):
LEX_OP = 1
LEX_ID = 2

View File

@@ -1,17 +1,8 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
'''
"""
Created on 13 Jan 2011
@author: charles
'''
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
"""
import inspect, re, traceback, numbers
from math import trunc
@@ -26,6 +17,11 @@ from ebook_converter.utils.localization import calibre_langcode_to_name, canonic
from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class FormatterFunctions(object):
error_function_body = ('def evaluate(self, formatter, kwargs, mi, locals):\n'

View File

@@ -1,9 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
def html2text(html):
from html2text import HTML2Text
import re

View File

@@ -1,24 +1,19 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
import codecs
import sys
import unicodedata
# Setup code {{{
from ebook_converter.constants import plugins
from ebook_converter.polyglot.builtins import unicode_type, cmp
from ebook_converter.polyglot.builtins import filter
from ebook_converter.utils.config_base import tweaks
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import sys
import unicodedata
from ebook_converter.polyglot.builtins import filter
is_narrow_build = sys.maxunicode < 0x10ffff
# Setup code {{{
import codecs
from ebook_converter.constants import plugins
from ebook_converter.utils.config_base import tweaks
from ebook_converter.polyglot.builtins import unicode_type, cmp
_locale = _collator = _primary_collator = _sort_collator = _numeric_collator = _case_sensitive_collator = None
cmp

View File

@@ -1,8 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2015-2019, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
import errno
import os
import shutil

View File

@@ -1,15 +1,13 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
"""
Recognize image file formats and sizes based on their first few bytes.
"""
from struct import unpack, error
import os
from ebook_converter.utils.speedups import ReadOnlyFileBuffer
from ebook_converter.constants import ispy3
from ebook_converter.polyglot.builtins import string_or_bytes, unicode_type
""" Recognize image file formats and sizes based on their first few bytes."""
HSIZE = 120

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os, errno, sys
from threading import Thread
@@ -14,6 +6,11 @@ from ebook_converter.constants import iswindows, get_windows_username, islinux,
from ebook_converter.utils.filenames import ascii_filename
from ebook_converter.polyglot.functools import lru_cache
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
VADDRESS = None

View File

@@ -1,23 +1,25 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import subprocess, os, sys, time
from functools import partial
from ebook_converter.constants import iswindows, isosx, isfrozen, filesystem_encoding, ispy3
from ebook_converter.constants import isosx, isfrozen, filesystem_encoding, ispy3
from ebook_converter.utils.config import prefs
from ebook_converter.ptempfile import PersistentTemporaryFile, base_dir
from ebook_converter.utils.serialize import msgpack_dumps
from ebook_converter.polyglot.builtins import iteritems, unicode_type, string_or_bytes, environ_item, native_string_type, getcwd
from ebook_converter.polyglot.binary import as_hex_unicode
try:
import win32process
iswindows = True
except ImportError:
iswindows = False
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
if iswindows:
import win32process
try:
windows_null_file = open(os.devnull, 'wb')
except:

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os, time, traceback, importlib
from multiprocessing.connection import Client
from threading import Thread
@@ -20,6 +12,11 @@ from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, env
from ebook_converter.polyglot.binary import as_hex_unicode, from_hex_bytes
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class WorkerError(Exception):
def __init__(self, msg, orig_tb='', log_path=None):

View File

@@ -1,8 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
from datetime import datetime
from dateutil.tz import tzlocal, tzutc, tzoffset

View File

@@ -1,18 +1,9 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
'''
"""
Try to read invalid zip files with missing or damaged central directories.
These are apparently produced in large numbers by the fruitcakes over at B&N.
Tries to only use the local headers to extract data from the damaged zip file.
'''
"""
import os, sys, zlib, shutil
from struct import calcsize, unpack, pack
from collections import namedtuple, OrderedDict
@@ -20,6 +11,11 @@ from tempfile import SpooledTemporaryFile
from ebook_converter.polyglot.builtins import itervalues, getcwd
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
HEADER_SIG = 0x04034b50
HEADER_BYTE_SIG = pack(b'<L', HEADER_SIG)
local_header_fmt = b'<L5HL2L2H'

View File

@@ -1,15 +1,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
'A simplified logging system'
DEBUG = 0
INFO = 1
WARN = 2
ERROR = 3
"""
A simplified logging system
"""
import sys, traceback, io
from functools import partial
from threading import Lock
@@ -18,6 +9,16 @@ from ebook_converter import isbytestring, force_unicode, as_unicode, prints
from ebook_converter.polyglot.builtins import unicode_type, iteritems
__license__ = 'GPL 3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
DEBUG = 0
INFO = 1
WARN = 2
ERROR = 3
class Stream(object):
def __init__(self, stream=None):

View File

@@ -1,6 +1,3 @@
# vim:fileencoding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
try:
from time import monotonic
except ImportError:

View File

@@ -1,9 +1,4 @@
# multiple replace from dictionnary : http://code.activestate.com/recipes/81330/
from __future__ import unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2010, sengian <sengian1 @ gmail.com>'
__docformat__ = 'restructuredtext en'
import re
try:
from collections import UserDict
@@ -11,6 +6,11 @@ except ImportError:
from UserDict import UserDict
__license__ = 'GPL v3'
__copyright__ = '2010, sengian <sengian1 @ gmail.com>'
__docformat__ = 'restructuredtext en'
class MReplace(UserDict):
def __init__(self, data=None, case_sensitive=True):

View File

@@ -1,9 +1,3 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
from ebook_converter.polyglot.builtins import unicode_type
from ebook_converter.constants import ispy3

View File

@@ -1,17 +1,4 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
import os, sys
from ebook_converter.polyglot.builtins import reraise
from ebook_converter.constants import iswindows, plugins, ispy3
'''
"""
This module defines a share_open() function which is a replacement for
python's builtin open() function.
@@ -26,7 +13,15 @@ delete a file that is open, you cannot open a new file with the same filename
until all open file handles are closed. You also cannot delete the containing
directory until all file handles are closed. To get around this, rename the
file before deleting it.
'''
"""
import os, sys
from ebook_converter.polyglot.builtins import reraise
from ebook_converter.constants import iswindows, plugins, ispy3
__license__ = 'GPL v3'
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
# speedup, err = plugins['speedup']

View File

@@ -1,12 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
'''
Generate UUID encoded using a user specified alphabet.
'''
import string, math, uuid as _uuid
from ebook_converter.polyglot.builtins import unicode_type

View File

@@ -1,11 +1,3 @@
#!/usr/bin/python2
# vim:fileencoding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
__author__ = "Chad Miller <smartypantspy@chad.org>, Kovid Goyal <kovid at kovidgoyal.net>"
__description__ = "Smart-quotes, smart-ellipses, and smart-dashes for weblog entries in pyblosxom"
r"""
==============
smartypants.py
@@ -66,7 +58,8 @@ sequence into a decimal-encoded HTML entity:
(FIXME: table here.)
.. comment It sucks that there's a disconnect between the visual layout and table markup when special characters are involved.
.. comment It sucks that there's a disconnect between the visual layout and
.. comment table markup when special characters are involved.
.. comment ====== ===== =========
.. comment Escape Value Character
.. comment ====== ===== =========
@@ -377,9 +370,12 @@ smartypants.py license::
.. _Movable Type: http://www.movabletype.org/
"""
import re
__author__ = "Chad Miller <smartypantspy@chad.org>, Kovid Goyal <kovid at kovidgoyal.net>"
__description__ = "Smart-quotes, smart-ellipses, and smart-dashes for weblog entries in pyblosxom"
# style added by Kovid
tags_to_skip_regex = re.compile(r"<(/)?(style|pre|code|kbd|script|math)[^>]*>", re.I)
self_closing_regex = re.compile(r'/\s*>$')

View File

@@ -1,10 +1,5 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
import os
from ebook_converter.polyglot.builtins import range, unicode_type

View File

@@ -1,19 +1,25 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import absolute_import, division, print_function, unicode_literals
import os, sys, re
try:
import ctypes.wintypes
iswindows = True
except ValueError:
iswindows = False
from ebook_converter.constants import ispy3
from ebook_converter.polyglot.builtins import iteritems, range, zip, native_string_type
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os, sys, re
from ebook_converter.constants import iswindows, ispy3
from ebook_converter.polyglot.builtins import iteritems, range, zip, native_string_type
def fmt(code):
return '\033[%dm' % code
if iswindows:
import ctypes.wintypes
class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
_fields_ = [
('dwSize', ctypes.wintypes._COORD),
@@ -24,10 +30,6 @@ if iswindows:
]
def fmt(code):
return '\033[%dm' % code
RATTRIBUTES = dict(
zip(range(1, 9), (
'bold',

View File

@@ -1,19 +1,15 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
"""
Original Perl version by: John Gruber https://daringfireball.net/ 10 May 2008
Python version by Stuart Colville http://muffinresearch.co.uk
Modifications to make it work with non-ascii chars by Kovid Goyal
License: http://www.opensource.org/licenses/mit-license.php
"""
import re
from ebook_converter.utils.icu import capitalize, upper
from ebook_converter.polyglot.builtins import unicode_type
__all__ = ['titlecase']
__version__ = '0.5'

View File

@@ -1,8 +1,3 @@
#!/usr/bin/python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import absolute_import, division, print_function, unicode_literals
"""
Get word, character, and Asian character counts

View File

@@ -1,15 +1,9 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
from lxml import etree
# resolving of SYSTEM entities is turned off as entities can cause
# reads of local files, for example:
# <!DOCTYPE foo [ <!ENTITY passwd SYSTEM "file:///etc/passwd" >]>
fs = etree.fromstring

View File

@@ -1,4 +1,3 @@
from __future__ import absolute_import, division, print_function, unicode_literals
"""
Read and write ZIP files. Modified by Kovid Goyal to support replacing files in
a zip archive, detecting filename encoding, updating zip files, etc.
@@ -20,6 +19,7 @@ except ImportError:
zlib = None
crc32 = binascii.crc32
__all__ = ["BadZipfile", "error", "ZIP_STORED", "ZIP_DEFLATED", "is_zipfile",
"ZipInfo", "ZipFile", "PyZipFile", "LargeZipFile"]