mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-23 19:03:34 +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:
@@ -1,11 +1,6 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
class InvalidDOCX(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import numbers
|
||||
from collections import OrderedDict
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
class Inherit(object):
|
||||
|
||||
def __eq__(self, other):
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from collections import OrderedDict
|
||||
from ebook_converter.ebooks.docx.block_styles import ( # noqa
|
||||
inherit, simple_color, LINE_STYLES, simple_float, binary_property, read_shd)
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
# Read from XML {{{
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
import os
|
||||
from ebook_converter.polyglot.builtins import itervalues, range
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os
|
||||
from ebook_converter.polyglot.builtins import itervalues, range
|
||||
|
||||
NBSP = '\xa0'
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, sys, shutil
|
||||
|
||||
from lxml import etree
|
||||
@@ -21,6 +14,10 @@ from ebook_converter.utils.zipfile import ZipFile
|
||||
from ebook_converter.utils.xml_parse import safe_xml_fromstring
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
def fromstring(raw, parser=None):
|
||||
return safe_xml_fromstring(raw)
|
||||
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
|
||||
from ebook_converter.ebooks.docx.index import process_index, polish_index_markup
|
||||
from ebook_converter.polyglot.builtins import iteritems, native_string_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
class Field(object):
|
||||
|
||||
def __init__(self, start):
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, re
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -15,6 +8,10 @@ from ebook_converter.utils.fonts.utils import panose_to_css_generic_family, is_t
|
||||
from ebook_converter.utils.icu import ord_string
|
||||
from ebook_converter.polyglot.builtins import codepoint_to_chr, iteritems, range
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
Embed = namedtuple('Embed', 'name key subsetted')
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
from collections import OrderedDict
|
||||
from ebook_converter.polyglot.builtins import iteritems, unicode_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from collections import OrderedDict
|
||||
from ebook_converter.polyglot.builtins import iteritems, unicode_type
|
||||
|
||||
|
||||
class Note(object):
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os
|
||||
|
||||
from lxml.html.builder import IMG, HR
|
||||
@@ -17,6 +10,10 @@ from ebook_converter.utils.imghdr import what
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
class LinkedImageNotFound(ValueError):
|
||||
|
||||
def __init__(self, fname):
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from operator import itemgetter
|
||||
|
||||
from lxml import etree
|
||||
@@ -13,6 +6,10 @@ from ebook_converter.utils.icu import partition_by_first_letter, sort_key
|
||||
from ebook_converter.polyglot.builtins import iteritems, filter
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
def get_applicable_xe_fields(index, xe_fields, XPath, expand):
|
||||
iet = index.get('entry-type', None)
|
||||
xe_fields = [xe for xe in xe_fields if xe.get('entry-type', None) == iet]
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
|
||||
from lxml.etree import XPath as X
|
||||
@@ -12,6 +5,10 @@ from lxml.etree import XPath as X
|
||||
from ebook_converter.utils.filenames import ascii_text
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
# Names {{{
|
||||
TRANSITIONAL_NAMES = {
|
||||
'DOCUMENT' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re, string
|
||||
from collections import Counter, defaultdict
|
||||
from functools import partial
|
||||
@@ -16,6 +9,10 @@ from ebook_converter.ebooks.docx.char_styles import RunStyle, inherit
|
||||
from ebook_converter.ebooks.metadata import roman
|
||||
from ebook_converter.polyglot.builtins import iteritems, unicode_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
STYLE_MAP = {
|
||||
'aiueo': 'hiragana',
|
||||
'aiueoFullWidth': 'hiragana',
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import textwrap
|
||||
from collections import OrderedDict, Counter
|
||||
|
||||
@@ -14,6 +7,10 @@ from ebook_converter.ebooks.docx.tables import TableStyle
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
class PageProperties(object):
|
||||
|
||||
'''
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from lxml.html.builder import TABLE, TR, TD
|
||||
|
||||
from ebook_converter.ebooks.docx.block_styles import inherit, read_shd as rs, read_border, binary_property, border_props, ParagraphStyle, border_to_css
|
||||
from ebook_converter.ebooks.docx.char_styles import RunStyle
|
||||
from ebook_converter.polyglot.builtins import filter, iteritems, itervalues, range, unicode_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
# Read from XML {{{
|
||||
read_shd = rs
|
||||
edges = ('left', 'top', 'right', 'bottom')
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import sys, os, re, math, errno, uuid, numbers
|
||||
from collections import OrderedDict, defaultdict
|
||||
|
||||
@@ -31,6 +24,9 @@ from ebook_converter.utils.localization import canonicalize_lang, lang_as_iso639
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues, filter, getcwd, map, unicode_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
NBSP = '\xa0'
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from collections import namedtuple
|
||||
from itertools import count
|
||||
|
||||
@@ -15,6 +8,10 @@ from ebook_converter.ebooks.oeb.polish.toc import elem_to_toc_text
|
||||
from ebook_converter.polyglot.builtins import iteritems, range
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
def from_headings(body, log, namespace, num_levels=3):
|
||||
' Create a TOC from headings in the document '
|
||||
tocroot = TOC()
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import textwrap, os
|
||||
|
||||
from lxml import etree
|
||||
@@ -21,6 +14,10 @@ from ebook_converter.utils.zipfile import ZipFile
|
||||
from ebook_converter.polyglot.builtins import iteritems, map, unicode_type, native_string_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
def xml2str(root, pretty_print=False, with_tail=False):
|
||||
if hasattr(etree, 'cleanup_namespaces'):
|
||||
etree.cleanup_namespaces(root)
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/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>'
|
||||
|
||||
from collections import defaultdict
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -13,6 +6,10 @@ from ebook_converter.ebooks.oeb.transforms.subset import find_font_face_rules
|
||||
from ebook_converter.polyglot.builtins import range
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
def obfuscate_font_data(data, key):
|
||||
prefix = bytearray(data[:32])
|
||||
key = bytearray(reversed(key.bytes))
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
from collections import Counter
|
||||
|
||||
@@ -21,6 +14,10 @@ from ebook_converter.utils.localization import lang_as_iso639_1
|
||||
from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
def lang_for_tag(tag):
|
||||
for attr in ('lang', '{http://www.w3.org/XML/1998/namespace}lang'):
|
||||
val = lang_as_iso639_1(tag.get(attr))
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/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
|
||||
import posixpath
|
||||
from collections import namedtuple
|
||||
@@ -19,6 +12,10 @@ from ebook_converter.ebooks.docx.images import pt_to_emu
|
||||
from ebook_converter.utils.filenames import ascii_filename
|
||||
from ebook_converter.utils.imghdr import identify
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
Image = namedtuple('Image', 'rid fname width height fmt item')
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/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 posixpath, re
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -13,6 +6,10 @@ from ebook_converter.polyglot.builtins import unicode_type
|
||||
from ebook_converter.polyglot.urllib import urlparse
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
def start_text(tag, prefix_len=0, top_level=True):
|
||||
ans = tag.text or ''
|
||||
limit = 50 - prefix_len
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
#!/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>'
|
||||
|
||||
from collections import defaultdict
|
||||
from operator import attrgetter
|
||||
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
LIST_STYLES = frozenset(
|
||||
'disc circle square decimal decimal-leading-zero lower-roman upper-roman'
|
||||
' lower-greek lower-alpha lower-latin upper-alpha upper-latin hiragana hebrew'
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/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 numbers
|
||||
from collections import Counter, defaultdict
|
||||
from operator import attrgetter
|
||||
@@ -17,6 +10,10 @@ from ebook_converter.utils.localization import lang_as_iso639_1
|
||||
from ebook_converter.polyglot.builtins import iteritems, filter, unicode_type
|
||||
from ebook_converter.tinycss.css21 import CSS21Parser
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
css_parser = CSS21Parser()
|
||||
|
||||
border_edges = ('left', 'top', 'right', 'bottom')
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
#!/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>'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
from ebook_converter.ebooks.docx.writer.utils import convert_color
|
||||
@@ -12,6 +5,10 @@ from ebook_converter.ebooks.docx.writer.styles import read_css_block_borders as
|
||||
from ebook_converter.polyglot.builtins import iteritems, range, unicode_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
class Dummy(object):
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
from ebook_converter.tinycss.color3 import parse_color_string
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from ebook_converter.tinycss.color3 import parse_color_string
|
||||
|
||||
|
||||
def int_or_zero(raw):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user