1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-03-17 23:33:43 +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,13 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
"""
Provides abstraction for metadata reading.writing from a variety of ebook formats.
Provides abstraction for metadata reading.writing from a variety of ebook
formats.
"""
import os, sys, re
@@ -17,6 +10,11 @@ from ebook_converter.polyglot.builtins import codepoint_to_chr, unicode_type, ra
from ebook_converter.polyglot.urllib import quote, unquote, urlparse
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
try:
_author_pat = re.compile(tweaks['authors_split_regex'])
except Exception:

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 os
from contextlib import closing
@@ -14,6 +6,11 @@ from ebook_converter.utils.localization import canonicalize_lang
from ebook_converter.polyglot.builtins import filter, unicode_type
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
def is_comic(list_of_names):
extensions = {x.rpartition('.')[-1].lower() for x in list_of_names
if '.' in x and x.lower().rpartition('/')[-1] != 'thumbs.db'}

View File

@@ -1,16 +1,9 @@
#!/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'
'''
All fields must have a NULL value represented as None for simple types,
an empty list/dictionary for complex types and (None, None) for cover_data
'''
# All fields must have a NULL value represented as None for simple types,
# an empty list/dictionary for complex types and (None, None) for cover_data
SOCIAL_METADATA_FIELDS = frozenset((
'tags', # Ordered list
'rating', # A floating point number between 0 and 10
@@ -22,10 +15,7 @@ SOCIAL_METADATA_FIELDS = frozenset((
'identifiers',
))
'''
The list of names that convert to identifiers when in get and set.
'''
# The list of names that convert to identifiers when in get and set.
TOP_LEVEL_IDENTIFIERS = frozenset((
'isbn',
))
@@ -128,5 +118,5 @@ SERIALIZABLE_FIELDS = SOCIAL_METADATA_FIELDS.union(
CALIBRE_METADATA_FIELDS).union(
DEVICE_METADATA_FIELDS) - \
frozenset(('device_collections', 'formats',
'cover_data'))
'cover_data'))
# these are rebuilt when needed

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 copy, traceback
from ebook_converter import prints
@@ -17,6 +9,11 @@ from ebook_converter.library.field_metadata import FieldMetadata
from ebook_converter.utils.icu import sort_key
from ebook_converter.polyglot.builtins import iteritems, unicode_type, filter, map
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
# Special sets used to optimize the performance of getting and setting
# attributes on Metadata objects
SIMPLE_GET = frozenset(STANDARD_METADATA_FIELDS - TOP_LEVEL_IDENTIFIERS)

View File

@@ -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>'
from ebook_converter.ebooks.metadata.book import TOP_LEVEL_IDENTIFIERS, ALL_METADATA_FIELDS
from ebook_converter.utils.formatter import TemplateFormatter
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
class SafeFormat(TemplateFormatter):
def __init__(self):

View File

@@ -1,11 +1,8 @@
from __future__ import absolute_import, division, print_function, unicode_literals
'''
"""
Created on 4 Jun 2010
@author: charles
'''
"""
import json, traceback
from datetime import datetime, time
@@ -16,6 +13,7 @@ from ebook_converter import isbytestring
from ebook_converter.polyglot.builtins import iteritems, itervalues, as_bytes
from ebook_converter.polyglot.binary import as_base64_unicode, from_base64_bytes
# Translate datetimes to and from strings. The string form is the datetime in
# UTC. The returned date is also UTC

View File

@@ -1,12 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2011, Roman Mukhin <ramses_ru at hotmail.com>, '\
'2008, Anatoly Shipitsin <norguhtar at gmail.com>'
'''Read meta information from fb2 files'''
"""
Read meta information from fb2 files
"""
import os, random
from functools import partial
from string import ascii_letters, digits
@@ -24,6 +18,11 @@ from ebook_converter.polyglot.builtins import unicode_type
from ebook_converter.polyglot.binary import as_base64_unicode
__license__ = 'GPL v3'
__copyright__ = ('2011, Roman Mukhin <ramses_ru at hotmail.com>, '
'2008, Anatoly Shipitsin <norguhtar at gmail.com>')
NAMESPACES = {
'fb2' : 'http://www.gribuser.ru/xml/fictionbook/2.0',
'fb21' : 'http://www.gribuser.ru/xml/fictionbook/2.1',

View File

@@ -1,13 +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>'
'''
"""
Try to read metadata from an HTML file.
'''
"""
import re
import unittest
@@ -23,6 +16,10 @@ from ebook_converter.utils.date import parse_date, is_date_undefined
from ebook_converter.polyglot.builtins import iteritems
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
def get_metadata(stream):
src = stream.read()
return get_metadata_(src)

View File

@@ -1,8 +1,3 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import os, re, collections
from ebook_converter.utils.config import prefs
@@ -13,6 +8,10 @@ from ebook_converter.customize.ui import get_file_type_metadata, set_file_type_m
from ebook_converter.ebooks.metadata import MetaInformation, string_to_authors
from ebook_converter.polyglot.builtins import getcwd, unicode_type
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
# The priorities for loading metadata from different file types
# Higher values should be used to update metadata from lower values
METADATA_PRIORITIES = collections.defaultdict(lambda:0)

View File

@@ -1,6 +1,3 @@
#!/usr/bin/python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
#
# Copyright (C) 2006 Søren Roug, European Environment Agency
#
# This is free software. You may redistribute it under the terms
@@ -18,8 +15,6 @@
#
# Contributor(s):
#
from __future__ import absolute_import, division, print_function, unicode_literals
import io
import json
import os
@@ -39,6 +34,7 @@ from odf.namespaces import DCNS, METANS, OFFICENS
from odf.opendocument import load as odLoad
from ebook_converter.polyglot.builtins import as_unicode
fields = {
'title': (DCNS, 'title'),
'description': (DCNS, 'description'),

View File

@@ -1,13 +1,6 @@
#!/usr/bin/env python2
from __future__ import print_function, unicode_literals, absolute_import, division
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
'''
"""
lxml based OPF parser.
'''
"""
import re, sys, unittest, functools, os, uuid, glob, io, json, copy
from lxml import etree
@@ -27,6 +20,11 @@ from ebook_converter.utils.xml_parse import safe_xml_fromstring
from ebook_converter.polyglot.builtins import iteritems, unicode_type, getcwd, map
from ebook_converter.polyglot.urllib import unquote, urlparse
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
pretty_print_opf = False

View File

@@ -1,9 +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
import json
import re
from collections import defaultdict, namedtuple
@@ -31,6 +25,7 @@ from ebook_converter.utils.date import (
from ebook_converter.utils.iso8601 import parse_iso8601
from ebook_converter.utils.localization import canonicalize_lang
# Utils {{{
_xpath_cache = {}
_re_cache = {}

View File

@@ -1,9 +1,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''Read meta information from PDF files'''
"""
Read meta information from PDF files
"""
import os, subprocess, shutil, re
from functools import partial
@@ -16,6 +13,10 @@ from ebook_converter.utils.ipc.simple_worker import fork_job, WorkerError
from ebook_converter.polyglot.builtins import iteritems, unicode_type
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
def get_tools():
from ebook_converter.ebooks.pdf.pdftohtml import PDFTOHTML
base = os.path.dirname(PDFTOHTML)

View File

@@ -1,11 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
"""
Edit metadata in RTF files.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import codecs
import re

View File

@@ -1,9 +1,3 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid at kovidgoyal.net>'
import os, glob, re, functools
from collections import Counter
@@ -17,6 +11,10 @@ from ebook_converter.utils.cleantext import clean_xml_chars
from ebook_converter.polyglot.builtins import unicode_type, getcwd
from ebook_converter.polyglot.urllib import unquote, urlparse
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid at kovidgoyal.net>'
NCX_NS = "http://www.daisy.org/z3986/2005/ncx/"
CALIBRE_NS = "http://calibre.kovidgoyal.net/2009/metadata"
NSMAP = {None: NCX_NS, 'calibre':CALIBRE_NS}

View File

@@ -1,18 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
'''
"""
Read meta information from TXT files
'''
"""
import re, os
from ebook_converter.ebooks.metadata import MetaInformation
__license__ = 'GPL v3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
def get_metadata(stream, extract_cover=True):
'''
Return metadata as a L{MetaInfo} object

View File

@@ -1,9 +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 collections import namedtuple
from ebook_converter.ebooks.chardet import xml_to_unicode
@@ -15,6 +9,7 @@ from ebook_converter.utils.localization import lang_as_iso639_1
from ebook_converter.utils.xml_parse import safe_xml_fromstring
from ebook_converter.polyglot.builtins import filter, map
OPFVersion = namedtuple('OPFVersion', 'major minor patch')

View File

@@ -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>'
import re, sys, copy, json
from itertools import repeat
from collections import defaultdict
@@ -21,6 +14,10 @@ from ebook_converter.utils.date import parse_date, isoformat, now
from ebook_converter.utils.localization import canonicalize_lang, lang_as_iso639_1
from ebook_converter.polyglot.builtins import iteritems, string_or_bytes, filter
__license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
_xml_declaration = re.compile(r'<\?xml[^<>]+encoding\s*=\s*[\'"](.*?)[\'"][^<>]*>', re.IGNORECASE)
NS_MAP = {