From 48fedea79942e28f082655cc5a76dba43888f003 Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 19 Apr 2020 17:38:58 +0200 Subject: [PATCH] Removing unneeded from __future__ import statements. Since we are on Python 3.6 and up, we don't need those anymore. --- ebook_converter/css_selectors/__init__.py | 10 +++---- ebook_converter/css_selectors/errors.py | 7 +++-- ebook_converter/css_selectors/ordered_set.py | 10 +++---- ebook_converter/css_selectors/select.py | 11 +++----- ebook_converter/css_selectors/tests.py | 11 +++----- ebook_converter/customize/__init__.py | 8 +++--- ebook_converter/customize/builtins.py | 12 ++++----- ebook_converter/customize/conversion.py | 6 ++--- ebook_converter/customize/profiles.py | 8 +++--- ebook_converter/customize/ui.py | 8 +++--- ebook_converter/customize/zipplugin.py | 20 +++++++------- ebook_converter/data/default_tweaks.py | 5 ---- ebook_converter/devices/interface.py | 8 +++--- ebook_converter/ebooks/BeautifulSoup.py | 5 ---- ebook_converter/ebooks/chardet.py | 9 +++---- ebook_converter/ebooks/compression/palmdoc.py | 16 +++--------- ebook_converter/ebooks/conversion/__init__.py | 6 ++--- ebook_converter/ebooks/conversion/cli.py | 16 +++++------- .../ebooks/conversion/plugins/azw4_input.py | 8 +++--- .../ebooks/conversion/plugins/chm_input.py | 14 +++++----- .../ebooks/conversion/plugins/comic_input.py | 16 +++++------- .../ebooks/conversion/plugins/djvu_input.py | 13 ++++------ .../ebooks/conversion/plugins/docx_input.py | 7 ++--- .../ebooks/conversion/plugins/docx_output.py | 7 ++--- .../ebooks/conversion/plugins/epub_input.py | 11 ++++---- .../ebooks/conversion/plugins/epub_output.py | 13 ++++------ .../ebooks/conversion/plugins/fb2_input.py | 8 +++--- .../ebooks/conversion/plugins/fb2_output.py | 10 +++---- .../ebooks/conversion/plugins/html_input.py | 13 ++++------ .../ebooks/conversion/plugins/html_output.py | 11 ++++---- .../ebooks/conversion/plugins/htmlz_input.py | 13 ++++------ .../ebooks/conversion/plugins/htmlz_output.py | 13 ++++------ .../ebooks/conversion/plugins/lit_input.py | 7 ++--- .../ebooks/conversion/plugins/lit_output.py | 8 ++---- .../ebooks/conversion/plugins/lrf_input.py | 13 ++++------ .../ebooks/conversion/plugins/lrf_output.py | 13 ++++------ .../ebooks/conversion/plugins/mobi_input.py | 11 ++++---- .../ebooks/conversion/plugins/mobi_output.py | 11 +++----- .../ebooks/conversion/plugins/odt_input.py | 12 ++++----- .../ebooks/conversion/plugins/oeb_output.py | 11 ++++---- .../ebooks/conversion/plugins/pdb_input.py | 8 +++--- .../ebooks/conversion/plugins/pdb_output.py | 12 ++++----- .../ebooks/conversion/plugins/pdf_input.py | 12 ++++----- .../ebooks/conversion/plugins/pdf_output.py | 17 +++++------- .../ebooks/conversion/plugins/pml_input.py | 12 ++++----- .../ebooks/conversion/plugins/pml_output.py | 12 ++++----- .../ebooks/conversion/plugins/rb_input.py | 9 +++---- .../ebooks/conversion/plugins/rb_output.py | 10 +++---- .../ebooks/conversion/plugins/recipe_input.py | 13 ++++------ .../ebooks/conversion/plugins/rtf_input.py | 7 +++-- .../ebooks/conversion/plugins/rtf_output.py | 10 +++---- .../ebooks/conversion/plugins/snb_input.py | 12 ++++----- .../ebooks/conversion/plugins/snb_output.py | 12 ++++----- .../ebooks/conversion/plugins/tcr_input.py | 11 ++++---- .../ebooks/conversion/plugins/tcr_output.py | 12 ++++----- .../ebooks/conversion/plugins/txt_input.py | 12 ++++----- .../ebooks/conversion/plugins/txt_output.py | 13 ++++------ ebook_converter/ebooks/conversion/plumber.py | 12 ++++----- .../ebooks/conversion/preprocess.py | 13 ++++------ ebook_converter/ebooks/conversion/utils.py | 13 ++++------ ebook_converter/ebooks/covers.py | 11 +++----- ebook_converter/ebooks/docx/__init__.py | 5 ---- ebook_converter/ebooks/docx/block_styles.py | 11 +++----- ebook_converter/ebooks/docx/char_styles.py | 11 +++----- ebook_converter/ebooks/docx/cleanup.py | 9 +++---- ebook_converter/ebooks/docx/container.py | 11 +++----- ebook_converter/ebooks/docx/fields.py | 11 +++----- ebook_converter/ebooks/docx/fonts.py | 11 +++----- ebook_converter/ebooks/docx/footnotes.py | 9 +++---- ebook_converter/ebooks/docx/images.py | 11 +++----- ebook_converter/ebooks/docx/index.py | 11 +++----- ebook_converter/ebooks/docx/names.py | 11 +++----- ebook_converter/ebooks/docx/numbering.py | 11 +++----- ebook_converter/ebooks/docx/settings.py | 4 --- ebook_converter/ebooks/docx/styles.py | 11 +++----- ebook_converter/ebooks/docx/tables.py | 11 +++----- ebook_converter/ebooks/docx/theme.py | 4 --- ebook_converter/ebooks/docx/to_html.py | 10 +++---- ebook_converter/ebooks/docx/toc.py | 11 +++----- .../ebooks/docx/writer/container.py | 11 +++----- ebook_converter/ebooks/docx/writer/fonts.py | 11 +++----- .../ebooks/docx/writer/from_html.py | 11 +++----- ebook_converter/ebooks/docx/writer/images.py | 11 +++----- ebook_converter/ebooks/docx/writer/links.py | 11 +++----- ebook_converter/ebooks/docx/writer/lists.py | 11 +++----- ebook_converter/ebooks/docx/writer/styles.py | 11 +++----- ebook_converter/ebooks/docx/writer/tables.py | 11 +++----- ebook_converter/ebooks/docx/writer/utils.py | 7 ++--- ebook_converter/ebooks/epub/__init__.py | 11 ++++---- ebook_converter/ebooks/fb2/__init__.py | 4 --- ebook_converter/ebooks/fb2/fb2ml.py | 17 +++++------- ebook_converter/ebooks/html/input.py | 19 +++++--------- ebook_converter/ebooks/html/to_zip.py | 13 ++++------ ebook_converter/ebooks/html_entities.py | 5 ---- ebook_converter/ebooks/htmlz/oeb2html.py | 18 +++++-------- ebook_converter/ebooks/lrf/__init__.py | 11 ++++---- ebook_converter/ebooks/lrf/fonts.py | 13 ++++------ ebook_converter/ebooks/lrf/html/color_map.py | 5 ++-- .../ebooks/lrf/html/convert_from.py | 17 +++++------- ebook_converter/ebooks/lrf/html/table.py | 8 +++--- ebook_converter/ebooks/lrf/pylrs/__init__.py | 7 ----- ebook_converter/ebooks/lrf/pylrs/elements.py | 7 +++-- ebook_converter/ebooks/lrf/pylrs/pylrf.py | 7 ++--- ebook_converter/ebooks/lrf/pylrs/pylrfopt.py | 3 --- ebook_converter/ebooks/lrf/pylrs/pylrs.py | 3 --- ebook_converter/ebooks/metadata/__init__.py | 16 +++++------- ebook_converter/ebooks/metadata/archive.py | 13 ++++------ .../ebooks/metadata/book/__init__.py | 18 +++---------- ebook_converter/ebooks/metadata/book/base.py | 13 ++++------ .../ebooks/metadata/book/formatter.py | 11 +++----- .../ebooks/metadata/book/json_codec.py | 8 +++--- ebook_converter/ebooks/metadata/fb2.py | 17 ++++++------ ebook_converter/ebooks/metadata/html.py | 15 +++++------ ebook_converter/ebooks/metadata/meta.py | 9 +++---- ebook_converter/ebooks/metadata/odt.py | 6 +---- ebook_converter/ebooks/metadata/opf2.py | 16 +++++------- ebook_converter/ebooks/metadata/opf3.py | 7 +---- ebook_converter/ebooks/metadata/pdf.py | 13 +++++----- ebook_converter/ebooks/metadata/rtf.py | 5 ---- ebook_converter/ebooks/metadata/toc.py | 10 +++---- ebook_converter/ebooks/metadata/txt.py | 15 +++++------ ebook_converter/ebooks/metadata/utils.py | 7 +---- ebook_converter/ebooks/metadata/xmp.py | 11 +++----- ebook_converter/ebooks/mobi/__init__.py | 9 +++---- ebook_converter/ebooks/mobi/huffcdic.py | 22 +++++++--------- ebook_converter/ebooks/mobi/langcodes.py | 8 +++--- ebook_converter/ebooks/mobi/mobiml.py | 14 +++++----- .../ebooks/mobi/reader/containers.py | 11 +++----- ebook_converter/ebooks/mobi/reader/headers.py | 13 ++++------ ebook_converter/ebooks/mobi/reader/index.py | 13 ++++------ ebook_converter/ebooks/mobi/reader/markup.py | 13 ++++------ ebook_converter/ebooks/mobi/reader/mobi6.py | 13 ++++------ ebook_converter/ebooks/mobi/reader/mobi8.py | 13 ++++------ ebook_converter/ebooks/mobi/reader/ncx.py | 13 ++++------ ebook_converter/ebooks/mobi/tweak.py | 13 ++++------ ebook_converter/ebooks/mobi/utils.py | 13 ++++------ .../ebooks/mobi/writer2/__init__.py | 8 +----- .../ebooks/mobi/writer2/indexer.py | 13 ++++------ ebook_converter/ebooks/mobi/writer2/main.py | 13 ++++------ .../ebooks/mobi/writer2/resources.py | 17 ++++++------ .../ebooks/mobi/writer2/serializer.py | 14 ++++------ .../ebooks/mobi/writer8/cleanup.py | 7 ++--- ebook_converter/ebooks/mobi/writer8/exth.py | 13 ++++------ ebook_converter/ebooks/odt/input.py | 14 +++++----- ebook_converter/ebooks/oeb/base.py | 15 +++++------ ebook_converter/ebooks/oeb/normalize_css.py | 11 +++----- ebook_converter/ebooks/oeb/parse_utils.py | 13 ++++------ .../ebooks/oeb/polish/container.py | 5 ---- ebook_converter/ebooks/oeb/polish/css.py | 11 +++----- ebook_converter/ebooks/oeb/polish/errors.py | 7 ++--- ebook_converter/ebooks/oeb/polish/opf.py | 11 +++----- ebook_converter/ebooks/oeb/polish/parsing.py | 11 +++----- ebook_converter/ebooks/oeb/polish/pretty.py | 10 +++---- ebook_converter/ebooks/oeb/polish/replace.py | 13 ++++------ ebook_converter/ebooks/oeb/polish/split.py | 11 +++----- ebook_converter/ebooks/oeb/polish/toc.py | 13 ++++------ ebook_converter/ebooks/oeb/polish/utils.py | 11 +++----- ebook_converter/ebooks/oeb/reader.py | 8 +++--- ebook_converter/ebooks/oeb/stylizer.py | 15 +++++------ .../ebooks/oeb/transforms/cover.py | 13 ++++------ .../ebooks/oeb/transforms/data_url.py | 11 +++----- .../ebooks/oeb/transforms/filenames.py | 13 ++++------ .../ebooks/oeb/transforms/flatcss.py | 13 +++++----- .../ebooks/oeb/transforms/guide.py | 4 --- .../ebooks/oeb/transforms/htmltoc.py | 12 ++++----- .../ebooks/oeb/transforms/jacket.py | 13 ++++------ .../ebooks/oeb/transforms/manglecase.py | 13 +++++----- .../ebooks/oeb/transforms/metadata.py | 13 ++++------ .../ebooks/oeb/transforms/page_margin.py | 13 ++++------ .../ebooks/oeb/transforms/rasterize.py | 14 +++++----- .../ebooks/oeb/transforms/rescale.py | 7 ++--- .../ebooks/oeb/transforms/split.py | 14 +++++----- .../ebooks/oeb/transforms/structure.py | 13 ++++------ .../ebooks/oeb/transforms/subset.py | 13 ++++------ .../ebooks/oeb/transforms/trimmanifest.py | 13 +++++----- ebook_converter/ebooks/oeb/writer.py | 13 +++++----- ebook_converter/ebooks/pdb/__init__.py | 3 --- .../ebooks/pdb/ereader/__init__.py | 6 ++--- ebook_converter/ebooks/pdb/ereader/reader.py | 17 +++++------- .../ebooks/pdb/ereader/reader132.py | 17 +++++------- .../ebooks/pdb/ereader/reader202.py | 20 +++++++------- ebook_converter/ebooks/pdb/formatreader.py | 8 ++---- ebook_converter/ebooks/pdb/haodoo/__init__.py | 10 ------- ebook_converter/ebooks/pdb/haodoo/reader.py | 18 +++++-------- ebook_converter/ebooks/pdb/header.py | 17 +++++------- ebook_converter/ebooks/pdb/palmdoc/reader.py | 14 +++++----- ebook_converter/ebooks/pdb/pdf/reader.py | 16 +++++------- ebook_converter/ebooks/pdb/plucker/reader.py | 13 ++++------ ebook_converter/ebooks/pdb/ztxt/__init__.py | 3 --- ebook_converter/ebooks/pdb/ztxt/reader.py | 18 +++++-------- ebook_converter/ebooks/pdf/pdftohtml.py | 6 ----- ebook_converter/ebooks/pdf/render/common.py | 13 ++++------ ebook_converter/ebooks/rtf/input.py | 6 ++--- ebook_converter/ebooks/rtf2xml/ParseRtf.py | 1 - ebook_converter/ebooks/rtf2xml/__init__.py | 2 -- .../ebooks/rtf2xml/add_brackets.py | 1 - ebook_converter/ebooks/rtf2xml/body_styles.py | 1 - .../ebooks/rtf2xml/border_parse.py | 1 - ebook_converter/ebooks/rtf2xml/char_set.py | 1 - .../ebooks/rtf2xml/check_brackets.py | 1 - .../ebooks/rtf2xml/check_encoding.py | 3 --- ebook_converter/ebooks/rtf2xml/colors.py | 1 - .../ebooks/rtf2xml/combine_borders.py | 1 - .../ebooks/rtf2xml/convert_to_tags.py | 1 - ebook_converter/ebooks/rtf2xml/copy.py | 1 - .../ebooks/rtf2xml/default_encoding.py | 1 - ebook_converter/ebooks/rtf2xml/delete_info.py | 1 - .../ebooks/rtf2xml/field_strings.py | 1 - .../ebooks/rtf2xml/fields_large.py | 1 - .../ebooks/rtf2xml/fields_small.py | 1 - ebook_converter/ebooks/rtf2xml/fonts.py | 1 - ebook_converter/ebooks/rtf2xml/footnote.py | 1 - .../ebooks/rtf2xml/get_char_map.py | 1 - .../ebooks/rtf2xml/group_borders.py | 1 - .../ebooks/rtf2xml/group_styles.py | 1 - ebook_converter/ebooks/rtf2xml/header.py | 1 - .../ebooks/rtf2xml/headings_to_sections.py | 1 - ebook_converter/ebooks/rtf2xml/hex_2_utf8.py | 1 - ebook_converter/ebooks/rtf2xml/info.py | 1 - ebook_converter/ebooks/rtf2xml/inline.py | 1 - .../ebooks/rtf2xml/line_endings.py | 1 - .../ebooks/rtf2xml/list_numbers.py | 1 - ebook_converter/ebooks/rtf2xml/list_table.py | 1 - ebook_converter/ebooks/rtf2xml/make_lists.py | 1 - ebook_converter/ebooks/rtf2xml/old_rtf.py | 1 - ebook_converter/ebooks/rtf2xml/output.py | 1 - .../ebooks/rtf2xml/override_table.py | 2 -- .../ebooks/rtf2xml/paragraph_def.py | 1 - ebook_converter/ebooks/rtf2xml/paragraphs.py | 1 - ebook_converter/ebooks/rtf2xml/pict.py | 1 - .../ebooks/rtf2xml/preamble_div.py | 2 -- .../ebooks/rtf2xml/preamble_rest.py | 1 - .../ebooks/rtf2xml/process_tokens.py | 1 - ebook_converter/ebooks/rtf2xml/sections.py | 1 - ebook_converter/ebooks/rtf2xml/styles.py | 1 - ebook_converter/ebooks/rtf2xml/table.py | 1 - ebook_converter/ebooks/rtf2xml/table_info.py | 1 - ebook_converter/ebooks/rtf2xml/tokenize.py | 1 - ebook_converter/ebooks/textile/functions.py | 22 +++++----------- ebook_converter/ebooks/textile/unsmarten.py | 6 ++--- ebook_converter/ebooks/txt/markdownml.py | 18 ++++++------- ebook_converter/ebooks/txt/newlines.py | 6 ++--- ebook_converter/ebooks/txt/processor.py | 18 +++++-------- ebook_converter/ebooks/txt/textileml.py | 16 +++++------- ebook_converter/ebooks/txt/txtml.py | 16 +++++------- .../ebooks/unihandecode/__init__.py | 19 ++++++-------- .../ebooks/unihandecode/jacodepoints.py | 12 +++------ .../ebooks/unihandecode/jadecoder.py | 18 ++++++------- .../ebooks/unihandecode/krcodepoints.py | 12 +++------ .../ebooks/unihandecode/krdecoder.py | 20 ++++++-------- .../ebooks/unihandecode/unicodepoints.py | 15 +++++------ .../ebooks/unihandecode/unidecoder.py | 18 ++++++------- .../ebooks/unihandecode/vncodepoints.py | 12 +++------ .../ebooks/unihandecode/vndecoder.py | 25 ++++++++---------- .../ebooks/unihandecode/zhcodepoints.py | 12 +++------ ebook_converter/library/__init__.py | 14 +++++----- ebook_converter/library/catalogs/__init__.py | 5 ---- ebook_converter/library/catalogs/bibtex.py | 13 ++++------ ebook_converter/library/catalogs/csv_xml.py | 13 ++++------ ebook_converter/library/catalogs/epub_mobi.py | 13 ++++------ ebook_converter/library/comments.py | 7 +---- ebook_converter/library/field_metadata.py | 7 ++--- ebook_converter/polyglot/binary.py | 6 ----- ebook_converter/polyglot/builtins.py | 7 +---- ebook_converter/polyglot/functools.py | 7 +---- ebook_converter/polyglot/urllib.py | 7 +---- ebook_converter/spell/__init__.py | 11 +++----- ebook_converter/tinycss/color3.py | 3 --- ebook_converter/tinycss/css21.py | 3 --- ebook_converter/tinycss/decoding.py | 4 --- ebook_converter/tinycss/fonts3.py | 13 ++++------ ebook_converter/tinycss/media3.py | 11 +++----- ebook_converter/tinycss/page3.py | 3 --- ebook_converter/tinycss/parsing.py | 6 +---- ebook_converter/tinycss/tests/__init__.py | 7 ++--- ebook_converter/tinycss/tests/color3.py | 9 +++---- ebook_converter/tinycss/tests/css21.py | 12 ++++----- ebook_converter/tinycss/tests/decoding.py | 8 +++--- ebook_converter/tinycss/tests/fonts3.py | 11 +++----- ebook_converter/tinycss/tests/main.py | 6 ++--- ebook_converter/tinycss/tests/media3.py | 8 +++--- ebook_converter/tinycss/tests/page3.py | 8 +++--- ebook_converter/tinycss/tests/tokenizing.py | 9 +++---- ebook_converter/tinycss/token_data.py | 4 --- ebook_converter/tinycss/tokenizer.py | 4 --- ebook_converter/utils/cleantext.py | 6 +---- ebook_converter/utils/config.py | 16 +++++------- ebook_converter/utils/date.py | 13 ++++------ ebook_converter/utils/filenames.py | 6 ++--- ebook_converter/utils/fonts/metadata.py | 13 ++++------ ebook_converter/utils/fonts/scanner.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/__init__.py | 7 ++--- .../utils/fonts/sfnt/cff/constants.py | 4 --- .../utils/fonts/sfnt/cff/dict_data.py | 9 +++---- ebook_converter/utils/fonts/sfnt/cff/table.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/cmap.py | 19 ++++++-------- ebook_converter/utils/fonts/sfnt/common.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/container.py | 6 +---- ebook_converter/utils/fonts/sfnt/errors.py | 4 --- ebook_converter/utils/fonts/sfnt/glyf.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/gsub.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/head.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/kern.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/loca.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/maxp.py | 13 ++++------ ebook_converter/utils/fonts/sfnt/subset.py | 13 ++++------ ebook_converter/utils/fonts/utils.py | 13 ++++------ ebook_converter/utils/formatter.py | 15 +++++------ ebook_converter/utils/formatter_functions.py | 18 +++++-------- ebook_converter/utils/html2text.py | 6 ----- ebook_converter/utils/icu.py | 25 +++++++----------- ebook_converter/utils/img.py | 5 ---- ebook_converter/utils/imghdr.py | 10 +++---- ebook_converter/utils/ipc/__init__.py | 13 ++++------ ebook_converter/utils/ipc/launch.py | 22 +++++++++------- ebook_converter/utils/ipc/simple_worker.py | 13 ++++------ ebook_converter/utils/iso8601.py | 5 ---- ebook_converter/utils/localunzip.py | 18 +++++-------- ebook_converter/utils/logging.py | 25 +++++++++--------- ebook_converter/utils/monotonic.py | 3 --- ebook_converter/utils/mreplace.py | 10 +++---- ebook_converter/utils/serialize.py | 6 ----- ebook_converter/utils/shared_file.py | 25 +++++++----------- ebook_converter/utils/short_uuid.py | 6 ----- ebook_converter/utils/smartypants.py | 16 +++++------- ebook_converter/utils/speedups.py | 7 +---- ebook_converter/utils/terminal.py | 26 ++++++++++--------- ebook_converter/utils/titlecase.py | 6 +---- ebook_converter/utils/wordcount.py | 5 ---- ebook_converter/utils/xml_parse.py | 8 +----- ebook_converter/utils/zipfile.py | 2 +- 331 files changed, 1178 insertions(+), 2067 deletions(-) diff --git a/ebook_converter/css_selectors/__init__.py b/ebook_converter/css_selectors/__init__.py index ecfe250..113bdc7 100644 --- a/ebook_converter/css_selectors/__init__.py +++ b/ebook_converter/css_selectors/__init__.py @@ -1,12 +1,8 @@ -#!/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 ' - from ebook_converter.css_selectors.parser import parse from ebook_converter.css_selectors.select import Select, INAPPROPRIATE_PSEUDO_CLASSES from ebook_converter.css_selectors.errors import SelectorError, SelectorSyntaxError, ExpressionError + +__license__ = 'GPL v3' +__copyright__ = '2015, Kovid Goyal ' __all__ = ['parse', 'Select', 'INAPPROPRIATE_PSEUDO_CLASSES', 'SelectorError', 'SelectorSyntaxError', 'ExpressionError'] diff --git a/ebook_converter/css_selectors/errors.py b/ebook_converter/css_selectors/errors.py index 070965c..e392ceb 100644 --- a/ebook_converter/css_selectors/errors.py +++ b/ebook_converter/css_selectors/errors.py @@ -1,18 +1,17 @@ -#!/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 ' + class SelectorError(ValueError): """Common parent for SelectorSyntaxError and ExpressionError""" + class SelectorSyntaxError(SelectorError): """Parsing a selector that does not match the grammar.""" + class ExpressionError(SelectorError): """Unknown or unsupported selector (eg. pseudo-class).""" diff --git a/ebook_converter/css_selectors/ordered_set.py b/ebook_converter/css_selectors/ordered_set.py index ac18413..c68418d 100644 --- a/ebook_converter/css_selectors/ordered_set.py +++ b/ebook_converter/css_selectors/ordered_set.py @@ -1,13 +1,11 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +import collections + +from ebook_converter.polyglot.builtins import string_or_bytes + __license__ = 'GPL v3' __copyright__ = '2015, Kovid Goyal ' -import collections -from ebook_converter.polyglot.builtins import string_or_bytes - SLICE_ALL = slice(None) diff --git a/ebook_converter/css_selectors/select.py b/ebook_converter/css_selectors/select.py index d1852ea..a1468ed 100644 --- a/ebook_converter/css_selectors/select.py +++ b/ebook_converter/css_selectors/select.py @@ -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 ' - import re, itertools from collections import OrderedDict, defaultdict from functools import wraps @@ -18,6 +11,10 @@ from ebook_converter.css_selectors.ordered_set import OrderedSet from ebook_converter.polyglot.builtins import iteritems, itervalues + +__license__ = 'GPL v3' +__copyright__ = '2015, Kovid Goyal ' + PARSE_CACHE_SIZE = 200 parse_cache = OrderedDict() XPATH_CACHE_SIZE = 30 diff --git a/ebook_converter/css_selectors/tests.py b/ebook_converter/css_selectors/tests.py index 86ce622..d77cb5a 100644 --- a/ebook_converter/css_selectors/tests.py +++ b/ebook_converter/css_selectors/tests.py @@ -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 ' - import unittest, sys, argparse from lxml import etree, html @@ -14,6 +7,10 @@ from ebook_converter.css_selectors.parser import tokenize, parse from ebook_converter.css_selectors.select import Select +__license__ = 'GPL v3' +__copyright__ = '2015, Kovid Goyal ' + + class TestCSSSelectors(unittest.TestCase): # Test data {{{ diff --git a/ebook_converter/customize/__init__.py b/ebook_converter/customize/__init__.py index 83a6ec1..e3f147c 100644 --- a/ebook_converter/customize/__init__.py +++ b/ebook_converter/customize/__init__.py @@ -1,13 +1,13 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' - import os, sys, zipfile, importlib from ebook_converter.constants import numeric_version, iswindows, isosx from ebook_converter.ptempfile import PersistentTemporaryFile from ebook_converter.polyglot.builtins import unicode_type + +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + platform = 'linux' if iswindows: platform = 'windows' diff --git a/ebook_converter/customize/builtins.py b/ebook_converter/customize/builtins.py index 16f9a46..4c04df9 100644 --- a/ebook_converter/customize/builtins.py +++ b/ebook_converter/customize/builtins.py @@ -1,10 +1,5 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' - import os, glob, re + from ebook_converter import guess_type from ebook_converter.customize import (FileTypePlugin, MetadataReaderPlugin, MetadataWriterPlugin, PreferencesPlugin, InterfaceActionBase, StoreBase) @@ -12,6 +7,10 @@ from ebook_converter.constants import numeric_version from ebook_converter.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comic_metadata from ebook_converter.ebooks.html.to_zip import HTML2ZIP + +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + plugins = [] # To archive plugins {{{ @@ -1945,7 +1944,6 @@ if __name__ == '__main__': try: subprocess.check_call(['python', '-c', textwrap.dedent( ''' - from __future__ import print_function import time, sys, init_calibre st = time.time() import ebook_converter.customize.builtins diff --git a/ebook_converter/customize/conversion.py b/ebook_converter/customize/conversion.py index 8a3a718..63c334f 100644 --- a/ebook_converter/customize/conversion.py +++ b/ebook_converter/customize/conversion.py @@ -1,8 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals -''' +""" Defines the plugin system for conversions. -''' +""" import re, os, shutil, numbers from ebook_converter import CurrentDir diff --git a/ebook_converter/customize/profiles.py b/ebook_converter/customize/profiles.py index 3434a97..a277e86 100644 --- a/ebook_converter/customize/profiles.py +++ b/ebook_converter/customize/profiles.py @@ -1,12 +1,10 @@ -# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai -from __future__ import absolute_import, division, print_function, unicode_literals +from ebook_converter.customize import Plugin as _Plugin +from ebook_converter.polyglot.builtins import zip + __license__ = 'GPL 3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter.customize import Plugin as _Plugin -from ebook_converter.polyglot.builtins import zip - FONT_SIZES = [('xx-small', 1), ('x-small', None), ('small', 2), diff --git a/ebook_converter/customize/ui.py b/ebook_converter/customize/ui.py index 416aa04..a0e1bb5 100644 --- a/ebook_converter/customize/ui.py +++ b/ebook_converter/customize/ui.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' - import os, shutil, traceback, functools, sys from collections import defaultdict from itertools import chain @@ -24,6 +20,10 @@ from ebook_converter.utils.config import (make_config_dir, Config, ConfigProxy, from ebook_converter.constants import DEBUG, numeric_version from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type + +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + builtin_names = frozenset(p.name for p in builtin_plugins) BLACKLISTED_PLUGINS = frozenset({'Marvin XD', 'iOS reader applications'}) diff --git a/ebook_converter/customize/zipplugin.py b/ebook_converter/customize/zipplugin.py index 3c39329..36f36be 100644 --- a/ebook_converter/customize/zipplugin.py +++ b/ebook_converter/customize/zipplugin.py @@ -1,11 +1,8 @@ -#!/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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - +""" +PEP 302 based plugin loading mechanism, works around the bug in zipimport in +python 2.x that prevents importing from zip files in locations whose paths +have non ASCII characters +""" import os, zipfile, posixpath, importlib, threading, re, imp, sys from collections import OrderedDict from functools import partial @@ -17,9 +14,10 @@ from ebook_converter.customize import (Plugin, numeric_version, platform, from ebook_converter.polyglot.builtins import (itervalues, map, string_or_bytes, unicode_type, reload) -# PEP 302 based plugin loading mechanism, works around the bug in zipimport in -# python 2.x that prevents importing from zip files in locations whose paths -# have non ASCII characters + +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' def get_resources(zfp, name_or_list_of_names): diff --git a/ebook_converter/data/default_tweaks.py b/ebook_converter/data/default_tweaks.py index 5ca16b1..7738a70 100644 --- a/ebook_converter/data/default_tweaks.py +++ b/ebook_converter/data/default_tweaks.py @@ -1,8 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai -# License: GPLv3 Copyright: 2010, Kovid Goyal -from __future__ import unicode_literals - # Contains various tweaks that affect calibre behavior. Only edit this file if # you know what you are doing. If you delete this file, it will be recreated from # defaults. diff --git a/ebook_converter/devices/interface.py b/ebook_converter/devices/interface.py index 7bcc18c..af05e72 100644 --- a/ebook_converter/devices/interface.py +++ b/ebook_converter/devices/interface.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' import os from collections import namedtuple @@ -10,6 +6,10 @@ from ebook_converter.constants import iswindows from ebook_converter.customize import Plugin +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + + class DevicePlugin(Plugin): """ Defines the interface that should be implemented by backends that diff --git a/ebook_converter/ebooks/BeautifulSoup.py b/ebook_converter/ebooks/BeautifulSoup.py index 35b0096..31af905 100644 --- a/ebook_converter/ebooks/BeautifulSoup.py +++ b/ebook_converter/ebooks/BeautifulSoup.py @@ -1,9 +1,4 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 # License: GPLv3 Copyright: 2019, Kovid Goyal - -from __future__ import absolute_import, division, print_function, unicode_literals - import bs4 from bs4 import ( # noqa CData, Comment, Declaration, NavigableString, ProcessingInstruction, diff --git a/ebook_converter/ebooks/chardet.py b/ebook_converter/ebooks/chardet.py index 9569476..d8f6085 100644 --- a/ebook_converter/ebooks/chardet.py +++ b/ebook_converter/ebooks/chardet.py @@ -1,14 +1,11 @@ -#!/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 +import re, codecs +from ebook_converter.polyglot.builtins import unicode_type + __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import re, codecs -from ebook_converter.polyglot.builtins import unicode_type - _encoding_pats = ( # XML declaration r'<\?[^<>]+encoding\s*=\s*[\'"](.*?)[\'"][^<>]*>', diff --git a/ebook_converter/ebooks/compression/palmdoc.py b/ebook_converter/ebooks/compression/palmdoc.py index 9ac216e..2373931 100644 --- a/ebook_converter/ebooks/compression/palmdoc.py +++ b/ebook_converter/ebooks/compression/palmdoc.py @@ -1,20 +1,12 @@ -#!/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__ = '2008, Kovid Goyal ' - import io from struct import pack -from ebook_converter.constants import plugins from ebook_converter.ebooks.compression import cPalmdoc from ebook_converter.polyglot.builtins import range -#cPalmdoc = plugins['cPalmdoc'][0] -#if not cPalmdoc: -# raise RuntimeError(('Failed to load required cPalmdoc module: ' -# '%s')%plugins['cPalmdoc'][1]) + + +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' def decompress_doc(data): diff --git a/ebook_converter/ebooks/conversion/__init__.py b/ebook_converter/ebooks/conversion/__init__.py index bc93edd..8bcec35 100644 --- a/ebook_converter/ebooks/conversion/__init__.py +++ b/ebook_converter/ebooks/conversion/__init__.py @@ -1,12 +1,10 @@ -# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai -from __future__ import absolute_import, division, print_function, unicode_literals +from ebook_converter.polyglot.builtins import native_string_type + __license__ = 'GPL v3' __copyright__ = '2011, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter.polyglot.builtins import native_string_type - class ConversionUserFeedBack(Exception): diff --git a/ebook_converter/ebooks/conversion/cli.py b/ebook_converter/ebooks/conversion/cli.py index fa898e1..d77957f 100644 --- a/ebook_converter/ebooks/conversion/cli.py +++ b/ebook_converter/ebooks/conversion/cli.py @@ -1,13 +1,6 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - -''' +""" Command line interface to conversion sub-system -''' - +""" import sys, os, numbers from optparse import OptionGroup, Option from collections import OrderedDict @@ -20,6 +13,11 @@ from ebook_converter.ebooks.conversion import ConversionUserFeedBack from ebook_converter.utils.localization import localize_user_manual_link from ebook_converter.polyglot.builtins import iteritems + +__license__ = 'GPL 3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + USAGE = '%prog ' + _('''\ input_file output_file [options] diff --git a/ebook_converter/ebooks/conversion/plugins/azw4_input.py b/ebook_converter/ebooks/conversion/plugins/azw4_input.py index 3d496e5..b71c610 100644 --- a/ebook_converter/ebooks/conversion/plugins/azw4_input.py +++ b/ebook_converter/ebooks/conversion/plugins/azw4_input.py @@ -1,13 +1,11 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +from ebook_converter.customize.conversion import InputFormatPlugin +from ebook_converter.polyglot.builtins import getcwd + __license__ = 'GPL v3' __copyright__ = '2011, John Schember ' __docformat__ = 'restructuredtext en' -from ebook_converter.customize.conversion import InputFormatPlugin -from ebook_converter.polyglot.builtins import getcwd - class AZW4Input(InputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/chm_input.py b/ebook_converter/ebooks/conversion/plugins/chm_input.py index 5c8ae70..0e58156 100644 --- a/ebook_converter/ebooks/conversion/plugins/chm_input.py +++ b/ebook_converter/ebooks/conversion/plugins/chm_input.py @@ -1,10 +1,6 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -''' CHM File decoding support ''' -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ,' \ - ' and Alex Bramley .' - +""" +CHM File decoding support +""" import os from ebook_converter.customize.conversion import InputFormatPlugin @@ -12,6 +8,10 @@ from ebook_converter.ptempfile import TemporaryDirectory from ebook_converter.constants import filesystem_encoding from ebook_converter.polyglot.builtins import unicode_type, as_bytes +__license__ = 'GPL v3' +__copyright__ = ('2008, Kovid Goyal , ' + 'and Alex Bramley .') + class CHMInput(InputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/comic_input.py b/ebook_converter/ebooks/conversion/plugins/comic_input.py index 335b53d..a424e80 100644 --- a/ebook_converter/ebooks/conversion/plugins/comic_input.py +++ b/ebook_converter/ebooks/conversion/plugins/comic_input.py @@ -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' - -''' +""" Based on ideas from comiclrf created by FangornUK. -''' - +""" import shutil, textwrap, codecs, os from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation @@ -16,6 +9,11 @@ from ebook_converter.ptempfile import PersistentTemporaryDirectory from ebook_converter.polyglot.builtins import getcwd, map +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' +__docformat__ = 'restructuredtext en' + + class ComicInput(InputFormatPlugin): name = 'Comic Input' diff --git a/ebook_converter/ebooks/conversion/plugins/djvu_input.py b/ebook_converter/ebooks/conversion/plugins/djvu_input.py index e40e0b7..3f9c261 100644 --- a/ebook_converter/ebooks/conversion/plugins/djvu_input.py +++ b/ebook_converter/ebooks/conversion/plugins/djvu_input.py @@ -1,11 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2011, Anthon van der Neut ' -__docformat__ = 'restructuredtext en' - import os from io import BytesIO @@ -13,6 +5,11 @@ from ebook_converter.customize.conversion import InputFormatPlugin from ebook_converter.polyglot.builtins import getcwd +__license__ = 'GPL 3' +__copyright__ = '2011, Anthon van der Neut ' +__docformat__ = 'restructuredtext en' + + class DJVUInput(InputFormatPlugin): name = 'DJVU Input' diff --git a/ebook_converter/ebooks/conversion/plugins/docx_input.py b/ebook_converter/ebooks/conversion/plugins/docx_input.py index 54283cb..5012a6e 100644 --- a/ebook_converter/ebooks/conversion/plugins/docx_input.py +++ b/ebook_converter/ebooks/conversion/plugins/docx_input.py @@ -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.customize.conversion import InputFormatPlugin, OptionRecommendation + __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' -from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation - class DOCXInput(InputFormatPlugin): name = 'DOCX Input' diff --git a/ebook_converter/ebooks/conversion/plugins/docx_output.py b/ebook_converter/ebooks/conversion/plugins/docx_output.py index 1a608f3..6ea0cf2 100644 --- a/ebook_converter/ebooks/conversion/plugins/docx_output.py +++ b/ebook_converter/ebooks/conversion/plugins/docx_output.py @@ -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.customize.conversion import OutputFormatPlugin, OptionRecommendation + __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' -from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation - PAGE_SIZES = ['a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'legal', 'letter'] diff --git a/ebook_converter/ebooks/conversion/plugins/epub_input.py b/ebook_converter/ebooks/conversion/plugins/epub_input.py index aeda324..0a3091e 100644 --- a/ebook_converter/ebooks/conversion/plugins/epub_input.py +++ b/ebook_converter/ebooks/conversion/plugins/epub_input.py @@ -1,15 +1,14 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import os, re, posixpath from itertools import cycle from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation from ebook_converter.polyglot.builtins import getcwd + +__license__ = 'GPL 3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + ADOBE_OBFUSCATION = 'http://ns.adobe.com/pdf/enc#RC' IDPF_OBFUSCATION = 'http://www.idpf.org/2008/embedding' diff --git a/ebook_converter/ebooks/conversion/plugins/epub_output.py b/ebook_converter/ebooks/conversion/plugins/epub_output.py index e2407f6..47f8f6b 100644 --- a/ebook_converter/ebooks/conversion/plugins/epub_output.py +++ b/ebook_converter/ebooks/conversion/plugins/epub_output.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import os, shutil, re from ebook_converter.customize.conversion import (OutputFormatPlugin, @@ -14,6 +6,11 @@ from ebook_converter.ptempfile import TemporaryDirectory from ebook_converter import CurrentDir from ebook_converter.polyglot.builtins import unicode_type, filter, map, zip, range, as_bytes + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + block_level_tags = ( 'address', 'body', diff --git a/ebook_converter/ebooks/conversion/plugins/fb2_input.py b/ebook_converter/ebooks/conversion/plugins/fb2_input.py index 2e108ef..ad2dead 100644 --- a/ebook_converter/ebooks/conversion/plugins/fb2_input.py +++ b/ebook_converter/ebooks/conversion/plugins/fb2_input.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Anatoly Shipitsin ' """ Convert .fb2 files to .lrf """ @@ -12,6 +8,10 @@ from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecomm from ebook_converter import guess_type from ebook_converter.polyglot.builtins import iteritems, getcwd + +__license__ = 'GPL v3' +__copyright__ = '2008, Anatoly Shipitsin ' + FB2NS = 'http://www.gribuser.ru/xml/fictionbook/2.0' FB21NS = 'http://www.gribuser.ru/xml/fictionbook/2.1' diff --git a/ebook_converter/ebooks/conversion/plugins/fb2_output.py b/ebook_converter/ebooks/conversion/plugins/fb2_output.py index 5f8f91e..641f9ba 100644 --- a/ebook_converter/ebooks/conversion/plugins/fb2_output.py +++ b/ebook_converter/ebooks/conversion/plugins/fb2_output.py @@ -1,14 +1,12 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +import os + +from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation + __license__ = 'GPL 3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -import os - -from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation - class FB2Output(OutputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/html_input.py b/ebook_converter/ebooks/conversion/plugins/html_input.py index 6ba979c..9047673 100644 --- a/ebook_converter/ebooks/conversion/plugins/html_input.py +++ b/ebook_converter/ebooks/conversion/plugins/html_input.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import re, tempfile, os from functools import partial @@ -18,6 +10,11 @@ from ebook_converter.utils.imghdr import what from ebook_converter.polyglot.builtins import unicode_type, zip, getcwd, as_unicode +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + def sanitize_file_name(x): ans = re.sub(r'\s+', ' ', re.sub(r'[?&=;#]', '_', ascii_filename(x))).strip().rstrip('.') ans, ext = ans.rpartition('.')[::2] diff --git a/ebook_converter/ebooks/conversion/plugins/html_output.py b/ebook_converter/ebooks/conversion/plugins/html_output.py index d4eb1b8..8f2338a 100644 --- a/ebook_converter/ebooks/conversion/plugins/html_output.py +++ b/ebook_converter/ebooks/conversion/plugins/html_output.py @@ -1,9 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2010, Fabian Grassl ' -__docformat__ = 'restructuredtext en' - import os, re, shutil from os.path import dirname, abspath, relpath as _relpath, exists, basename import pkg_resources @@ -14,6 +8,11 @@ from ebook_converter.ptempfile import PersistentTemporaryDirectory from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL 3' +__copyright__ = '2010, Fabian Grassl ' +__docformat__ = 'restructuredtext en' + + def relpath(*args): return _relpath(*args).replace(os.sep, '/') diff --git a/ebook_converter/ebooks/conversion/plugins/htmlz_input.py b/ebook_converter/ebooks/conversion/plugins/htmlz_input.py index f0dfe1b..6c66201 100644 --- a/ebook_converter/ebooks/conversion/plugins/htmlz_input.py +++ b/ebook_converter/ebooks/conversion/plugins/htmlz_input.py @@ -1,11 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - - -__license__ = 'GPL 3' -__copyright__ = '2011, John Schember ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter import guess_type @@ -13,6 +5,11 @@ from ebook_converter.customize.conversion import InputFormatPlugin from ebook_converter.polyglot.builtins import getcwd +__license__ = 'GPL 3' +__copyright__ = '2011, John Schember ' +__docformat__ = 'restructuredtext en' + + class HTMLZInput(InputFormatPlugin): name = 'HTLZ Input' diff --git a/ebook_converter/ebooks/conversion/plugins/htmlz_output.py b/ebook_converter/ebooks/conversion/plugins/htmlz_output.py index 1ed11c9..a47e71d 100644 --- a/ebook_converter/ebooks/conversion/plugins/htmlz_output.py +++ b/ebook_converter/ebooks/conversion/plugins/htmlz_output.py @@ -1,11 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - - -__license__ = 'GPL 3' -__copyright__ = '2011, John Schember ' -__docformat__ = 'restructuredtext en' - import io import os @@ -15,6 +7,11 @@ from ebook_converter.ptempfile import TemporaryDirectory from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL 3' +__copyright__ = '2011, John Schember ' +__docformat__ = 'restructuredtext en' + + class HTMLZOutput(OutputFormatPlugin): name = 'HTMLZ Output' diff --git a/ebook_converter/ebooks/conversion/plugins/lit_input.py b/ebook_converter/ebooks/conversion/plugins/lit_input.py index c424ea9..ec118bc 100644 --- a/ebook_converter/ebooks/conversion/plugins/lit_input.py +++ b/ebook_converter/ebooks/conversion/plugins/lit_input.py @@ -1,13 +1,10 @@ -#!/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 +from ebook_converter.customize.conversion import InputFormatPlugin + __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter.customize.conversion import InputFormatPlugin - class LITInput(InputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/lit_output.py b/ebook_converter/ebooks/conversion/plugins/lit_output.py index e4e6711..faea195 100644 --- a/ebook_converter/ebooks/conversion/plugins/lit_output.py +++ b/ebook_converter/ebooks/conversion/plugins/lit_output.py @@ -1,15 +1,11 @@ -#!/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 +from ebook_converter.customize.conversion import OutputFormatPlugin + __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter.customize.conversion import OutputFormatPlugin - - class LITOutput(OutputFormatPlugin): name = 'LIT Output' diff --git a/ebook_converter/ebooks/conversion/plugins/lrf_input.py b/ebook_converter/ebooks/conversion/plugins/lrf_input.py index 7f93995..02f4ef2 100644 --- a/ebook_converter/ebooks/conversion/plugins/lrf_input.py +++ b/ebook_converter/ebooks/conversion/plugins/lrf_input.py @@ -1,17 +1,14 @@ -#!/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 ' -__docformat__ = 'restructuredtext en' - import os, sys import pkg_resources from ebook_converter.customize.conversion import InputFormatPlugin +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class LRFInput(InputFormatPlugin): name = 'LRF Input' diff --git a/ebook_converter/ebooks/conversion/plugins/lrf_output.py b/ebook_converter/ebooks/conversion/plugins/lrf_output.py index 230d250..bf971aa 100644 --- a/ebook_converter/ebooks/conversion/plugins/lrf_output.py +++ b/ebook_converter/ebooks/conversion/plugins/lrf_output.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import sys, os from ebook_converter.customize.conversion import OutputFormatPlugin @@ -13,6 +5,11 @@ from ebook_converter.customize.conversion import OptionRecommendation from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class LRFOptions(object): def __init__(self, output, opts, oeb): diff --git a/ebook_converter/ebooks/conversion/plugins/mobi_input.py b/ebook_converter/ebooks/conversion/plugins/mobi_input.py index a84f5e7..16145bc 100644 --- a/ebook_converter/ebooks/conversion/plugins/mobi_input.py +++ b/ebook_converter/ebooks/conversion/plugins/mobi_input.py @@ -1,15 +1,14 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter.customize.conversion import InputFormatPlugin from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL 3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class MOBIInput(InputFormatPlugin): name = 'MOBI Input' diff --git a/ebook_converter/ebooks/conversion/plugins/mobi_output.py b/ebook_converter/ebooks/conversion/plugins/mobi_output.py index 5fbb6e0..8ee9ea6 100644 --- a/ebook_converter/ebooks/conversion/plugins/mobi_output.py +++ b/ebook_converter/ebooks/conversion/plugins/mobi_output.py @@ -1,15 +1,12 @@ -#!/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 +from ebook_converter.customize.conversion import (OutputFormatPlugin, + OptionRecommendation) +from ebook_converter.polyglot.builtins import unicode_type + __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter.customize.conversion import (OutputFormatPlugin, - OptionRecommendation) -from ebook_converter.polyglot.builtins import unicode_type - def remove_html_cover(oeb, log): from ebook_converter.ebooks.oeb.base import OEB_DOCS diff --git a/ebook_converter/ebooks/conversion/plugins/odt_input.py b/ebook_converter/ebooks/conversion/plugins/odt_input.py index 8c9d791..049b215 100644 --- a/ebook_converter/ebooks/conversion/plugins/odt_input.py +++ b/ebook_converter/ebooks/conversion/plugins/odt_input.py @@ -1,15 +1,13 @@ -from __future__ import absolute_import, division, print_function, unicode_literals +""" +Convert an ODT file into a Open Ebook +""" +from ebook_converter.customize.conversion import InputFormatPlugin + __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' -''' -Convert an ODT file into a Open Ebook -''' - -from ebook_converter.customize.conversion import InputFormatPlugin - class ODTInput(InputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/oeb_output.py b/ebook_converter/ebooks/conversion/plugins/oeb_output.py index 0b012c9..27ac5d8 100644 --- a/ebook_converter/ebooks/conversion/plugins/oeb_output.py +++ b/ebook_converter/ebooks/conversion/plugins/oeb_output.py @@ -1,9 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import os, re @@ -12,6 +6,11 @@ from ebook_converter.customize.conversion import (OutputFormatPlugin, from ebook_converter import CurrentDir +__license__ = 'GPL 3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class OEBOutput(OutputFormatPlugin): name = 'OEB Output' diff --git a/ebook_converter/ebooks/conversion/plugins/pdb_input.py b/ebook_converter/ebooks/conversion/plugins/pdb_input.py index eff0eb3..05c9f8f 100644 --- a/ebook_converter/ebooks/conversion/plugins/pdb_input.py +++ b/ebook_converter/ebooks/conversion/plugins/pdb_input.py @@ -1,13 +1,11 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +from ebook_converter.customize.conversion import InputFormatPlugin +from ebook_converter.polyglot.builtins import getcwd + __license__ = 'GPL v3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -from ebook_converter.customize.conversion import InputFormatPlugin -from ebook_converter.polyglot.builtins import getcwd - class PDBInput(InputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/pdb_output.py b/ebook_converter/ebooks/conversion/plugins/pdb_output.py index 3b423a3..dee027a 100644 --- a/ebook_converter/ebooks/conversion/plugins/pdb_output.py +++ b/ebook_converter/ebooks/conversion/plugins/pdb_output.py @@ -1,10 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter.customize.conversion import OutputFormatPlugin, \ @@ -12,6 +5,11 @@ from ebook_converter.customize.conversion import OutputFormatPlugin, \ from ebook_converter.ebooks.pdb import PDBError, get_writer, ALL_FORMAT_WRITERS +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class PDBOutput(OutputFormatPlugin): name = 'PDB Output' diff --git a/ebook_converter/ebooks/conversion/plugins/pdf_input.py b/ebook_converter/ebooks/conversion/plugins/pdf_input.py index 558abde..51f57c8 100644 --- a/ebook_converter/ebooks/conversion/plugins/pdf_input.py +++ b/ebook_converter/ebooks/conversion/plugins/pdf_input.py @@ -1,16 +1,14 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation from ebook_converter.polyglot.builtins import as_bytes, getcwd +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class PDFInput(InputFormatPlugin): name = 'PDF Input' diff --git a/ebook_converter/ebooks/conversion/plugins/pdf_output.py b/ebook_converter/ebooks/conversion/plugins/pdf_output.py index ec08ede..bf24a8d 100644 --- a/ebook_converter/ebooks/conversion/plugins/pdf_output.py +++ b/ebook_converter/ebooks/conversion/plugins/pdf_output.py @@ -1,14 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2012, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - -''' +""" Convert OEB ebook format to PDF. -''' - +""" import glob, os from ebook_converter.customize.conversion import (OutputFormatPlugin, @@ -16,6 +8,11 @@ from ebook_converter.customize.conversion import (OutputFormatPlugin, from ebook_converter.ptempfile import TemporaryDirectory from ebook_converter.polyglot.builtins import iteritems, unicode_type + +__license__ = 'GPL 3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + UNITS = ('millimeter', 'centimeter', 'point', 'inch' , 'pica' , 'didot', 'cicero', 'devicepixel') diff --git a/ebook_converter/ebooks/conversion/plugins/pml_input.py b/ebook_converter/ebooks/conversion/plugins/pml_input.py index 4384911..a8a8ed5 100644 --- a/ebook_converter/ebooks/conversion/plugins/pml_input.py +++ b/ebook_converter/ebooks/conversion/plugins/pml_input.py @@ -1,10 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - import glob import os import shutil @@ -14,6 +7,11 @@ from ebook_converter.ptempfile import TemporaryDirectory from ebook_converter.polyglot.builtins import getcwd +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class PMLInput(InputFormatPlugin): name = 'PML Input' diff --git a/ebook_converter/ebooks/conversion/plugins/pml_output.py b/ebook_converter/ebooks/conversion/plugins/pml_output.py index 798122e..022c5b1 100644 --- a/ebook_converter/ebooks/conversion/plugins/pml_output.py +++ b/ebook_converter/ebooks/conversion/plugins/pml_output.py @@ -1,10 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - import os, io from ebook_converter.customize.conversion import (OutputFormatPlugin, @@ -13,6 +6,11 @@ from ebook_converter.ptempfile import TemporaryDirectory from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class PMLOutput(OutputFormatPlugin): name = 'PML Output' diff --git a/ebook_converter/ebooks/conversion/plugins/rb_input.py b/ebook_converter/ebooks/conversion/plugins/rb_input.py index c541eac..24b96f2 100644 --- a/ebook_converter/ebooks/conversion/plugins/rb_input.py +++ b/ebook_converter/ebooks/conversion/plugins/rb_input.py @@ -1,15 +1,12 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +from ebook_converter.customize.conversion import InputFormatPlugin +from ebook_converter.polyglot.builtins import getcwd + __license__ = 'GPL 3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -from ebook_converter.customize.conversion import InputFormatPlugin -from ebook_converter.polyglot.builtins import getcwd - - class RBInput(InputFormatPlugin): name = 'RB Input' diff --git a/ebook_converter/ebooks/conversion/plugins/rb_output.py b/ebook_converter/ebooks/conversion/plugins/rb_output.py index be8f935..d988df7 100644 --- a/ebook_converter/ebooks/conversion/plugins/rb_output.py +++ b/ebook_converter/ebooks/conversion/plugins/rb_output.py @@ -1,14 +1,12 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +import os + +from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation + __license__ = 'GPL 3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -import os - -from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation - class RBOutput(OutputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/recipe_input.py b/ebook_converter/ebooks/conversion/plugins/recipe_input.py index ae78dd0..757a52d 100644 --- a/ebook_converter/ebooks/conversion/plugins/recipe_input.py +++ b/ebook_converter/ebooks/conversion/plugins/recipe_input.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation @@ -14,6 +6,11 @@ from ebook_converter import walk from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class RecipeDisabled(Exception): pass diff --git a/ebook_converter/ebooks/conversion/plugins/rtf_input.py b/ebook_converter/ebooks/conversion/plugins/rtf_input.py index c26a917..f68fb90 100644 --- a/ebook_converter/ebooks/conversion/plugins/rtf_input.py +++ b/ebook_converter/ebooks/conversion/plugins/rtf_input.py @@ -1,13 +1,12 @@ -from __future__ import with_statement, unicode_literals -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' - import os, glob, re, textwrap import pkg_resources from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation from ebook_converter.polyglot.builtins import iteritems, filter, getcwd, as_bytes +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + border_style_map = { 'single' : 'solid', 'double-thickness-border' : 'double', diff --git a/ebook_converter/ebooks/conversion/plugins/rtf_output.py b/ebook_converter/ebooks/conversion/plugins/rtf_output.py index c2079ad..89a94c1 100644 --- a/ebook_converter/ebooks/conversion/plugins/rtf_output.py +++ b/ebook_converter/ebooks/conversion/plugins/rtf_output.py @@ -1,14 +1,12 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +import os + +from ebook_converter.customize.conversion import OutputFormatPlugin + __license__ = 'GPL 3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -import os - -from ebook_converter.customize.conversion import OutputFormatPlugin - class RTFOutput(OutputFormatPlugin): diff --git a/ebook_converter/ebooks/conversion/plugins/snb_input.py b/ebook_converter/ebooks/conversion/plugins/snb_input.py index 8c44eac..b151cb2 100644 --- a/ebook_converter/ebooks/conversion/plugins/snb_input.py +++ b/ebook_converter/ebooks/conversion/plugins/snb_input.py @@ -1,10 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2010, Li Fanxi ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter.customize.conversion import InputFormatPlugin @@ -12,6 +5,11 @@ from ebook_converter.ptempfile import TemporaryDirectory from ebook_converter.utils.filenames import ascii_filename from ebook_converter.polyglot.builtins import unicode_type + +__license__ = 'GPL 3' +__copyright__ = '2010, Li Fanxi ' +__docformat__ = 'restructuredtext en' + HTML_TEMPLATE = '%s\n%s\n' diff --git a/ebook_converter/ebooks/conversion/plugins/snb_output.py b/ebook_converter/ebooks/conversion/plugins/snb_output.py index 7abef66..bda81f8 100644 --- a/ebook_converter/ebooks/conversion/plugins/snb_output.py +++ b/ebook_converter/ebooks/conversion/plugins/snb_output.py @@ -1,10 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2010, Li Fanxi ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation @@ -13,6 +6,11 @@ from ebook_converter.constants import __appname__, __version__ from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL 3' +__copyright__ = '2010, Li Fanxi ' +__docformat__ = 'restructuredtext en' + + class SNBOutput(OutputFormatPlugin): name = 'SNB Output' diff --git a/ebook_converter/ebooks/conversion/plugins/tcr_input.py b/ebook_converter/ebooks/conversion/plugins/tcr_input.py index 3f1ef11..3aabc9c 100644 --- a/ebook_converter/ebooks/conversion/plugins/tcr_input.py +++ b/ebook_converter/ebooks/conversion/plugins/tcr_input.py @@ -1,15 +1,14 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' from io import BytesIO from ebook_converter.customize.conversion import InputFormatPlugin +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class TCRInput(InputFormatPlugin): name = 'TCR Input' diff --git a/ebook_converter/ebooks/conversion/plugins/tcr_output.py b/ebook_converter/ebooks/conversion/plugins/tcr_output.py index 56759f2..bc83785 100644 --- a/ebook_converter/ebooks/conversion/plugins/tcr_output.py +++ b/ebook_converter/ebooks/conversion/plugins/tcr_output.py @@ -1,16 +1,14 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter.customize.conversion import OutputFormatPlugin, \ OptionRecommendation +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class TCROutput(OutputFormatPlugin): name = 'TCR Output' diff --git a/ebook_converter/ebooks/conversion/plugins/txt_input.py b/ebook_converter/ebooks/conversion/plugins/txt_input.py index 579bcb1..8161221 100644 --- a/ebook_converter/ebooks/conversion/plugins/txt_input.py +++ b/ebook_converter/ebooks/conversion/plugins/txt_input.py @@ -1,16 +1,14 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - import os from ebook_converter import _ent_pat, walk, xml_entity_to_unicode from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation from ebook_converter.polyglot.builtins import getcwd + +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + MD_EXTENSIONS = { 'abbr': _('Abbreviations'), 'admonition': _('Support admonitions'), diff --git a/ebook_converter/ebooks/conversion/plugins/txt_output.py b/ebook_converter/ebooks/conversion/plugins/txt_output.py index 07ea689..6e73359 100644 --- a/ebook_converter/ebooks/conversion/plugins/txt_output.py +++ b/ebook_converter/ebooks/conversion/plugins/txt_output.py @@ -1,18 +1,15 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - import os import shutil - from ebook_converter.customize.conversion import OutputFormatPlugin, \ OptionRecommendation from ebook_converter.ptempfile import TemporaryDirectory, TemporaryFile + +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + NEWLINE_TYPES = ['system', 'unix', 'old_mac', 'windows'] diff --git a/ebook_converter/ebooks/conversion/plumber.py b/ebook_converter/ebooks/conversion/plumber.py index a11d2cb..c2d6a57 100644 --- a/ebook_converter/ebooks/conversion/plumber.py +++ b/ebook_converter/ebooks/conversion/plumber.py @@ -1,10 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import os, re, sys, shutil, pprint, json from functools import partial @@ -22,6 +15,11 @@ from ebook_converter import (extract, walk, isbytestring, filesystem_encoding, from ebook_converter.constants import __version__ from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, map + +__license__ = 'GPL 3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + DEBUG_README=b''' This debug directory contains snapshots of the e-book as it passes through the various stages of conversion. The stages are: diff --git a/ebook_converter/ebooks/conversion/preprocess.py b/ebook_converter/ebooks/conversion/preprocess.py index eab5560..7356d80 100644 --- a/ebook_converter/ebooks/conversion/preprocess.py +++ b/ebook_converter/ebooks/conversion/preprocess.py @@ -1,17 +1,14 @@ -#!/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 ' -__docformat__ = 'restructuredtext en' - import functools, re, json from math import ceil from ebook_converter import entity_to_unicode, as_unicode from ebook_converter.polyglot.builtins import unicode_type, range + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + XMLDECL_RE = re.compile(r'^\s*<[?]xml.*?[?]>') SVG_NS = 'http://www.w3.org/2000/svg' XLINK_NS = 'http://www.w3.org/1999/xlink' diff --git a/ebook_converter/ebooks/conversion/utils.py b/ebook_converter/ebooks/conversion/utils.py index 79a725d..14dda4f 100644 --- a/ebook_converter/ebooks/conversion/utils.py +++ b/ebook_converter/ebooks/conversion/utils.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import re from math import ceil from ebook_converter.ebooks.conversion.preprocess import DocAnalysis, Dehyphenator @@ -14,6 +6,11 @@ from ebook_converter.utils.wordcount import get_wordcount_obj from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL v3' +__copyright__ = '2010, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class HeuristicProcessor(object): def __init__(self, extra_opts=None, log=None): diff --git a/ebook_converter/ebooks/covers.py b/ebook_converter/ebooks/covers.py index 95f490d..f7eac3a 100644 --- a/ebook_converter/ebooks/covers.py +++ b/ebook_converter/ebooks/covers.py @@ -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 ' - import re, random, unicodedata, numbers from collections import namedtuple from contextlib import contextmanager @@ -27,6 +20,10 @@ from ebook_converter.gui2 import ensure_app, config, load_builtin_fonts, pixmap_ from ebook_converter.utils.cleantext import clean_ascii_chars, clean_xml_chars from ebook_converter.utils.config import JSONConfig + +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + # Default settings {{{ cprefs = JSONConfig('cover_generation') cprefs.defaults['title_font_size'] = 120 # px diff --git a/ebook_converter/ebooks/docx/__init__.py b/ebook_converter/ebooks/docx/__init__.py index 038376a..353d37e 100644 --- a/ebook_converter/ebooks/docx/__init__.py +++ b/ebook_converter/ebooks/docx/__init__.py @@ -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 ' class InvalidDOCX(ValueError): pass - diff --git a/ebook_converter/ebooks/docx/block_styles.py b/ebook_converter/ebooks/docx/block_styles.py index 00473e8..e7e2ba1 100644 --- a/ebook_converter/ebooks/docx/block_styles.py +++ b/ebook_converter/ebooks/docx/block_styles.py @@ -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 ' - import numbers from collections import OrderedDict from ebook_converter.polyglot.builtins import iteritems +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' + + class Inherit(object): def __eq__(self, other): diff --git a/ebook_converter/ebooks/docx/char_styles.py b/ebook_converter/ebooks/docx/char_styles.py index 1727f34..d8fba0d 100644 --- a/ebook_converter/ebooks/docx/char_styles.py +++ b/ebook_converter/ebooks/docx/char_styles.py @@ -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 ' - 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 ' + # Read from XML {{{ diff --git a/ebook_converter/ebooks/docx/cleanup.py b/ebook_converter/ebooks/docx/cleanup.py index 671683d..f4779c7 100644 --- a/ebook_converter/ebooks/docx/cleanup.py +++ b/ebook_converter/ebooks/docx/cleanup.py @@ -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 ' -import os -from ebook_converter.polyglot.builtins import itervalues, range - NBSP = '\xa0' diff --git a/ebook_converter/ebooks/docx/container.py b/ebook_converter/ebooks/docx/container.py index bfa707a..4f18b7e 100644 --- a/ebook_converter/ebooks/docx/container.py +++ b/ebook_converter/ebooks/docx/container.py @@ -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 ' - 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 ' + + def fromstring(raw, parser=None): return safe_xml_fromstring(raw) diff --git a/ebook_converter/ebooks/docx/fields.py b/ebook_converter/ebooks/docx/fields.py index 3e2bd33..99d7e93 100644 --- a/ebook_converter/ebooks/docx/fields.py +++ b/ebook_converter/ebooks/docx/fields.py @@ -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 ' - 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 ' + + class Field(object): def __init__(self, start): diff --git a/ebook_converter/ebooks/docx/fonts.py b/ebook_converter/ebooks/docx/fonts.py index 1352a64..ee6f0e9 100644 --- a/ebook_converter/ebooks/docx/fonts.py +++ b/ebook_converter/ebooks/docx/fonts.py @@ -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 ' - 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 ' + Embed = namedtuple('Embed', 'name key subsetted') diff --git a/ebook_converter/ebooks/docx/footnotes.py b/ebook_converter/ebooks/docx/footnotes.py index 286eefd..d0af450 100644 --- a/ebook_converter/ebooks/docx/footnotes.py +++ b/ebook_converter/ebooks/docx/footnotes.py @@ -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 ' -from collections import OrderedDict -from ebook_converter.polyglot.builtins import iteritems, unicode_type - class Note(object): diff --git a/ebook_converter/ebooks/docx/images.py b/ebook_converter/ebooks/docx/images.py index 4cf346d..33514ca 100644 --- a/ebook_converter/ebooks/docx/images.py +++ b/ebook_converter/ebooks/docx/images.py @@ -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 ' - 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 ' + + class LinkedImageNotFound(ValueError): def __init__(self, fname): diff --git a/ebook_converter/ebooks/docx/index.py b/ebook_converter/ebooks/docx/index.py index a28723e..652c757 100644 --- a/ebook_converter/ebooks/docx/index.py +++ b/ebook_converter/ebooks/docx/index.py @@ -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 ' - 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 ' + + 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] diff --git a/ebook_converter/ebooks/docx/names.py b/ebook_converter/ebooks/docx/names.py index a0e2f1c..8455f7d 100644 --- a/ebook_converter/ebooks/docx/names.py +++ b/ebook_converter/ebooks/docx/names.py @@ -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 ' - 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 ' + # Names {{{ TRANSITIONAL_NAMES = { 'DOCUMENT' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', diff --git a/ebook_converter/ebooks/docx/numbering.py b/ebook_converter/ebooks/docx/numbering.py index 60dff17..966f67d 100644 --- a/ebook_converter/ebooks/docx/numbering.py +++ b/ebook_converter/ebooks/docx/numbering.py @@ -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 ' - 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 ' + STYLE_MAP = { 'aiueo': 'hiragana', 'aiueoFullWidth': 'hiragana', diff --git a/ebook_converter/ebooks/docx/settings.py b/ebook_converter/ebooks/docx/settings.py index e30fb54..e714821 100644 --- a/ebook_converter/ebooks/docx/settings.py +++ b/ebook_converter/ebooks/docx/settings.py @@ -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 ' diff --git a/ebook_converter/ebooks/docx/styles.py b/ebook_converter/ebooks/docx/styles.py index ce869fb..d7b909b 100644 --- a/ebook_converter/ebooks/docx/styles.py +++ b/ebook_converter/ebooks/docx/styles.py @@ -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 ' - 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 ' + + class PageProperties(object): ''' diff --git a/ebook_converter/ebooks/docx/tables.py b/ebook_converter/ebooks/docx/tables.py index 3360aab..54a32e8 100644 --- a/ebook_converter/ebooks/docx/tables.py +++ b/ebook_converter/ebooks/docx/tables.py @@ -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 ' - 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 ' + # Read from XML {{{ read_shd = rs edges = ('left', 'top', 'right', 'bottom') diff --git a/ebook_converter/ebooks/docx/theme.py b/ebook_converter/ebooks/docx/theme.py index c6f84b8..23363ed 100644 --- a/ebook_converter/ebooks/docx/theme.py +++ b/ebook_converter/ebooks/docx/theme.py @@ -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 ' diff --git a/ebook_converter/ebooks/docx/to_html.py b/ebook_converter/ebooks/docx/to_html.py index d4a80b3..4985dc5 100644 --- a/ebook_converter/ebooks/docx/to_html.py +++ b/ebook_converter/ebooks/docx/to_html.py @@ -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 ' - 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 ' + NBSP = '\xa0' diff --git a/ebook_converter/ebooks/docx/toc.py b/ebook_converter/ebooks/docx/toc.py index 41bf7ce..2e4fa89 100644 --- a/ebook_converter/ebooks/docx/toc.py +++ b/ebook_converter/ebooks/docx/toc.py @@ -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 ' - 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 ' + + def from_headings(body, log, namespace, num_levels=3): ' Create a TOC from headings in the document ' tocroot = TOC() diff --git a/ebook_converter/ebooks/docx/writer/container.py b/ebook_converter/ebooks/docx/writer/container.py index ba30e1d..1f062fb 100644 --- a/ebook_converter/ebooks/docx/writer/container.py +++ b/ebook_converter/ebooks/docx/writer/container.py @@ -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 ' - 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 ' + + def xml2str(root, pretty_print=False, with_tail=False): if hasattr(etree, 'cleanup_namespaces'): etree.cleanup_namespaces(root) diff --git a/ebook_converter/ebooks/docx/writer/fonts.py b/ebook_converter/ebooks/docx/writer/fonts.py index eb5ddaf..b4fc217 100644 --- a/ebook_converter/ebooks/docx/writer/fonts.py +++ b/ebook_converter/ebooks/docx/writer/fonts.py @@ -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 ' - 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 ' + + def obfuscate_font_data(data, key): prefix = bytearray(data[:32]) key = bytearray(reversed(key.bytes)) diff --git a/ebook_converter/ebooks/docx/writer/from_html.py b/ebook_converter/ebooks/docx/writer/from_html.py index 836a1e4..92254ab 100644 --- a/ebook_converter/ebooks/docx/writer/from_html.py +++ b/ebook_converter/ebooks/docx/writer/from_html.py @@ -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 ' - 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 ' + + 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)) diff --git a/ebook_converter/ebooks/docx/writer/images.py b/ebook_converter/ebooks/docx/writer/images.py index 46c878b..3488ff7 100644 --- a/ebook_converter/ebooks/docx/writer/images.py +++ b/ebook_converter/ebooks/docx/writer/images.py @@ -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 ' - 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 ' + Image = namedtuple('Image', 'rid fname width height fmt item') diff --git a/ebook_converter/ebooks/docx/writer/links.py b/ebook_converter/ebooks/docx/writer/links.py index aa6f12e..97b27c0 100644 --- a/ebook_converter/ebooks/docx/writer/links.py +++ b/ebook_converter/ebooks/docx/writer/links.py @@ -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 ' - 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 ' + + def start_text(tag, prefix_len=0, top_level=True): ans = tag.text or '' limit = 50 - prefix_len diff --git a/ebook_converter/ebooks/docx/writer/lists.py b/ebook_converter/ebooks/docx/writer/lists.py index aed443b..438ff35 100644 --- a/ebook_converter/ebooks/docx/writer/lists.py +++ b/ebook_converter/ebooks/docx/writer/lists.py @@ -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 ' - 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 ' + 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' diff --git a/ebook_converter/ebooks/docx/writer/styles.py b/ebook_converter/ebooks/docx/writer/styles.py index 22a8fd9..e171b83 100644 --- a/ebook_converter/ebooks/docx/writer/styles.py +++ b/ebook_converter/ebooks/docx/writer/styles.py @@ -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 ' - 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 ' + css_parser = CSS21Parser() border_edges = ('left', 'top', 'right', 'bottom') diff --git a/ebook_converter/ebooks/docx/writer/tables.py b/ebook_converter/ebooks/docx/writer/tables.py index 28d02d6..a4e3912 100644 --- a/ebook_converter/ebooks/docx/writer/tables.py +++ b/ebook_converter/ebooks/docx/writer/tables.py @@ -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 ' - 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 ' + + class Dummy(object): pass diff --git a/ebook_converter/ebooks/docx/writer/utils.py b/ebook_converter/ebooks/docx/writer/utils.py index fedae3b..9abd25a 100644 --- a/ebook_converter/ebooks/docx/writer/utils.py +++ b/ebook_converter/ebooks/docx/writer/utils.py @@ -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 ' -from ebook_converter.tinycss.color3 import parse_color_string - def int_or_zero(raw): try: diff --git a/ebook_converter/ebooks/epub/__init__.py b/ebook_converter/ebooks/epub/__init__.py index df450e5..1d60dc9 100644 --- a/ebook_converter/ebooks/epub/__init__.py +++ b/ebook_converter/ebooks/epub/__init__.py @@ -1,14 +1,13 @@ -from __future__ import absolute_import, division, print_function, unicode_literals +""" +Conversion to EPUB. +""" +from ebook_converter.utils.zipfile import ZipFile, ZIP_STORED + __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' -''' -Conversion to EPUB. -''' -from ebook_converter.utils.zipfile import ZipFile, ZIP_STORED - def rules(stylesheets): for s in stylesheets: diff --git a/ebook_converter/ebooks/fb2/__init__.py b/ebook_converter/ebooks/fb2/__init__.py index 5dfd502..f43d6b5 100644 --- a/ebook_converter/ebooks/fb2/__init__.py +++ b/ebook_converter/ebooks/fb2/__init__.py @@ -1,7 +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 ' __docformat__ = 'restructuredtext en' diff --git a/ebook_converter/ebooks/fb2/fb2ml.py b/ebook_converter/ebooks/fb2/fb2ml.py index edf5583..b163533 100644 --- a/ebook_converter/ebooks/fb2/fb2ml.py +++ b/ebook_converter/ebooks/fb2/fb2ml.py @@ -1,14 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - -''' +""" Transform OEB content into FB2 markup -''' - +""" import re, textwrap, uuid from datetime import datetime @@ -25,6 +17,11 @@ from ebook_converter.polyglot.binary import as_base64_unicode from ebook_converter.polyglot.urllib import urlparse +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class FB2MLizer(object): ''' Todo: * Include more FB2 specific tags in the conversion. diff --git a/ebook_converter/ebooks/html/input.py b/ebook_converter/ebooks/html/input.py index 5da56db..5bdad86 100644 --- a/ebook_converter/ebooks/html/input.py +++ b/ebook_converter/ebooks/html/input.py @@ -1,16 +1,6 @@ -#!/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 ' -__docformat__ = 'restructuredtext en' - - -''' +""" Input plugin for HTML or OPF ebooks. -''' - +""" import os, re, sys, errno as gerrno from ebook_converter.ebooks.oeb.base import urlunquote @@ -21,6 +11,11 @@ from ebook_converter.polyglot.builtins import is_py3, unicode_type from ebook_converter.polyglot.urllib import urlparse, urlunparse +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class Link(object): ''' diff --git a/ebook_converter/ebooks/html/to_zip.py b/ebook_converter/ebooks/html/to_zip.py index 0833893..ddbc8fb 100644 --- a/ebook_converter/ebooks/html/to_zip.py +++ b/ebook_converter/ebooks/html/to_zip.py @@ -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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import textwrap, os, glob from ebook_converter.customize import FileTypePlugin @@ -13,6 +5,11 @@ from ebook_converter.constants import numeric_version from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class HTML2ZIP(FileTypePlugin): name = 'HTML to ZIP' author = 'Kovid Goyal' diff --git a/ebook_converter/ebooks/html_entities.py b/ebook_converter/ebooks/html_entities.py index cc86a21..9fd67b1 100644 --- a/ebook_converter/ebooks/html_entities.py +++ b/ebook_converter/ebooks/html_entities.py @@ -1,8 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2017, Kovid Goyal -from __future__ import absolute_import, division, print_function, unicode_literals - html5_entities = { # ENTITY_DATA {{{ 'AElig': 'Æ', diff --git a/ebook_converter/ebooks/htmlz/oeb2html.py b/ebook_converter/ebooks/htmlz/oeb2html.py index d2aebe6..d7ad6dd 100644 --- a/ebook_converter/ebooks/htmlz/oeb2html.py +++ b/ebook_converter/ebooks/htmlz/oeb2html.py @@ -1,15 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - - -__license__ = 'GPL 3' -__copyright__ = '2011, John Schember ' -__docformat__ = 'restructuredtext en' - -''' +""" Transform OEB content into a single (more or less) HTML file. -''' - +""" import os import re @@ -24,6 +15,11 @@ from ebook_converter.utils.logging import default_log from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, as_bytes from ebook_converter.polyglot.urllib import urldefrag + +__license__ = 'GPL 3' +__copyright__ = '2011, John Schember ' +__docformat__ = 'restructuredtext en' + SELF_CLOSING_TAGS = {'area', 'base', 'basefont', 'br', 'hr', 'input', 'img', 'link', 'meta'} diff --git a/ebook_converter/ebooks/lrf/__init__.py b/ebook_converter/ebooks/lrf/__init__.py index 35ddeee..2d0a617 100644 --- a/ebook_converter/ebooks/lrf/__init__.py +++ b/ebook_converter/ebooks/lrf/__init__.py @@ -1,18 +1,17 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' """ This package contains logic to read and write LRF files. -The LRF file format is documented at U{http://www.sven.de/librie/Librie/LrfFormat}. +The LRF file format is documented at +http://www.sven.de/librie/Librie/LrfFormat. """ - from ebook_converter.ebooks.lrf.pylrs.pylrs import Book as _Book from ebook_converter.ebooks.lrf.pylrs.pylrs import TextBlock, Header, \ TextStyle, BlockStyle from ebook_converter.ebooks.lrf.fonts import FONT_FILE_MAP from ebook_converter.ebooks import ConversionError + +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' __docformat__ = "epytext" diff --git a/ebook_converter/ebooks/lrf/fonts.py b/ebook_converter/ebooks/lrf/fonts.py index 3fe2cd4..40b818d 100644 --- a/ebook_converter/ebooks/lrf/fonts.py +++ b/ebook_converter/ebooks/lrf/fonts.py @@ -1,16 +1,13 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' - +""" +Default fonts used in the PRS500 +""" from PIL import ImageFont from ebook_converter.utils.fonts.scanner import font_scanner -''' -Default fonts used in the PRS500 -''' +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' LIBERATION_FONT_MAP = {'Swis721 BT Roman': 'Liberation Sans Regular', 'Dutch801 Rm BT Roman': 'Liberation Serif Regular', diff --git a/ebook_converter/ebooks/lrf/html/color_map.py b/ebook_converter/ebooks/lrf/html/color_map.py index ce4af2d..7376d71 100644 --- a/ebook_converter/ebooks/lrf/html/color_map.py +++ b/ebook_converter/ebooks/lrf/html/color_map.py @@ -1,10 +1,9 @@ -from __future__ import absolute_import, division, print_function, unicode_literals +import re + __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' -import re - NAME_MAP = { 'aliceblue': '#F0F8FF', 'antiquewhite': '#FAEBD7', diff --git a/ebook_converter/ebooks/lrf/html/convert_from.py b/ebook_converter/ebooks/lrf/html/convert_from.py index 52fbf81..ff6b1dc 100644 --- a/ebook_converter/ebooks/lrf/html/convert_from.py +++ b/ebook_converter/ebooks/lrf/html/convert_from.py @@ -1,7 +1,11 @@ -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2008, Kovid Goyal -from __future__ import absolute_import, division, print_function, unicode_literals +""" +Code to convert HTML ebooks into LRF ebooks. +I am indebted to esperanc for the initial CSS->Xylog Style conversion code +and to Falstaff for pylrs. + +License: GPLv3 Copyright: 2008, Kovid Goyal +""" import copy import glob import os @@ -35,13 +39,6 @@ from ebook_converter.ptempfile import PersistentTemporaryFile from ebook_converter.polyglot.builtins import getcwd, itervalues, string_or_bytes, unicode_type from ebook_converter.polyglot.urllib import unquote, urlparse -""" -Code to convert HTML ebooks into LRF ebooks. - -I am indebted to esperanc for the initial CSS->Xylog Style conversion code -and to Falstaff for pylrs. -""" - from PIL import Image as PILImage diff --git a/ebook_converter/ebooks/lrf/html/table.py b/ebook_converter/ebooks/lrf/html/table.py index deb3759..a85a0d3 100644 --- a/ebook_converter/ebooks/lrf/html/table.py +++ b/ebook_converter/ebooks/lrf/html/table.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' import math, sys, re, numbers from ebook_converter.ebooks.lrf.fonts import get_font @@ -11,6 +7,10 @@ from ebook_converter.ebooks.lrf.pylrs.pylrs import TextBlock, Text, CR, Span, \ from ebook_converter.polyglot.builtins import string_or_bytes, range, native_string_type +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal ' + + def ceil(num): return int(math.ceil(num)) diff --git a/ebook_converter/ebooks/lrf/pylrs/__init__.py b/ebook_converter/ebooks/lrf/pylrs/__init__.py index 72b8c8d..e69de29 100644 --- a/ebook_converter/ebooks/lrf/pylrs/__init__.py +++ b/ebook_converter/ebooks/lrf/pylrs/__init__.py @@ -1,7 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -""" -This package contains code to generate ebooks in the SONY LRS/F format. It was -originally developed by Mike Higgins and has been extended and modified by Kovid -Goyal. -""" diff --git a/ebook_converter/ebooks/lrf/pylrs/elements.py b/ebook_converter/ebooks/lrf/pylrs/elements.py index 96ccb1e..f1d0085 100644 --- a/ebook_converter/ebooks/lrf/pylrs/elements.py +++ b/ebook_converter/ebooks/lrf/pylrs/elements.py @@ -1,7 +1,6 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -""" elements.py -- replacements and helpers for ElementTree """ - +""" +elements.py -- replacements and helpers for ElementTree +""" from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes diff --git a/ebook_converter/ebooks/lrf/pylrs/pylrf.py b/ebook_converter/ebooks/lrf/pylrs/pylrf.py index a8c12d2..f1f1ca9 100644 --- a/ebook_converter/ebooks/lrf/pylrs/pylrf.py +++ b/ebook_converter/ebooks/lrf/pylrs/pylrf.py @@ -1,9 +1,6 @@ -#!/usr/bin/env python2 -from __future__ import absolute_import, division, print_function, unicode_literals - """ - pylrf.py -- very low level interface to create lrf files. See pylrs for - higher level interface that can use this module to render books to lrf. +pylrf.py -- very low level interface to create lrf files. See pylrs for +higher level interface that can use this module to render books to lrf. """ import struct import zlib diff --git a/ebook_converter/ebooks/lrf/pylrs/pylrfopt.py b/ebook_converter/ebooks/lrf/pylrs/pylrfopt.py index b9a1e81..64648c5 100644 --- a/ebook_converter/ebooks/lrf/pylrs/pylrfopt.py +++ b/ebook_converter/ebooks/lrf/pylrs/pylrfopt.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - - def _optimize(tagList, tagName, conversion): # copy the tag of interest plus any text newTagList = [] diff --git a/ebook_converter/ebooks/lrf/pylrs/pylrs.py b/ebook_converter/ebooks/lrf/pylrs/pylrs.py index 2da754b..095ad0f 100644 --- a/ebook_converter/ebooks/lrf/pylrs/pylrs.py +++ b/ebook_converter/ebooks/lrf/pylrs/pylrs.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - # Copyright (c) 2007 Mike Higgins (Falstaff) # Modifications from the original: # Copyright (C) 2007 Kovid Goyal @@ -37,7 +35,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera # Other unsupported tags: PageDiv, SoundStop, Wait, pos, # Plot, Image (outside of ImageBlock), # EmpLine, EmpDots - import os, re, codecs, operator, io from xml.sax.saxutils import escape from datetime import date diff --git a/ebook_converter/ebooks/metadata/__init__.py b/ebook_converter/ebooks/metadata/__init__.py index a218924..ce22d37 100644 --- a/ebook_converter/ebooks/metadata/__init__.py +++ b/ebook_converter/ebooks/metadata/__init__.py @@ -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: diff --git a/ebook_converter/ebooks/metadata/archive.py b/ebook_converter/ebooks/metadata/archive.py index bffa84e..9dd82cc 100644 --- a/ebook_converter/ebooks/metadata/archive.py +++ b/ebook_converter/ebooks/metadata/archive.py @@ -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 ' -__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 ' +__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'} diff --git a/ebook_converter/ebooks/metadata/book/__init__.py b/ebook_converter/ebooks/metadata/book/__init__.py index 84e8039..a4a99fa 100644 --- a/ebook_converter/ebooks/metadata/book/__init__.py +++ b/ebook_converter/ebooks/metadata/book/__init__.py @@ -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 ' __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 diff --git a/ebook_converter/ebooks/metadata/book/base.py b/ebook_converter/ebooks/metadata/book/base.py index cb5c0bf..d44ada6 100644 --- a/ebook_converter/ebooks/metadata/book/base.py +++ b/ebook_converter/ebooks/metadata/book/base.py @@ -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 ' -__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 ' +__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) diff --git a/ebook_converter/ebooks/metadata/book/formatter.py b/ebook_converter/ebooks/metadata/book/formatter.py index 525e8f6..5a6776c 100644 --- a/ebook_converter/ebooks/metadata/book/formatter.py +++ b/ebook_converter/ebooks/metadata/book/formatter.py @@ -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 ' - 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 ' + + class SafeFormat(TemplateFormatter): def __init__(self): diff --git a/ebook_converter/ebooks/metadata/book/json_codec.py b/ebook_converter/ebooks/metadata/book/json_codec.py index a649fa5..fe4ed13 100644 --- a/ebook_converter/ebooks/metadata/book/json_codec.py +++ b/ebook_converter/ebooks/metadata/book/json_codec.py @@ -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 diff --git a/ebook_converter/ebooks/metadata/fb2.py b/ebook_converter/ebooks/metadata/fb2.py index 2b84668..670e5d1 100644 --- a/ebook_converter/ebooks/metadata/fb2.py +++ b/ebook_converter/ebooks/metadata/fb2.py @@ -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 , '\ - '2008, Anatoly Shipitsin ' -'''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 , ' + '2008, Anatoly Shipitsin ') + + NAMESPACES = { 'fb2' : 'http://www.gribuser.ru/xml/fictionbook/2.0', 'fb21' : 'http://www.gribuser.ru/xml/fictionbook/2.1', diff --git a/ebook_converter/ebooks/metadata/html.py b/ebook_converter/ebooks/metadata/html.py index 55db29c..fb8e3f0 100644 --- a/ebook_converter/ebooks/metadata/html.py +++ b/ebook_converter/ebooks/metadata/html.py @@ -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 ' -''' +""" 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 ' + + def get_metadata(stream): src = stream.read() return get_metadata_(src) diff --git a/ebook_converter/ebooks/metadata/meta.py b/ebook_converter/ebooks/metadata/meta.py index 15f14c9..3d913f5 100644 --- a/ebook_converter/ebooks/metadata/meta.py +++ b/ebook_converter/ebooks/metadata/meta.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' - 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 ' + # 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) diff --git a/ebook_converter/ebooks/metadata/odt.py b/ebook_converter/ebooks/metadata/odt.py index ab324f5..11388a3 100644 --- a/ebook_converter/ebooks/metadata/odt.py +++ b/ebook_converter/ebooks/metadata/odt.py @@ -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'), diff --git a/ebook_converter/ebooks/metadata/opf2.py b/ebook_converter/ebooks/metadata/opf2.py index 3fb8ed5..4b50903 100644 --- a/ebook_converter/ebooks/metadata/opf2.py +++ b/ebook_converter/ebooks/metadata/opf2.py @@ -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 diff --git a/ebook_converter/ebooks/metadata/opf3.py b/ebook_converter/ebooks/metadata/opf3.py index 5bdae96..f9f62dd 100644 --- a/ebook_converter/ebooks/metadata/opf3.py +++ b/ebook_converter/ebooks/metadata/opf3.py @@ -1,9 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2016, Kovid Goyal - -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 = {} diff --git a/ebook_converter/ebooks/metadata/pdf.py b/ebook_converter/ebooks/metadata/pdf.py index 1e92ef1..ad7de64 100644 --- a/ebook_converter/ebooks/metadata/pdf.py +++ b/ebook_converter/ebooks/metadata/pdf.py @@ -1,9 +1,6 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' -'''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 ' + + def get_tools(): from ebook_converter.ebooks.pdf.pdftohtml import PDFTOHTML base = os.path.dirname(PDFTOHTML) diff --git a/ebook_converter/ebooks/metadata/rtf.py b/ebook_converter/ebooks/metadata/rtf.py index 61118f3..a23f148 100644 --- a/ebook_converter/ebooks/metadata/rtf.py +++ b/ebook_converter/ebooks/metadata/rtf.py @@ -1,11 +1,6 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2008, Kovid Goyal - """ Edit metadata in RTF files. """ -from __future__ import absolute_import, division, print_function, unicode_literals import codecs import re diff --git a/ebook_converter/ebooks/metadata/toc.py b/ebook_converter/ebooks/metadata/toc.py index 2889aab..4ea54c4 100644 --- a/ebook_converter/ebooks/metadata/toc.py +++ b/ebook_converter/ebooks/metadata/toc.py @@ -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 ' - 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 ' + NCX_NS = "http://www.daisy.org/z3986/2005/ncx/" CALIBRE_NS = "http://calibre.kovidgoyal.net/2009/metadata" NSMAP = {None: NCX_NS, 'calibre':CALIBRE_NS} diff --git a/ebook_converter/ebooks/metadata/txt.py b/ebook_converter/ebooks/metadata/txt.py index 07b2a2a..7bedb26 100644 --- a/ebook_converter/ebooks/metadata/txt.py +++ b/ebook_converter/ebooks/metadata/txt.py @@ -1,18 +1,15 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' - -''' +""" Read meta information from TXT files -''' - +""" import re, os from ebook_converter.ebooks.metadata import MetaInformation +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' + + def get_metadata(stream, extract_cover=True): ''' Return metadata as a L{MetaInfo} object diff --git a/ebook_converter/ebooks/metadata/utils.py b/ebook_converter/ebooks/metadata/utils.py index 4288498..a814d38 100644 --- a/ebook_converter/ebooks/metadata/utils.py +++ b/ebook_converter/ebooks/metadata/utils.py @@ -1,9 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2016, Kovid Goyal - -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') diff --git a/ebook_converter/ebooks/metadata/xmp.py b/ebook_converter/ebooks/metadata/xmp.py index 20d4527..5e02c28 100644 --- a/ebook_converter/ebooks/metadata/xmp.py +++ b/ebook_converter/ebooks/metadata/xmp.py @@ -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 ' - 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 ' + _xml_declaration = re.compile(r'<\?xml[^<>]+encoding\s*=\s*[\'"](.*?)[\'"][^<>]*>', re.IGNORECASE) NS_MAP = { diff --git a/ebook_converter/ebooks/mobi/__init__.py b/ebook_converter/ebooks/mobi/__init__.py index bea6a17..b5dbb79 100644 --- a/ebook_converter/ebooks/mobi/__init__.py +++ b/ebook_converter/ebooks/mobi/__init__.py @@ -1,8 +1,4 @@ -#!/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' +__license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' @@ -10,6 +6,7 @@ class MobiError(Exception): pass -# That might be a bit small on the PW, but Amazon/KG 2.5 still uses these values, even when delivered to a PW +# That might be a bit small on the PW, but Amazon/KG 2.5 still uses these +# values, even when delivered to a PW MAX_THUMB_SIZE = 16 * 1024 MAX_THUMB_DIMEN = (180, 240) diff --git a/ebook_converter/ebooks/mobi/huffcdic.py b/ebook_converter/ebooks/mobi/huffcdic.py index b48f609..1f422d7 100644 --- a/ebook_converter/ebooks/mobi/huffcdic.py +++ b/ebook_converter/ebooks/mobi/huffcdic.py @@ -1,22 +1,18 @@ -#!/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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - -''' -Decompress MOBI files compressed with the Huff/cdic algorithm. Code thanks to darkninja -and igorsk. -''' - +""" +Decompress MOBI files compressed with the Huff/cdic algorithm. Code thanks to +darkninja and igorsk. +""" import struct from ebook_converter.ebooks.mobi import MobiError from ebook_converter.polyglot.builtins import map +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class Reader(object): def __init__(self): diff --git a/ebook_converter/ebooks/mobi/langcodes.py b/ebook_converter/ebooks/mobi/langcodes.py index 5f5a74e..7c1321d 100644 --- a/ebook_converter/ebooks/mobi/langcodes.py +++ b/ebook_converter/ebooks/mobi/langcodes.py @@ -1,13 +1,11 @@ -#!/usr/bin/env python2 -from __future__ import absolute_import, division, print_function, unicode_literals +from struct import pack +from ebook_converter.utils.localization import lang_as_iso639_1 + __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' -from struct import pack -from ebook_converter.utils.localization import lang_as_iso639_1 - lang_codes = { } diff --git a/ebook_converter/ebooks/mobi/mobiml.py b/ebook_converter/ebooks/mobi/mobiml.py index 93a2559..f7d7ea7 100644 --- a/ebook_converter/ebooks/mobi/mobiml.py +++ b/ebook_converter/ebooks/mobi/mobiml.py @@ -1,12 +1,6 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Transform XHTML/OPS-ish content into Mobipocket HTML 3.2. -''' - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" import copy import re import numbers @@ -19,6 +13,10 @@ from ebook_converter.ebooks.mobi.utils import convert_color_for_font_tag from ebook_converter.utils.imghdr import identify from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes + +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' + MBP_NS = 'http://mobipocket.com/ns/mbp' diff --git a/ebook_converter/ebooks/mobi/reader/containers.py b/ebook_converter/ebooks/mobi/reader/containers.py index 4462b11..1e6c7de 100644 --- a/ebook_converter/ebooks/mobi/reader/containers.py +++ b/ebook_converter/ebooks/mobi/reader/containers.py @@ -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__ = '2014, Kovid Goyal ' - from struct import unpack_from, error from ebook_converter.utils.imghdr import what +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + def find_imgtype(data): return what(None, data) or 'unknown' diff --git a/ebook_converter/ebooks/mobi/reader/headers.py b/ebook_converter/ebooks/mobi/reader/headers.py index ace9ddc..f04ad55 100644 --- a/ebook_converter/ebooks/mobi/reader/headers.py +++ b/ebook_converter/ebooks/mobi/reader/headers.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import struct, re, os from ebook_converter import replace_entities @@ -18,6 +10,11 @@ from ebook_converter.utils.localization import canonicalize_lang from ebook_converter.utils.config_base import tweaks from ebook_converter.polyglot.builtins import unicode_type + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + NULL_INDEX = 0xffffffff diff --git a/ebook_converter/ebooks/mobi/reader/index.py b/ebook_converter/ebooks/mobi/reader/index.py index 9a14538..4f2888f 100644 --- a/ebook_converter/ebooks/mobi/reader/index.py +++ b/ebook_converter/ebooks/mobi/reader/index.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import struct from collections import OrderedDict, namedtuple @@ -13,6 +5,11 @@ from ebook_converter.ebooks.mobi.utils import (decint, count_set_bits, decode_string) from ebook_converter.polyglot.builtins import iteritems, range, zip + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + TagX = namedtuple('TagX', 'tag num_of_values bitmask eof') PTagX = namedtuple('PTagX', 'tag value_count value_bytes num_of_values') INDEX_HEADER_FIELDS = ( diff --git a/ebook_converter/ebooks/mobi/reader/markup.py b/ebook_converter/ebooks/mobi/reader/markup.py index ca8fcf6..25857bd 100644 --- a/ebook_converter/ebooks/mobi/reader/markup.py +++ b/ebook_converter/ebooks/mobi/reader/markup.py @@ -1,17 +1,14 @@ -#!/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 ' -__docformat__ = 'restructuredtext en' - import re, os from ebook_converter.ebooks.chardet import strip_encoding_declarations from ebook_converter.polyglot.builtins import unicode_type, range +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + def update_internal_links(mobi8_reader, log): # need to update all links that are internal which # are based on positions within the xhtml files **BEFORE** diff --git a/ebook_converter/ebooks/mobi/reader/mobi6.py b/ebook_converter/ebooks/mobi/reader/mobi6.py index 15d0cf6..250e9ba 100644 --- a/ebook_converter/ebooks/mobi/reader/mobi6.py +++ b/ebook_converter/ebooks/mobi/reader/mobi6.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import shutil, os, re, struct, textwrap, io import logging @@ -27,6 +19,11 @@ from ebook_converter.utils.imghdr import what from ebook_converter.polyglot.builtins import iteritems, unicode_type, range, map +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class TopazError(ValueError): pass diff --git a/ebook_converter/ebooks/mobi/reader/mobi8.py b/ebook_converter/ebooks/mobi/reader/mobi8.py index ad4cca1..8f2753d 100644 --- a/ebook_converter/ebooks/mobi/reader/mobi8.py +++ b/ebook_converter/ebooks/mobi/reader/mobi8.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import struct, re, os from collections import namedtuple from itertools import repeat @@ -26,6 +18,11 @@ from ebook_converter.ebooks.oeb.base import XPath, XHTML, xml2text from ebook_converter.polyglot.builtins import range, zip, unicode_type, getcwd, as_unicode from ebook_converter.polyglot.urllib import urldefrag + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + Part = namedtuple('Part', 'num type filename start end aid') diff --git a/ebook_converter/ebooks/mobi/reader/ncx.py b/ebook_converter/ebooks/mobi/reader/ncx.py index 83cacb3..7252dee 100644 --- a/ebook_converter/ebooks/mobi/reader/ncx.py +++ b/ebook_converter/ebooks/mobi/reader/ncx.py @@ -1,17 +1,14 @@ -#!/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 ' -__docformat__ = 'restructuredtext en' - from ebook_converter import replace_entities from ebook_converter.ebooks.metadata.toc import TOC from ebook_converter.ebooks.mobi.reader.headers import NULL_INDEX from ebook_converter.ebooks.mobi.reader.index import read_index from ebook_converter.polyglot.builtins import iteritems, getcwd + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + tag_fieldname_map = { 1: ['pos',0], 2: ['len',0], diff --git a/ebook_converter/ebooks/mobi/tweak.py b/ebook_converter/ebooks/mobi/tweak.py index 5e27af7..9f671d4 100644 --- a/ebook_converter/ebooks/mobi/tweak.py +++ b/ebook_converter/ebooks/mobi/tweak.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import os, glob from ebook_converter import CurrentDir @@ -21,6 +13,11 @@ from ebook_converter.customize.ui import (plugin_for_input_format, from ebook_converter.utils.ipc.simple_worker import fork_job +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class BadFormat(ValueError): pass diff --git a/ebook_converter/ebooks/mobi/utils.py b/ebook_converter/ebooks/mobi/utils.py index 4b08a91..63d8e7c 100644 --- a/ebook_converter/ebooks/mobi/utils.py +++ b/ebook_converter/ebooks/mobi/utils.py @@ -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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import struct, string, zlib, os from collections import OrderedDict from io import BytesIO @@ -16,6 +8,11 @@ from ebook_converter.ebooks import normalize from ebook_converter.polyglot.builtins import unicode_type, range, as_bytes, map from ebook_converter.tinycss.color3 import parse_color_string + +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + IMAGE_MAX_SIZE = 10 * 1024 * 1024 RECORD_SIZE = 0x1000 # 4096 (Text record size (uncompressed)) diff --git a/ebook_converter/ebooks/mobi/writer2/__init__.py b/ebook_converter/ebooks/mobi/writer2/__init__.py index 3a2b08b..caa80c9 100644 --- a/ebook_converter/ebooks/mobi/writer2/__init__.py +++ b/ebook_converter/ebooks/mobi/writer2/__init__.py @@ -1,14 +1,8 @@ -#!/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' +__license__ = 'GPL v3' __copyright__ = '2011, Kovid Goyal ' __docformat__ = 'restructuredtext en' - UNCOMPRESSED = 1 PALMDOC = 2 HUFFDIC = 17480 PALM_MAX_IMAGE_SIZE = 63 * 1024 - diff --git a/ebook_converter/ebooks/mobi/writer2/indexer.py b/ebook_converter/ebooks/mobi/writer2/indexer.py index 6fd397a..8bb4fb5 100644 --- a/ebook_converter/ebooks/mobi/writer2/indexer.py +++ b/ebook_converter/ebooks/mobi/writer2/indexer.py @@ -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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import numbers from struct import pack import io @@ -16,6 +8,11 @@ from ebook_converter.ebooks.mobi.utils import (encint, encode_number_as_hex, from ebook_converter.polyglot.builtins import filter, iteritems, itervalues, map, range +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class CNCX(CNCX_): # {{{ def __init__(self, toc, is_periodical): diff --git a/ebook_converter/ebooks/mobi/writer2/main.py b/ebook_converter/ebooks/mobi/writer2/main.py index 9d5b429..c8e1f7b 100644 --- a/ebook_converter/ebooks/mobi/writer2/main.py +++ b/ebook_converter/ebooks/mobi/writer2/main.py @@ -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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import io, random, time from struct import pack @@ -20,6 +12,11 @@ from ebook_converter.ebooks.mobi.utils import (encint, encode_trailing_data, from ebook_converter.ebooks.mobi.writer2.indexer import Indexer from ebook_converter.polyglot.builtins import iteritems, unicode_type, range + +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + # Disabled as I dont care about uncrossable breaks WRITE_UNCROSSABLE_BREAKS = False NULL_INDEX = 0xffffffff diff --git a/ebook_converter/ebooks/mobi/writer2/resources.py b/ebook_converter/ebooks/mobi/writer2/resources.py index c569a1f..40c3fa7 100644 --- a/ebook_converter/ebooks/mobi/writer2/resources.py +++ b/ebook_converter/ebooks/mobi/writer2/resources.py @@ -1,10 +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 ' -__docformat__ = 'restructuredtext en' import os @@ -17,7 +10,15 @@ from ebook_converter.ptempfile import PersistentTemporaryFile from ebook_converter.utils.imghdr import what from ebook_converter.polyglot.builtins import iteritems, unicode_type -PLACEHOLDER_GIF = b'GIF89a\x01\x00\x01\x00\xf0\x00\x00\x00\x00\x00\xff\xff\xff!\xf9\x04\x01\x00\x00\x00\x00!\xfe calibre-placeholder-gif-for-azw3\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;' # noqa + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +PLACEHOLDER_GIF = (b'GIF89a\x01\x00\x01\x00\xf0\x00\x00\x00\x00\x00\xff\xff' + b'\xff!\xf9\x04\x01\x00\x00\x00\x00!\xfe calibre-placeho' + b'lder-gif-for-azw3\x00,\x00\x00\x00\x00\x01\x00\x01\x00' + b'\x00\x02\x02D\x01\x00;') class Resources(object): diff --git a/ebook_converter/ebooks/mobi/writer2/serializer.py b/ebook_converter/ebooks/mobi/writer2/serializer.py index f78ca5d..9390c48 100644 --- a/ebook_converter/ebooks/mobi/writer2/serializer.py +++ b/ebook_converter/ebooks/mobi/writer2/serializer.py @@ -1,12 +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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - - import re import unicodedata from collections import defaultdict @@ -21,6 +12,11 @@ from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes from ebook_converter.polyglot.urllib import urldefrag +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class Buf(BytesIO): def write(self, x): diff --git a/ebook_converter/ebooks/mobi/writer8/cleanup.py b/ebook_converter/ebooks/mobi/writer8/cleanup.py index bd3a00d..369cfc7 100644 --- a/ebook_converter/ebooks/mobi/writer8/cleanup.py +++ b/ebook_converter/ebooks/mobi/writer8/cleanup.py @@ -1,13 +1,10 @@ -#!/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 +from ebook_converter.ebooks.oeb.base import XPath + __license__ = 'GPL v3' __copyright__ = '2012, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter.ebooks.oeb.base import XPath - class CSSCleanup(object): diff --git a/ebook_converter/ebooks/mobi/writer8/exth.py b/ebook_converter/ebooks/mobi/writer8/exth.py index 110475b..2e95fe5 100644 --- a/ebook_converter/ebooks/mobi/writer8/exth.py +++ b/ebook_converter/ebooks/mobi/writer8/exth.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import re from struct import pack from io import BytesIO @@ -16,6 +8,11 @@ from ebook_converter.utils.localization import lang_as_iso639_1 from ebook_converter.ebooks.metadata import authors_to_sort_string from ebook_converter.polyglot.builtins import iteritems, unicode_type + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + EXTH_CODES = { 'creator': 100, 'publisher': 101, diff --git a/ebook_converter/ebooks/odt/input.py b/ebook_converter/ebooks/odt/input.py index 7a7bf90..2422a6f 100644 --- a/ebook_converter/ebooks/odt/input.py +++ b/ebook_converter/ebooks/odt/input.py @@ -1,11 +1,6 @@ -from __future__ import print_function, unicode_literals, absolute_import, division -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' -__docformat__ = 'restructuredtext en' - -''' +""" Convert an ODT file into a Open Ebook -''' +""" import os, logging from lxml import etree @@ -23,6 +18,11 @@ from ebook_converter.utils.xml_parse import safe_xml_fromstring from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, filter, getcwd, as_bytes +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' +__docformat__ = 'restructuredtext en' + + class Extract(ODF2XHTML): def extract_pictures(self, zf): diff --git a/ebook_converter/ebooks/oeb/base.py b/ebook_converter/ebooks/oeb/base.py index 2720219..6bf3456 100644 --- a/ebook_converter/ebooks/oeb/base.py +++ b/ebook_converter/ebooks/oeb/base.py @@ -1,12 +1,6 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -''' +""" Basic support for manipulating OEB 1.x/2.0 content and metadata. -''' - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' -__docformat__ = 'restructuredtext en' - +""" import os, re, logging, sys, numbers from collections import defaultdict from itertools import count @@ -25,6 +19,11 @@ from ebook_converter.utils.short_uuid import uuid4 from ebook_converter.polyglot.builtins import iteritems, unicode_type, string_or_bytes, range, itervalues, filter, codepoint_to_chr from ebook_converter.polyglot.urllib import unquote as urlunquote, urldefrag, urljoin, urlparse, urlunparse + +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' +__docformat__ = 'restructuredtext en' + XML_NS = 'http://www.w3.org/XML/1998/namespace' OEB_DOC_NS = 'http://openebook.org/namespaces/oeb-document/1.0/' OPF1_NS = 'http://openebook.org/namespaces/oeb-package/1.0/' diff --git a/ebook_converter/ebooks/oeb/normalize_css.py b/ebook_converter/ebooks/oeb/normalize_css.py index 87f332b..debcc06 100644 --- a/ebook_converter/ebooks/oeb/normalize_css.py +++ b/ebook_converter/ebooks/oeb/normalize_css.py @@ -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 ' - import numbers from functools import wraps @@ -14,6 +7,10 @@ from ebook_converter.tinycss.fonts3 import parse_font, serialize_font_family from ebook_converter.ebooks.oeb.base import css_text from ebook_converter.polyglot.builtins import iteritems, string_or_bytes, unicode_type, zip + +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' + DEFAULTS = {'azimuth': 'center', 'background-attachment': 'scroll', # {{{ 'background-color': 'transparent', 'background-image': 'none', 'background-position': '0% 0%', 'background-repeat': 'repeat', diff --git a/ebook_converter/ebooks/oeb/parse_utils.py b/ebook_converter/ebooks/oeb/parse_utils.py index b0dab4e..91b0869 100644 --- a/ebook_converter/ebooks/oeb/parse_utils.py +++ b/ebook_converter/ebooks/oeb/parse_utils.py @@ -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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import re from lxml import etree, html @@ -16,6 +8,11 @@ from ebook_converter.constants import filesystem_encoding from ebook_converter.ebooks.chardet import xml_to_unicode, strip_encoding_declarations from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type, string_or_bytes, map + +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + RECOVER_PARSER = etree.XMLParser(recover=True, no_network=True, resolve_entities=False) XHTML_NS = 'http://www.w3.org/1999/xhtml' XMLNS_NS = 'http://www.w3.org/2000/xmlns/' diff --git a/ebook_converter/ebooks/oeb/polish/container.py b/ebook_converter/ebooks/oeb/polish/container.py index 1fc9107..1ace749 100644 --- a/ebook_converter/ebooks/oeb/polish/container.py +++ b/ebook_converter/ebooks/oeb/polish/container.py @@ -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: 2013, Kovid Goyal -from __future__ import absolute_import, division, print_function, unicode_literals - import errno import hashlib import logging diff --git a/ebook_converter/ebooks/oeb/polish/css.py b/ebook_converter/ebooks/oeb/polish/css.py index 16f8484..1593cb2 100644 --- a/ebook_converter/ebooks/oeb/polish/css.py +++ b/ebook_converter/ebooks/oeb/polish/css.py @@ -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 ' - from collections import defaultdict from functools import partial @@ -20,6 +13,10 @@ from ebook_converter.css_selectors import Select, SelectorError from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type, filter +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + def filter_used_rules(rules, log, select): for rule in rules: used = False diff --git a/ebook_converter/ebooks/oeb/polish/errors.py b/ebook_converter/ebooks/oeb/polish/errors.py index 06025ac..cecc86f 100644 --- a/ebook_converter/ebooks/oeb/polish/errors.py +++ b/ebook_converter/ebooks/oeb/polish/errors.py @@ -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 ebook_converter.ebooks import DRMError as _DRMError + __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter.ebooks import DRMError as _DRMError - class InvalidBook(ValueError): pass diff --git a/ebook_converter/ebooks/oeb/polish/opf.py b/ebook_converter/ebooks/oeb/polish/opf.py index a70c86e..b66adcb 100644 --- a/ebook_converter/ebooks/oeb/polish/opf.py +++ b/ebook_converter/ebooks/oeb/polish/opf.py @@ -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__ = '2014, Kovid Goyal ' - from lxml import etree from ebook_converter.ebooks.oeb.polish.container import OPF_NAMESPACES from ebook_converter.utils.localization import canonicalize_lang +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + def get_book_language(container): for lang in container.opf_xpath('//dc:language'): raw = lang.text diff --git a/ebook_converter/ebooks/oeb/polish/parsing.py b/ebook_converter/ebooks/oeb/polish/parsing.py index 2be9481..c8a6e94 100644 --- a/ebook_converter/ebooks/oeb/polish/parsing.py +++ b/ebook_converter/ebooks/oeb/polish/parsing.py @@ -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 ' - import re from lxml.etree import Element as LxmlElement @@ -16,6 +9,10 @@ from ebook_converter.ebooks.chardet import xml_to_unicode, strip_encoding_declar from ebook_converter.utils.cleantext import clean_xml_chars from ebook_converter.polyglot.builtins import unicode_type + +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' + XHTML_NS = 'http://www.w3.org/1999/xhtml' diff --git a/ebook_converter/ebooks/oeb/polish/pretty.py b/ebook_converter/ebooks/oeb/polish/pretty.py index 2a4c857..34f6078 100644 --- a/ebook_converter/ebooks/oeb/polish/pretty.py +++ b/ebook_converter/ebooks/oeb/polish/pretty.py @@ -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 ' - import textwrap from ebook_converter.polyglot.builtins import iteritems, map @@ -18,6 +11,9 @@ from ebook_converter.ebooks.oeb.polish.utils import guess_type from ebook_converter.utils.icu import sort_key +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' + def isspace(x): return not x.strip('\u0009\u000a\u000c\u000d\u0020') diff --git a/ebook_converter/ebooks/oeb/polish/replace.py b/ebook_converter/ebooks/oeb/polish/replace.py index 90991ee..95f705c 100644 --- a/ebook_converter/ebooks/oeb/polish/replace.py +++ b/ebook_converter/ebooks/oeb/polish/replace.py @@ -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__ = '2013, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import codecs, shutil, os, posixpath from ebook_converter.polyglot.builtins import iteritems, itervalues, map from functools import partial @@ -19,6 +11,11 @@ from ebook_converter.ebooks.oeb.polish.utils import extract from ebook_converter.polyglot.urllib import urlparse, urlunparse +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class LinkReplacer(object): def __init__(self, base, container, link_map, frag_map): diff --git a/ebook_converter/ebooks/oeb/polish/split.py b/ebook_converter/ebooks/oeb/polish/split.py index 910d7d5..e3515d6 100644 --- a/ebook_converter/ebooks/oeb/polish/split.py +++ b/ebook_converter/ebooks/oeb/polish/split.py @@ -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 ' - import copy, os, re from ebook_converter.polyglot.builtins import map, string_or_bytes, range @@ -16,6 +9,10 @@ from ebook_converter.polyglot.builtins import iteritems, unicode_type from ebook_converter.polyglot.urllib import urlparse +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' + + class AbortError(ValueError): pass diff --git a/ebook_converter/ebooks/oeb/polish/toc.py b/ebook_converter/ebooks/oeb/polish/toc.py index c5b8cda..fedc1ac 100644 --- a/ebook_converter/ebooks/oeb/polish/toc.py +++ b/ebook_converter/ebooks/oeb/polish/toc.py @@ -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__ = '2013, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import re from collections import Counter, OrderedDict from functools import partial @@ -26,6 +18,11 @@ from ebook_converter.utils.localization import get_lang, canonicalize_lang, lang from ebook_converter.polyglot.builtins import iteritems, map, unicode_type from ebook_converter.polyglot.urllib import urlparse + +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + ns = etree.FunctionNamespace('calibre_xpath_extensions') ns.prefix = 'calibre' ns['lower-case'] = lambda c, x: x.lower() if hasattr(x, 'lower') else x diff --git a/ebook_converter/ebooks/oeb/polish/utils.py b/ebook_converter/ebooks/oeb/polish/utils.py index c68186c..957c37d 100644 --- a/ebook_converter/ebooks/oeb/polish/utils.py +++ b/ebook_converter/ebooks/oeb/polish/utils.py @@ -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 ' - import re, os from bisect import bisect @@ -12,6 +5,10 @@ from ebook_converter import guess_type as _guess_type, replace_entities from ebook_converter.polyglot.builtins import filter +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' + + def guess_type(x): return _guess_type(x)[0] or 'application/octet-stream' diff --git a/ebook_converter/ebooks/oeb/reader.py b/ebook_converter/ebooks/oeb/reader.py index 527ed9c..6785c83 100644 --- a/ebook_converter/ebooks/oeb/reader.py +++ b/ebook_converter/ebooks/oeb/reader.py @@ -1,11 +1,6 @@ """ Container-/OPF-based input OEBBook reader. """ -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - import sys, os, uuid, copy, re, io from collections import defaultdict @@ -30,7 +25,10 @@ from ebook_converter import guess_type, xml_replace_entities from ebook_converter.polyglot.builtins import unicode_type, zip from ebook_converter.polyglot.urllib import unquote, urldefrag, urlparse + __all__ = ['OEBReader'] +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' class OEBReader(object): diff --git a/ebook_converter/ebooks/oeb/stylizer.py b/ebook_converter/ebooks/oeb/stylizer.py index 16cba7c..9f18ede 100644 --- a/ebook_converter/ebooks/oeb/stylizer.py +++ b/ebook_converter/ebooks/oeb/stylizer.py @@ -1,13 +1,6 @@ -# -*- encoding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" CSS property propagation class. -''' - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" import os, re, logging, copy, unicodedata, numbers import pkg_resources from operator import itemgetter @@ -25,6 +18,10 @@ from ebook_converter.css_selectors import Select, SelectorError, INAPPROPRIATE_P from ebook_converter.polyglot.builtins import iteritems, unicode_type, filter from ebook_converter.tinycss.media3 import CSSMedia3Parser + +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' + css_parser_log.setLevel(logging.WARN) _html_css_stylesheet = None diff --git a/ebook_converter/ebooks/oeb/transforms/cover.py b/ebook_converter/ebooks/oeb/transforms/cover.py index 059811c..ecb6bac 100644 --- a/ebook_converter/ebooks/oeb/transforms/cover.py +++ b/ebook_converter/ebooks/oeb/transforms/cover.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import textwrap from ebook_converter import guess_type @@ -15,6 +7,11 @@ from ebook_converter.polyglot.builtins import unicode_type from ebook_converter.polyglot.urllib import unquote +__license__ = 'GPL v3' +__copyright__ = '2010, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class CoverManager(object): SVG_TEMPLATE = textwrap.dedent('''\ diff --git a/ebook_converter/ebooks/oeb/transforms/data_url.py b/ebook_converter/ebooks/oeb/transforms/data_url.py index b45295b..60f874a 100644 --- a/ebook_converter/ebooks/oeb/transforms/data_url.py +++ b/ebook_converter/ebooks/oeb/transforms/data_url.py @@ -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__ = '2014, Kovid Goyal ' - import re from ebook_converter.ebooks.oeb.base import XPath, urlunquote from ebook_converter.polyglot.builtins import as_bytes +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + class DataURL(object): def __call__(self, oeb, opts): diff --git a/ebook_converter/ebooks/oeb/transforms/filenames.py b/ebook_converter/ebooks/oeb/transforms/filenames.py index ad56221..dbaefd1 100644 --- a/ebook_converter/ebooks/oeb/transforms/filenames.py +++ b/ebook_converter/ebooks/oeb/transforms/filenames.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import posixpath from lxml import etree @@ -14,6 +6,11 @@ from ebook_converter.ebooks.oeb.base import rewrite_links, urlnormalize from ebook_converter.polyglot.urllib import urldefrag, urlparse +__license__ = 'GPL v3' +__copyright__ = '2010, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class RenameFiles(object): # {{{ ''' diff --git a/ebook_converter/ebooks/oeb/transforms/flatcss.py b/ebook_converter/ebooks/oeb/transforms/flatcss.py index 2b4a764..774b2a4 100644 --- a/ebook_converter/ebooks/oeb/transforms/flatcss.py +++ b/ebook_converter/ebooks/oeb/transforms/flatcss.py @@ -1,11 +1,6 @@ -''' +""" CSS flattening transform. -''' -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" import re, operator, math, numbers from collections import defaultdict from xml.dom import SyntaxErr @@ -23,6 +18,10 @@ from ebook_converter.utils.filenames import ascii_filename, ascii_text from ebook_converter.utils.icu import numeric_sort_key from ebook_converter.polyglot.builtins import iteritems, unicode_type, string_or_bytes, map + +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' + COLLAPSE = re.compile(r'[ \t\r\n\v]+') STRIPNUM = re.compile(r'[-0-9]+$') diff --git a/ebook_converter/ebooks/oeb/transforms/guide.py b/ebook_converter/ebooks/oeb/transforms/guide.py index e935d79..f33718f 100644 --- a/ebook_converter/ebooks/oeb/transforms/guide.py +++ b/ebook_converter/ebooks/oeb/transforms/guide.py @@ -1,7 +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 ' __docformat__ = 'restructuredtext en' diff --git a/ebook_converter/ebooks/oeb/transforms/htmltoc.py b/ebook_converter/ebooks/oeb/transforms/htmltoc.py index 50bd876..b37190f 100644 --- a/ebook_converter/ebooks/oeb/transforms/htmltoc.py +++ b/ebook_converter/ebooks/oeb/transforms/htmltoc.py @@ -1,17 +1,15 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -''' +""" HTML-TOC-adding transform. -''' - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" from ebook_converter.ebooks.oeb.base import XML, XHTML, XHTML_NS from ebook_converter.ebooks.oeb.base import XHTML_MIME, CSS_MIME from ebook_converter.ebooks.oeb.base import element, XPath from ebook_converter.polyglot.builtins import unicode_type + __all__ = ['HTMLTOCAdder'] +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' DEFAULT_TITLE = __('Table of Contents') diff --git a/ebook_converter/ebooks/oeb/transforms/jacket.py b/ebook_converter/ebooks/oeb/transforms/jacket.py index f9666a9..7d200b4 100644 --- a/ebook_converter/ebooks/oeb/transforms/jacket.py +++ b/ebook_converter/ebooks/oeb/transforms/jacket.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import sys, os, re from xml.sax.saxutils import escape from string import Formatter @@ -20,6 +12,11 @@ from ebook_converter.ebooks.chardet import strip_encoding_declarations from ebook_converter.ebooks.metadata import fmt_sidx, rating_to_stars from ebook_converter.polyglot.builtins import unicode_type, map + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + JACKET_XPATH = '//h:meta[@name="calibre-content" and @content="jacket"]' diff --git a/ebook_converter/ebooks/oeb/transforms/manglecase.py b/ebook_converter/ebooks/oeb/transforms/manglecase.py index b2caaa6..93d9f0a 100644 --- a/ebook_converter/ebooks/oeb/transforms/manglecase.py +++ b/ebook_converter/ebooks/oeb/transforms/manglecase.py @@ -1,11 +1,6 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -''' +""" CSS case-mangling transform. -''' - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" from lxml import etree from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS from ebook_converter.ebooks.oeb.base import CSS_MIME @@ -13,6 +8,10 @@ from ebook_converter.ebooks.oeb.base import namespace from ebook_converter.ebooks.oeb.stylizer import Stylizer from ebook_converter.polyglot.builtins import string_or_bytes + +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' + CASE_MANGLER_CSS = """ .calibre_lowercase { font-variant: normal; diff --git a/ebook_converter/ebooks/oeb/transforms/metadata.py b/ebook_converter/ebooks/oeb/transforms/metadata.py index 097cc6d..146cd77 100644 --- a/ebook_converter/ebooks/oeb/transforms/metadata.py +++ b/ebook_converter/ebooks/oeb/transforms/metadata.py @@ -1,17 +1,14 @@ -#!/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 ' -__docformat__ = 'restructuredtext en' - import os, re from ebook_converter.utils.date import isoformat, now from ebook_converter import guess_type from ebook_converter.polyglot.builtins import iteritems +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + def meta_info_to_oeb_metadata(mi, m, log, override_input_metadata=False): from ebook_converter.ebooks.oeb.base import OPF if not mi.is_null('title'): diff --git a/ebook_converter/ebooks/oeb/transforms/page_margin.py b/ebook_converter/ebooks/oeb/transforms/page_margin.py index decf9f3..d6b1f2c 100644 --- a/ebook_converter/ebooks/oeb/transforms/page_margin.py +++ b/ebook_converter/ebooks/oeb/transforms/page_margin.py @@ -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__ = '2011, Kovid Goyal ' -__docformat__ = 'restructuredtext en' - import numbers from collections import Counter @@ -13,6 +5,11 @@ from ebook_converter.ebooks.oeb.base import barename, XPath from ebook_converter.polyglot.builtins import iteritems +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class RemoveAdobeMargins(object): ''' Remove margins specified in Adobe's page templates. diff --git a/ebook_converter/ebooks/oeb/transforms/rasterize.py b/ebook_converter/ebooks/oeb/transforms/rasterize.py index 246cc34..a199d16 100644 --- a/ebook_converter/ebooks/oeb/transforms/rasterize.py +++ b/ebook_converter/ebooks/oeb/transforms/rasterize.py @@ -1,15 +1,11 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -''' +""" SVG rasterization transform. -''' - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" import os, re # from PyQt5.Qt import ( # Qt, QByteArray, QBuffer, QIODevice, QColor, QImage, QPainter, QSvgRenderer) + from ebook_converter.ebooks.oeb.base import XHTML, XLINK from ebook_converter.ebooks.oeb.base import SVG_MIME, PNG_MIME from ebook_converter.ebooks.oeb.base import xml2str, xpath @@ -20,6 +16,10 @@ from ebook_converter.utils.imghdr import what from ebook_converter.polyglot.builtins import unicode_type from ebook_converter.polyglot.urllib import urldefrag + +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' + IMAGE_TAGS = {XHTML('img'), XHTML('object')} KEEP_ATTRS = {'class', 'style', 'width', 'height', 'align'} diff --git a/ebook_converter/ebooks/oeb/transforms/rescale.py b/ebook_converter/ebooks/oeb/transforms/rescale.py index cb9ba5e..33c7689 100644 --- a/ebook_converter/ebooks/oeb/transforms/rescale.py +++ b/ebook_converter/ebooks/oeb/transforms/rescale.py @@ -1,13 +1,10 @@ -#!/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 +from ebook_converter import fit_image + __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from ebook_converter import fit_image - class RescaleImages(object): diff --git a/ebook_converter/ebooks/oeb/transforms/split.py b/ebook_converter/ebooks/oeb/transforms/split.py index 3d5b02d..42eb63e 100644 --- a/ebook_converter/ebooks/oeb/transforms/split.py +++ b/ebook_converter/ebooks/oeb/transforms/split.py @@ -1,14 +1,8 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -__license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' -__docformat__ = 'restructuredtext en' - -''' +""" Splitting of the XHTML flows. Splitting can happen on page boundaries or can be forced at "likely" locations to conform to size limitations. This transform assumes a prior call to the flatcss transform. -''' - +""" import os, functools, collections, re, copy from collections import OrderedDict @@ -24,6 +18,10 @@ from ebook_converter.polyglot.builtins import iteritems, range, map, unicode_typ from ebook_converter.polyglot.urllib import unquote from ebook_converter.css_selectors import Select, SelectorError + +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' +__docformat__ = 'restructuredtext en' XPath = functools.partial(_XPath, namespaces=NAMESPACES) SPLIT_POINT_ATTR = 'csp' diff --git a/ebook_converter/ebooks/oeb/transforms/structure.py b/ebook_converter/ebooks/oeb/transforms/structure.py index a16b70d..ff634aa 100644 --- a/ebook_converter/ebooks/oeb/transforms/structure.py +++ b/ebook_converter/ebooks/oeb/transforms/structure.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import re, uuid from lxml import etree @@ -17,6 +9,11 @@ from ebook_converter.polyglot.builtins import itervalues, unicode_type from ebook_converter.polyglot.urllib import urlparse +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + def XPath(x): try: return etree.XPath(x, namespaces=XPNSMAP) diff --git a/ebook_converter/ebooks/oeb/transforms/subset.py b/ebook_converter/ebooks/oeb/transforms/subset.py index 37c1493..f0522d6 100644 --- a/ebook_converter/ebooks/oeb/transforms/subset.py +++ b/ebook_converter/ebooks/oeb/transforms/subset.py @@ -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 ' -__docformat__ = 'restructuredtext en' - from collections import defaultdict from ebook_converter.ebooks.oeb.base import urlnormalize, css_text @@ -14,6 +6,11 @@ from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_typ from ebook_converter.tinycss.fonts3 import parse_font_family +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + def get_font_properties(rule, default=None): ''' Given a CSS rule, extract normalized font properties from diff --git a/ebook_converter/ebooks/oeb/transforms/trimmanifest.py b/ebook_converter/ebooks/oeb/transforms/trimmanifest.py index 900fdf1..fd65617 100644 --- a/ebook_converter/ebooks/oeb/transforms/trimmanifest.py +++ b/ebook_converter/ebooks/oeb/transforms/trimmanifest.py @@ -1,16 +1,15 @@ -''' +""" OPF manifest trimming transform. -''' -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" from ebook_converter.ebooks.oeb.base import CSS_MIME, OEB_DOCS from ebook_converter.ebooks.oeb.base import urlnormalize, iterlinks from ebook_converter.polyglot.urllib import urldefrag +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' + + class ManifestTrimmer(object): @classmethod diff --git a/ebook_converter/ebooks/oeb/writer.py b/ebook_converter/ebooks/oeb/writer.py index f6e01f8..2bf6a6f 100644 --- a/ebook_converter/ebooks/oeb/writer.py +++ b/ebook_converter/ebooks/oeb/writer.py @@ -1,16 +1,15 @@ -''' +""" Directory output OEBBook writer. -''' -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2008, Marshall T. Vandegrift ' - +""" import os + from ebook_converter.ebooks.oeb.base import OPF_MIME, xml2str from ebook_converter.ebooks.oeb.base import DirContainer, OEBError + __all__ = ['OEBWriter'] +__license__ = 'GPL v3' +__copyright__ = '2008, Marshall T. Vandegrift ' class OEBWriter(object): diff --git a/ebook_converter/ebooks/pdb/__init__.py b/ebook_converter/ebooks/pdb/__init__.py index 870dc34..030d571 100644 --- a/ebook_converter/ebooks/pdb/__init__.py +++ b/ebook_converter/ebooks/pdb/__init__.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - __license__ = 'GPL v3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' diff --git a/ebook_converter/ebooks/pdb/ereader/__init__.py b/ebook_converter/ebooks/pdb/ereader/__init__.py index 84661e8..4233e39 100644 --- a/ebook_converter/ebooks/pdb/ereader/__init__.py +++ b/ebook_converter/ebooks/pdb/ereader/__init__.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +import os + __license__ = 'GPL v3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -import os - class EreaderError(Exception): pass diff --git a/ebook_converter/ebooks/pdb/ereader/reader.py b/ebook_converter/ebooks/pdb/ereader/reader.py index 48745b3..35913b7 100644 --- a/ebook_converter/ebooks/pdb/ereader/reader.py +++ b/ebook_converter/ebooks/pdb/ereader/reader.py @@ -1,20 +1,17 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Read content from ereader pdb file. -''' - -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - +""" from ebook_converter.ebooks.pdb.ereader import EreaderError from ebook_converter.ebooks.pdb.formatreader import FormatReader from ebook_converter.ebooks.pdb.ereader.reader132 import Reader132 from ebook_converter.ebooks.pdb.ereader.reader202 import Reader202 +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class Reader(FormatReader): def __init__(self, header, stream, log, options): diff --git a/ebook_converter/ebooks/pdb/ereader/reader132.py b/ebook_converter/ebooks/pdb/ereader/reader132.py index 2881e15..f4f2cad 100644 --- a/ebook_converter/ebooks/pdb/ereader/reader132.py +++ b/ebook_converter/ebooks/pdb/ereader/reader132.py @@ -1,14 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Read content from ereader pdb file with a 132 byte header created by Dropbook. -''' - -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - +""" import os import re import struct @@ -22,6 +14,11 @@ from ebook_converter.ebooks.pdb.formatreader import FormatReader from ebook_converter.polyglot.builtins import unicode_type, range +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class HeaderRecord(object): ''' The first record in the file is always the header record. It holds diff --git a/ebook_converter/ebooks/pdb/ereader/reader202.py b/ebook_converter/ebooks/pdb/ereader/reader202.py index 7695b41..b3dae6a 100644 --- a/ebook_converter/ebooks/pdb/ereader/reader202.py +++ b/ebook_converter/ebooks/pdb/ereader/reader202.py @@ -1,14 +1,7 @@ -# -*- coding: utf-8 -*- - -from __future__ import absolute_import, division, print_function, unicode_literals - -''' -Read content from ereader pdb file with a 116 and 202 byte header created by Makebook. -''' -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - +""" +Read content from ereader pdb file with a 116 and 202 byte header created by +Makebook. +""" import os import struct @@ -19,6 +12,11 @@ from ebook_converter.ebooks.pdb.ereader import EreaderError from ebook_converter.polyglot.builtins import unicode_type, range +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class HeaderRecord(object): ''' The first record in the file is always the header record. It holds diff --git a/ebook_converter/ebooks/pdb/formatreader.py b/ebook_converter/ebooks/pdb/formatreader.py index 1d14c63..dc98c6b 100644 --- a/ebook_converter/ebooks/pdb/formatreader.py +++ b/ebook_converter/ebooks/pdb/formatreader.py @@ -1,10 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Interface defining the necessary public functions for a pdb format reader. -''' - +""" __license__ = 'GPL v3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' diff --git a/ebook_converter/ebooks/pdb/haodoo/__init__.py b/ebook_converter/ebooks/pdb/haodoo/__init__.py index 357137f..e69de29 100644 --- a/ebook_converter/ebooks/pdb/haodoo/__init__.py +++ b/ebook_converter/ebooks/pdb/haodoo/__init__.py @@ -1,10 +0,0 @@ -#!/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 ' -__docformat__ = 'restructuredtext en' - - - diff --git a/ebook_converter/ebooks/pdb/haodoo/reader.py b/ebook_converter/ebooks/pdb/haodoo/reader.py index 59d7ece..b1c5043 100644 --- a/ebook_converter/ebooks/pdb/haodoo/reader.py +++ b/ebook_converter/ebooks/pdb/haodoo/reader.py @@ -1,15 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Read content from Haodoo.net pdb file. -''' - -__license__ = 'GPL v3' -__copyright__ = '2012, Kan-Ru Chen ' -__docformat__ = 'restructuredtext en' - - +""" import struct import os @@ -19,6 +10,11 @@ from ebook_converter.ebooks.metadata import MetaInformation from ebook_converter.ebooks.txt.processor import opf_writer, HTML_TEMPLATE from ebook_converter.polyglot.builtins import range, map + +__license__ = 'GPL v3' +__copyright__ = '2012, Kan-Ru Chen ' +__docformat__ = 'restructuredtext en' + BPDB_IDENT = b'BOOKMTIT' UPDB_IDENT = b'BOOKMTIU' diff --git a/ebook_converter/ebooks/pdb/header.py b/ebook_converter/ebooks/pdb/header.py index a3995e7..3c43cfa 100644 --- a/ebook_converter/ebooks/pdb/header.py +++ b/ebook_converter/ebooks/pdb/header.py @@ -1,14 +1,6 @@ -# -*- coding: utf-8 -*- - -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Read the header data from a pdb file. -''' - -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' +""" import re import struct @@ -16,6 +8,11 @@ import time from ebook_converter.polyglot.builtins import long_type +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + + class PdbHeaderReader(object): def __init__(self, stream): diff --git a/ebook_converter/ebooks/pdb/palmdoc/reader.py b/ebook_converter/ebooks/pdb/palmdoc/reader.py index 80c1259..a6df1c9 100644 --- a/ebook_converter/ebooks/pdb/palmdoc/reader.py +++ b/ebook_converter/ebooks/pdb/palmdoc/reader.py @@ -1,19 +1,17 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - ''' Read content from palmdoc pdb file. ''' +import io +import struct + +from ebook_converter.ebooks.pdb.formatreader import FormatReader + + __license__ = 'GPL v3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -import struct, io - - -from ebook_converter.ebooks.pdb.formatreader import FormatReader - class HeaderRecord(object): ''' diff --git a/ebook_converter/ebooks/pdb/pdf/reader.py b/ebook_converter/ebooks/pdb/pdf/reader.py index df688c0..9144d59 100644 --- a/ebook_converter/ebooks/pdb/pdf/reader.py +++ b/ebook_converter/ebooks/pdb/pdf/reader.py @@ -1,20 +1,16 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Read content from palmdoc pdb file. -''' +""" +from ebook_converter.ebooks.pdb.formatreader import FormatReader +from ebook_converter.ptempfile import PersistentTemporaryFile +from ebook_converter.polyglot.builtins import range + __license__ = 'GPL v3' __copyright__ = '2010, John Schember ' __docformat__ = 'restructuredtext en' -from ebook_converter.ebooks.pdb.formatreader import FormatReader -from ebook_converter.ptempfile import PersistentTemporaryFile -from ebook_converter.polyglot.builtins import range - - class Reader(FormatReader): def __init__(self, header, stream, log, options): diff --git a/ebook_converter/ebooks/pdb/plucker/reader.py b/ebook_converter/ebooks/pdb/plucker/reader.py index 0be3697..e57bc90 100644 --- a/ebook_converter/ebooks/pdb/plucker/reader.py +++ b/ebook_converter/ebooks/pdb/plucker/reader.py @@ -1,11 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - - -__license__ = 'GPL v3' -__copyright__ = '20011, John Schember ' -__docformat__ = 'restructuredtext en' - import os import struct import zlib @@ -19,6 +11,11 @@ from ebook_converter.utils.imghdr import identify from ebook_converter.utils.img import save_cover_data_to, Canvas, image_from_data from ebook_converter.polyglot.builtins import codepoint_to_chr, range + +__license__ = 'GPL v3' +__copyright__ = '20011, John Schember ' +__docformat__ = 'restructuredtext en' + DATATYPE_PHTML = 0 DATATYPE_PHTML_COMPRESSED = 1 DATATYPE_TBMP = 2 diff --git a/ebook_converter/ebooks/pdb/ztxt/__init__.py b/ebook_converter/ebooks/pdb/ztxt/__init__.py index 18d4da9..93d9542 100644 --- a/ebook_converter/ebooks/pdb/ztxt/__init__.py +++ b/ebook_converter/ebooks/pdb/ztxt/__init__.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - __license__ = 'GPL v3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' diff --git a/ebook_converter/ebooks/pdb/ztxt/reader.py b/ebook_converter/ebooks/pdb/ztxt/reader.py index 0b96bbd..e9caab0 100644 --- a/ebook_converter/ebooks/pdb/ztxt/reader.py +++ b/ebook_converter/ebooks/pdb/ztxt/reader.py @@ -1,22 +1,18 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Read content from ztxt pdb file. -''' - -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - +""" import struct import zlib import io - from ebook_converter.ebooks.pdb.formatreader import FormatReader from ebook_converter.ebooks.pdb.ztxt import zTXTError + +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + SUPPORTED_VERSION = (1, 40) diff --git a/ebook_converter/ebooks/pdf/pdftohtml.py b/ebook_converter/ebooks/pdf/pdftohtml.py index 40c95b3..bf502a7 100644 --- a/ebook_converter/ebooks/pdf/pdftohtml.py +++ b/ebook_converter/ebooks/pdf/pdftohtml.py @@ -1,9 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2008, Kovid Goyal - -from __future__ import print_function, unicode_literals - import errno import os import re diff --git a/ebook_converter/ebooks/pdf/render/common.py b/ebook_converter/ebooks/pdf/render/common.py index 691c685..c40e93a 100644 --- a/ebook_converter/ebooks/pdf/render/common.py +++ b/ebook_converter/ebooks/pdf/render/common.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import codecs, zlib, numbers from io import BytesIO from datetime import datetime @@ -15,6 +7,11 @@ from ebook_converter.utils.logging import default_log from ebook_converter.polyglot.builtins import iteritems, unicode_type, codepoint_to_chr from ebook_converter.polyglot.binary import as_hex_bytes + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + pdf_float = lambda x: f"{x:.1f}" EOL = b'\n' diff --git a/ebook_converter/ebooks/rtf/input.py b/ebook_converter/ebooks/rtf/input.py index 075eaaa..1522526 100644 --- a/ebook_converter/ebooks/rtf/input.py +++ b/ebook_converter/ebooks/rtf/input.py @@ -1,12 +1,10 @@ -from __future__ import absolute_import, division, print_function, unicode_literals +from lxml import etree + __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' -from lxml import etree - - class InlineClass(etree.XSLTExtension): FMTS = ('italics', 'bold', 'strike-through', 'small-caps') diff --git a/ebook_converter/ebooks/rtf2xml/ParseRtf.py b/ebook_converter/ebooks/rtf2xml/ParseRtf.py index b88ed5e..a1cc095 100644 --- a/ebook_converter/ebooks/rtf2xml/ParseRtf.py +++ b/ebook_converter/ebooks/rtf2xml/ParseRtf.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/__init__.py b/ebook_converter/ebooks/rtf2xml/__init__.py index a106fe9..cd134c5 100644 --- a/ebook_converter/ebooks/rtf2xml/__init__.py +++ b/ebook_converter/ebooks/rtf2xml/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division - import io diff --git a/ebook_converter/ebooks/rtf2xml/add_brackets.py b/ebook_converter/ebooks/rtf2xml/add_brackets.py index 8bf7aea..df61ede 100644 --- a/ebook_converter/ebooks/rtf2xml/add_brackets.py +++ b/ebook_converter/ebooks/rtf2xml/add_brackets.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/body_styles.py b/ebook_converter/ebooks/rtf2xml/body_styles.py index 2d1ccc8..d6a611b 100644 --- a/ebook_converter/ebooks/rtf2xml/body_styles.py +++ b/ebook_converter/ebooks/rtf2xml/body_styles.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/border_parse.py b/ebook_converter/ebooks/rtf2xml/border_parse.py index 782b0b8..29852ee 100644 --- a/ebook_converter/ebooks/rtf2xml/border_parse.py +++ b/ebook_converter/ebooks/rtf2xml/border_parse.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/char_set.py b/ebook_converter/ebooks/rtf2xml/char_set.py index 5ad6950..304a0a2 100644 --- a/ebook_converter/ebooks/rtf2xml/char_set.py +++ b/ebook_converter/ebooks/rtf2xml/char_set.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division char_set = """ NON-BREAKING HYPEHN:_:8290:‑ diff --git a/ebook_converter/ebooks/rtf2xml/check_brackets.py b/ebook_converter/ebooks/rtf2xml/check_brackets.py index c3ebfcd..355af16 100644 --- a/ebook_converter/ebooks/rtf2xml/check_brackets.py +++ b/ebook_converter/ebooks/rtf2xml/check_brackets.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/check_encoding.py b/ebook_converter/ebooks/rtf2xml/check_encoding.py index b73bcad..81f5cf4 100644 --- a/ebook_converter/ebooks/rtf2xml/check_encoding.py +++ b/ebook_converter/ebooks/rtf2xml/check_encoding.py @@ -1,6 +1,3 @@ -#!/usr/bin/env python2 -from __future__ import absolute_import, division, print_function, unicode_literals - import sys from ebook_converter.polyglot.builtins import unicode_type diff --git a/ebook_converter/ebooks/rtf2xml/colors.py b/ebook_converter/ebooks/rtf2xml/colors.py index 7bfd500..a75fe4d 100644 --- a/ebook_converter/ebooks/rtf2xml/colors.py +++ b/ebook_converter/ebooks/rtf2xml/colors.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/combine_borders.py b/ebook_converter/ebooks/rtf2xml/combine_borders.py index d0a00e1..6983f13 100644 --- a/ebook_converter/ebooks/rtf2xml/combine_borders.py +++ b/ebook_converter/ebooks/rtf2xml/combine_borders.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/convert_to_tags.py b/ebook_converter/ebooks/rtf2xml/convert_to_tags.py index 7cef82f..ffdf0be 100644 --- a/ebook_converter/ebooks/rtf2xml/convert_to_tags.py +++ b/ebook_converter/ebooks/rtf2xml/convert_to_tags.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division import os, sys from ebook_converter.ebooks.rtf2xml import copy, check_encoding diff --git a/ebook_converter/ebooks/rtf2xml/copy.py b/ebook_converter/ebooks/rtf2xml/copy.py index f81cc50..e89d24c 100644 --- a/ebook_converter/ebooks/rtf2xml/copy.py +++ b/ebook_converter/ebooks/rtf2xml/copy.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/default_encoding.py b/ebook_converter/ebooks/rtf2xml/default_encoding.py index a1b7019..5d1461c 100644 --- a/ebook_converter/ebooks/rtf2xml/default_encoding.py +++ b/ebook_converter/ebooks/rtf2xml/default_encoding.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # copyright 2002 Paul Henry Tremblay # diff --git a/ebook_converter/ebooks/rtf2xml/delete_info.py b/ebook_converter/ebooks/rtf2xml/delete_info.py index fcc2c95..f62b8ba 100644 --- a/ebook_converter/ebooks/rtf2xml/delete_info.py +++ b/ebook_converter/ebooks/rtf2xml/delete_info.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/field_strings.py b/ebook_converter/ebooks/rtf2xml/field_strings.py index a43f4a6..522dabe 100644 --- a/ebook_converter/ebooks/rtf2xml/field_strings.py +++ b/ebook_converter/ebooks/rtf2xml/field_strings.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/fields_large.py b/ebook_converter/ebooks/rtf2xml/fields_large.py index 0afaf4a..51e73da 100644 --- a/ebook_converter/ebooks/rtf2xml/fields_large.py +++ b/ebook_converter/ebooks/rtf2xml/fields_large.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/fields_small.py b/ebook_converter/ebooks/rtf2xml/fields_small.py index baddc4a..76f71cb 100644 --- a/ebook_converter/ebooks/rtf2xml/fields_small.py +++ b/ebook_converter/ebooks/rtf2xml/fields_small.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/fonts.py b/ebook_converter/ebooks/rtf2xml/fonts.py index 42c6a84..7543b97 100644 --- a/ebook_converter/ebooks/rtf2xml/fonts.py +++ b/ebook_converter/ebooks/rtf2xml/fonts.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/footnote.py b/ebook_converter/ebooks/rtf2xml/footnote.py index 31165a9..ce928a8 100644 --- a/ebook_converter/ebooks/rtf2xml/footnote.py +++ b/ebook_converter/ebooks/rtf2xml/footnote.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/get_char_map.py b/ebook_converter/ebooks/rtf2xml/get_char_map.py index 9b67347..4ce42e3 100644 --- a/ebook_converter/ebooks/rtf2xml/get_char_map.py +++ b/ebook_converter/ebooks/rtf2xml/get_char_map.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/group_borders.py b/ebook_converter/ebooks/rtf2xml/group_borders.py index 2169469..39e5d23 100644 --- a/ebook_converter/ebooks/rtf2xml/group_borders.py +++ b/ebook_converter/ebooks/rtf2xml/group_borders.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/group_styles.py b/ebook_converter/ebooks/rtf2xml/group_styles.py index a33fba2..8834979 100644 --- a/ebook_converter/ebooks/rtf2xml/group_styles.py +++ b/ebook_converter/ebooks/rtf2xml/group_styles.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/header.py b/ebook_converter/ebooks/rtf2xml/header.py index 53bb796..4273942 100644 --- a/ebook_converter/ebooks/rtf2xml/header.py +++ b/ebook_converter/ebooks/rtf2xml/header.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/headings_to_sections.py b/ebook_converter/ebooks/rtf2xml/headings_to_sections.py index ec64fd2..0213a2e 100644 --- a/ebook_converter/ebooks/rtf2xml/headings_to_sections.py +++ b/ebook_converter/ebooks/rtf2xml/headings_to_sections.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py b/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py index 2f252d3..f951208 100644 --- a/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py +++ b/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/info.py b/ebook_converter/ebooks/rtf2xml/info.py index 291fad8..1b2a5ce 100644 --- a/ebook_converter/ebooks/rtf2xml/info.py +++ b/ebook_converter/ebooks/rtf2xml/info.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/inline.py b/ebook_converter/ebooks/rtf2xml/inline.py index cb9538b..2fd4829 100644 --- a/ebook_converter/ebooks/rtf2xml/inline.py +++ b/ebook_converter/ebooks/rtf2xml/inline.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division import sys, os from ebook_converter.ebooks.rtf2xml import copy diff --git a/ebook_converter/ebooks/rtf2xml/line_endings.py b/ebook_converter/ebooks/rtf2xml/line_endings.py index 609faf0..ec85ac9 100644 --- a/ebook_converter/ebooks/rtf2xml/line_endings.py +++ b/ebook_converter/ebooks/rtf2xml/line_endings.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/list_numbers.py b/ebook_converter/ebooks/rtf2xml/list_numbers.py index b37bfb7..ba2a32f 100644 --- a/ebook_converter/ebooks/rtf2xml/list_numbers.py +++ b/ebook_converter/ebooks/rtf2xml/list_numbers.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/list_table.py b/ebook_converter/ebooks/rtf2xml/list_table.py index aabbca1..69df2d6 100644 --- a/ebook_converter/ebooks/rtf2xml/list_table.py +++ b/ebook_converter/ebooks/rtf2xml/list_table.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/make_lists.py b/ebook_converter/ebooks/rtf2xml/make_lists.py index aa73cac..fb5e334 100644 --- a/ebook_converter/ebooks/rtf2xml/make_lists.py +++ b/ebook_converter/ebooks/rtf2xml/make_lists.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/old_rtf.py b/ebook_converter/ebooks/rtf2xml/old_rtf.py index 9b7ab31..ceda6f1 100644 --- a/ebook_converter/ebooks/rtf2xml/old_rtf.py +++ b/ebook_converter/ebooks/rtf2xml/old_rtf.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/output.py b/ebook_converter/ebooks/rtf2xml/output.py index 7499259..8ed27c5 100644 --- a/ebook_converter/ebooks/rtf2xml/output.py +++ b/ebook_converter/ebooks/rtf2xml/output.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/override_table.py b/ebook_converter/ebooks/rtf2xml/override_table.py index 3ae5309..94201b6 100644 --- a/ebook_converter/ebooks/rtf2xml/override_table.py +++ b/ebook_converter/ebooks/rtf2xml/override_table.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division -from __future__ import print_function ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/paragraph_def.py b/ebook_converter/ebooks/rtf2xml/paragraph_def.py index 296b4d4..ffb9118 100644 --- a/ebook_converter/ebooks/rtf2xml/paragraph_def.py +++ b/ebook_converter/ebooks/rtf2xml/paragraph_def.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/paragraphs.py b/ebook_converter/ebooks/rtf2xml/paragraphs.py index 194a850..9d5d61e 100644 --- a/ebook_converter/ebooks/rtf2xml/paragraphs.py +++ b/ebook_converter/ebooks/rtf2xml/paragraphs.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/pict.py b/ebook_converter/ebooks/rtf2xml/pict.py index 30e497f..c9042c4 100644 --- a/ebook_converter/ebooks/rtf2xml/pict.py +++ b/ebook_converter/ebooks/rtf2xml/pict.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/preamble_div.py b/ebook_converter/ebooks/rtf2xml/preamble_div.py index dbd56b0..23c9791 100644 --- a/ebook_converter/ebooks/rtf2xml/preamble_div.py +++ b/ebook_converter/ebooks/rtf2xml/preamble_div.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division -from __future__ import print_function ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/preamble_rest.py b/ebook_converter/ebooks/rtf2xml/preamble_rest.py index aec9b83..1da32d7 100644 --- a/ebook_converter/ebooks/rtf2xml/preamble_rest.py +++ b/ebook_converter/ebooks/rtf2xml/preamble_rest.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/process_tokens.py b/ebook_converter/ebooks/rtf2xml/process_tokens.py index eab2703..0e40f85 100644 --- a/ebook_converter/ebooks/rtf2xml/process_tokens.py +++ b/ebook_converter/ebooks/rtf2xml/process_tokens.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/sections.py b/ebook_converter/ebooks/rtf2xml/sections.py index c4fa78c..ac912d3 100644 --- a/ebook_converter/ebooks/rtf2xml/sections.py +++ b/ebook_converter/ebooks/rtf2xml/sections.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/styles.py b/ebook_converter/ebooks/rtf2xml/styles.py index 4c1513c..964bd8f 100644 --- a/ebook_converter/ebooks/rtf2xml/styles.py +++ b/ebook_converter/ebooks/rtf2xml/styles.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/table.py b/ebook_converter/ebooks/rtf2xml/table.py index 5f09753..2dc7ab4 100644 --- a/ebook_converter/ebooks/rtf2xml/table.py +++ b/ebook_converter/ebooks/rtf2xml/table.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function, unicode_literals ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/table_info.py b/ebook_converter/ebooks/rtf2xml/table_info.py index fbaaedc..85179eb 100644 --- a/ebook_converter/ebooks/rtf2xml/table_info.py +++ b/ebook_converter/ebooks/rtf2xml/table_info.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/rtf2xml/tokenize.py b/ebook_converter/ebooks/rtf2xml/tokenize.py index 36a34e2..615870b 100644 --- a/ebook_converter/ebooks/rtf2xml/tokenize.py +++ b/ebook_converter/ebooks/rtf2xml/tokenize.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals, absolute_import, print_function, division ######################################################################### # # # # diff --git a/ebook_converter/ebooks/textile/functions.py b/ebook_converter/ebooks/textile/functions.py index 34ca7a7..f019815 100644 --- a/ebook_converter/ebooks/textile/functions.py +++ b/ebook_converter/ebooks/textile/functions.py @@ -1,17 +1,19 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - """ PyTextile A Humane Web Text Generator """ +import re +import uuid + +from ebook_converter.utils.smartypants import smartyPants +from ebook_converter.polyglot.builtins import unicode_type +from ebook_converter.polyglot.urllib import urlopen, urlparse + # Last upstream version basis # __version__ = '2.1.4' # __date__ = '2009/12/04' - __copyright__ = """ Copyright (c) 2011, Leigh Parry Copyright (c) 2011, John Schember @@ -27,9 +29,7 @@ Thanks to Carlo Zottmann for refactoring Textile's procedural code into a class framework Additions and fixes Copyright (c) 2006 Alex Shiels http://thresholdstate.com/ - """ - __license__ = """ L I C E N S E ============= @@ -58,16 +58,8 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - """ -import re -import uuid - -from ebook_converter.utils.smartypants import smartyPants -from ebook_converter.polyglot.builtins import unicode_type -from ebook_converter.polyglot.urllib import urlopen, urlparse - def _normalize_newlines(string): out = re.sub(r'\r\n', '\n', string) diff --git a/ebook_converter/ebooks/textile/unsmarten.py b/ebook_converter/ebooks/textile/unsmarten.py index ff05227..4e9a7a1 100644 --- a/ebook_converter/ebooks/textile/unsmarten.py +++ b/ebook_converter/ebooks/textile/unsmarten.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +import re + __license__ = 'GPL 3' __copyright__ = '2011, Leigh Parry ' __docformat__ = 'restructuredtext en' -import re - def unsmarten(txt): txt = re.sub(u'¢|¢|¢', r'{c\}', txt) # cent diff --git a/ebook_converter/ebooks/txt/markdownml.py b/ebook_converter/ebooks/txt/markdownml.py index 87a7ab1..9f1320b 100644 --- a/ebook_converter/ebooks/txt/markdownml.py +++ b/ebook_converter/ebooks/txt/markdownml.py @@ -1,14 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '''2011, John Schember -2011, Leigh Parry ''' -__docformat__ = 'restructuredtext en' - -''' +""" Transform OEB content into Textile formatted plain text -''' +""" import re from functools import partial @@ -19,6 +11,12 @@ from ebook_converter.ebooks.oeb.stylizer import Stylizer from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes +__license__ = 'GPL 3' +__copyright__ = ('2011, John Schember 2011, ' + 'Leigh Parry ') +__docformat__ = 'restructuredtext en' + + class MarkdownMLizer(OEB2HTML): def extract_content(self, oeb_book, opts): diff --git a/ebook_converter/ebooks/txt/newlines.py b/ebook_converter/ebooks/txt/newlines.py index 56a890c..3319e5b 100644 --- a/ebook_converter/ebooks/txt/newlines.py +++ b/ebook_converter/ebooks/txt/newlines.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +import os + __license__ = 'GPL 3' __copyright__ = '2009, John Schember ' __docformat__ = 'restructuredtext en' -import os - class TxtNewlines(object): diff --git a/ebook_converter/ebooks/txt/processor.py b/ebook_converter/ebooks/txt/processor.py index 66a18f2..8b63517 100644 --- a/ebook_converter/ebooks/txt/processor.py +++ b/ebook_converter/ebooks/txt/processor.py @@ -1,15 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL v3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - - -''' +""" Read content from txt file. -''' - +""" import os, re from ebook_converter import prepare_string_for_xml, isbytestring @@ -19,6 +10,11 @@ from ebook_converter.ebooks.conversion.preprocess import DocAnalysis from ebook_converter.utils.cleantext import clean_ascii_chars from ebook_converter.polyglot.builtins import iteritems, unicode_type, map, range, long_type + +__license__ = 'GPL v3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + HTML_TEMPLATE = '%s \n%s\n' diff --git a/ebook_converter/ebooks/txt/textileml.py b/ebook_converter/ebooks/txt/textileml.py index 874fac4..4192416 100644 --- a/ebook_converter/ebooks/txt/textileml.py +++ b/ebook_converter/ebooks/txt/textileml.py @@ -1,13 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2011, Leigh Parry ' -__docformat__ = 'restructuredtext en' - -''' +""" Transform OEB content into Textile formatted plain text -''' +""" import re from functools import partial @@ -20,6 +13,11 @@ from ebook_converter.ebooks.textile.unsmarten import unsmarten from ebook_converter.polyglot.builtins import string_or_bytes +__license__ = 'GPL 3' +__copyright__ = '2011, Leigh Parry ' +__docformat__ = 'restructuredtext en' + + class TextileMLizer(OEB2HTML): MAX_EM = 10 diff --git a/ebook_converter/ebooks/txt/txtml.py b/ebook_converter/ebooks/txt/txtml.py index 64a44f4..78e1f65 100644 --- a/ebook_converter/ebooks/txt/txtml.py +++ b/ebook_converter/ebooks/txt/txtml.py @@ -1,20 +1,16 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - -''' +""" Transform OEB content into plain text -''' - +""" import re from lxml import etree from ebook_converter.polyglot.builtins import string_or_bytes +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + BLOCK_TAGS = [ 'div', 'p', diff --git a/ebook_converter/ebooks/unihandecode/__init__.py b/ebook_converter/ebooks/unihandecode/__init__.py index 63e8120..2c50c7f 100644 --- a/ebook_converter/ebooks/unihandecode/__init__.py +++ b/ebook_converter/ebooks/unihandecode/__init__.py @@ -1,12 +1,4 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2010, Hiroshi Miura ' -__docformat__ = 'restructuredtext en' -__all__ = ["Unihandecoder"] - -''' +""" Decode unicode text to an ASCII representation of the text. Translate unicode characters to ASCII. @@ -16,11 +8,16 @@ of calibre. Copyright(c) 2009, John Schember Tranliterate the string from unicode characters to ASCII in Chinese and others. - -''' +""" import unicodedata +__license__ = 'GPL 3' +__copyright__ = '2010, Hiroshi Miura ' +__docformat__ = 'restructuredtext en' +__all__ = ["Unihandecoder"] + + class Unihandecoder(object): preferred_encoding = None decoder = None diff --git a/ebook_converter/ebooks/unihandecode/jacodepoints.py b/ebook_converter/ebooks/unihandecode/jacodepoints.py index 89d83d9..02bc149 100644 --- a/ebook_converter/ebooks/unihandecode/jacodepoints.py +++ b/ebook_converter/ebooks/unihandecode/jacodepoints.py @@ -1,15 +1,11 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - +""" +Unicode code point dictionary. +Based on Unicode.org Unihan database. +""" __license__ = 'GPL 3' __copyright__ = '2010 Hiroshi Miura ' __docformat__ = 'restructuredtext en' -''' -Unicode code point dictionary. -Based on Unicode.org Unihan database. -''' - CODEPOINTS = { 'x34':[ 'Qiu ','Tian ','','','Kua ','Wu ','Yin ','','','','','','Si ','','','', diff --git a/ebook_converter/ebooks/unihandecode/jadecoder.py b/ebook_converter/ebooks/unihandecode/jadecoder.py index a4c54bd..ce535f8 100644 --- a/ebook_converter/ebooks/unihandecode/jadecoder.py +++ b/ebook_converter/ebooks/unihandecode/jadecoder.py @@ -1,11 +1,4 @@ -# coding:utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2010, Hiroshi Miura ' -__docformat__ = 'restructuredtext en' - -''' +""" Decode unicode text to an ASCII representation of the text for Japanese. Translate unicode string to ASCII roman string. @@ -17,15 +10,20 @@ and perl module Text::Unidecode This functionality is owned by Kakasi Japanese processing engine. Copyright (c) 2010 Hiroshi Miura -''' - +""" import re + from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS from ebook_converter.ebooks.unihandecode.jacodepoints import CODEPOINTS as JACODES from ebook_converter.ebooks.unihandecode.pykakasi.kakasi import kakasi +__license__ = 'GPL 3' +__copyright__ = '2010, Hiroshi Miura ' +__docformat__ = 'restructuredtext en' + + class Jadecoder(Unidecoder): kakasi = None codepoints = {} diff --git a/ebook_converter/ebooks/unihandecode/krcodepoints.py b/ebook_converter/ebooks/unihandecode/krcodepoints.py index bca8e3f..3334b3c 100644 --- a/ebook_converter/ebooks/unihandecode/krcodepoints.py +++ b/ebook_converter/ebooks/unihandecode/krcodepoints.py @@ -1,15 +1,11 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - +""" +Unicode code point dictionary. +Based on Unicode.org Unihan database. +""" __license__ = 'GPL 3' __copyright__ = '2010 Hiroshi Miura ' __docformat__ = 'restructuredtext en' -''' -Unicode code point dictionary. -Based on Unicode.org Unihan database. -''' - CODEPOINTS = { 'x34':[ 'Qiu ','Tian ','','','Kua ','Wu ','Yin ','','','','','','Si ','','','', diff --git a/ebook_converter/ebooks/unihandecode/krdecoder.py b/ebook_converter/ebooks/unihandecode/krdecoder.py index 7cbacb9..f66de31 100644 --- a/ebook_converter/ebooks/unihandecode/krdecoder.py +++ b/ebook_converter/ebooks/unihandecode/krdecoder.py @@ -1,20 +1,16 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +""" +Decode unicode text to an ASCII representation of the text in Korean. +Based on unidecoder. +""" +from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder +from ebook_converter.ebooks.unihandecode.krcodepoints import CODEPOINTS as HANCODES +from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS + __license__ = 'GPL 3' __copyright__ = '2010, Hiroshi Miura ' __docformat__ = 'restructuredtext en' -''' -Decode unicode text to an ASCII representation of the text in Korean. -Based on unidecoder. - -''' - -from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder -from ebook_converter.ebooks.unihandecode.krcodepoints import CODEPOINTS as HANCODES -from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS - class Krdecoder(Unidecoder): diff --git a/ebook_converter/ebooks/unihandecode/unicodepoints.py b/ebook_converter/ebooks/unihandecode/unicodepoints.py index 13eeed2..ad3cc35 100644 --- a/ebook_converter/ebooks/unihandecode/unicodepoints.py +++ b/ebook_converter/ebooks/unihandecode/unicodepoints.py @@ -1,16 +1,13 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' -__docformat__ = 'restructuredtext en' - -''' +""" Unicode code point dictionary. Based on Text::Unidecode's xAB.pm lists. This combines all xAB.pm files into a single dictionary. -''' +""" + +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' CODEPOINTS = { diff --git a/ebook_converter/ebooks/unihandecode/unidecoder.py b/ebook_converter/ebooks/unihandecode/unidecoder.py index 92d5638..e8e8624 100644 --- a/ebook_converter/ebooks/unihandecode/unidecoder.py +++ b/ebook_converter/ebooks/unihandecode/unidecoder.py @@ -1,11 +1,4 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -__license__ = 'GPL 3' -__copyright__ = '2010, Hiroshi Miura ' -__docformat__ = 'restructuredtext en' - -''' +""" Decode unicode text to an ASCII representation of the text in Chinese. Transliterate unicode characters to ASCII based on chinese pronounce. @@ -58,14 +51,19 @@ purpose. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -''' - +""" import re + from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS from ebook_converter.ebooks.unihandecode.zhcodepoints import CODEPOINTS as HANCODES from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL 3' +__copyright__ = '2010, Hiroshi Miura ' +__docformat__ = 'restructuredtext en' + + class Unidecoder(object): codepoints = {} diff --git a/ebook_converter/ebooks/unihandecode/vncodepoints.py b/ebook_converter/ebooks/unihandecode/vncodepoints.py index 2a74bb1..63032bd 100644 --- a/ebook_converter/ebooks/unihandecode/vncodepoints.py +++ b/ebook_converter/ebooks/unihandecode/vncodepoints.py @@ -1,15 +1,11 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - +""" +Unicode code point dictionary. +Based on Unicode.org Unihan database. +""" __license__ = 'GPL 3' __copyright__ = '2010 Hiroshi Miura ' __docformat__ = 'restructuredtext en' -''' -Unicode code point dictionary. -Based on Unicode.org Unihan database. -''' - CODEPOINTS = { 'x34':[ 'Qiu ','Tian ','','','Kua ','Wu ','Yin ','','','','','','Si ','','','', diff --git a/ebook_converter/ebooks/unihandecode/vndecoder.py b/ebook_converter/ebooks/unihandecode/vndecoder.py index 1a23d0d..5aff0d6 100644 --- a/ebook_converter/ebooks/unihandecode/vndecoder.py +++ b/ebook_converter/ebooks/unihandecode/vndecoder.py @@ -1,24 +1,21 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +""" +Decode unicode text to an ASCII representation of the text in Vietnamese. +""" + +from ebook_converter.ebooks.unihandecode import unidecoder +from ebook_converter.ebooks.unihandecode import vncodepoints +from ebook_converter.ebooks.unihandecode import unicodepoints + __license__ = 'GPL 3' __copyright__ = '2010, Hiroshi Miura ' __docformat__ = 'restructuredtext en' -''' -Decode unicode text to an ASCII representation of the text in Vietnamese. -''' - -from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder -from ebook_converter.ebooks.unihandecode.vncodepoints import CODEPOINTS as HANCODES -from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS - - -class Vndecoder(Unidecoder): +class Vndecoder(unidecoder.Unidecoder): codepoints = {} def __init__(self): - self.codepoints = CODEPOINTS - self.codepoints.update(HANCODES) + self.codepoints = unicodepoints.CODEPOINTS + self.codepoints.update(vncodepoints.CODEPOINTS) diff --git a/ebook_converter/ebooks/unihandecode/zhcodepoints.py b/ebook_converter/ebooks/unihandecode/zhcodepoints.py index 57e4de3..244ff2e 100644 --- a/ebook_converter/ebooks/unihandecode/zhcodepoints.py +++ b/ebook_converter/ebooks/unihandecode/zhcodepoints.py @@ -1,15 +1,11 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - +""" +Unicode code point dictionary. +Based on Unicode.org Unihan database. +""" __license__ = 'GPL 3' __copyright__ = '2010 Hiroshi Miura ' __docformat__ = 'restructuredtext en' -''' -Unicode code point dictionary. -Based on Unicode.org Unihan database. -''' - CODEPOINTS = { 'x34':[ 'Qiu ','Tian ','','','Kua ','Wu ','Yin ','','','','','','Si ','','','', diff --git a/ebook_converter/library/__init__.py b/ebook_converter/library/__init__.py index 7c1bc31..c893e39 100644 --- a/ebook_converter/library/__init__.py +++ b/ebook_converter/library/__init__.py @@ -1,14 +1,14 @@ -from __future__ import absolute_import, division, print_function, unicode_literals +""" +Code to manage ebook library +""" +import os + +from ebook_converter.polyglot.builtins import range + __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' -''' Code to manage ebook library''' - - -import os -from ebook_converter.polyglot.builtins import range - def db(path=None, read_only=False): from ebook_converter.db.legacy import LibraryDatabase diff --git a/ebook_converter/library/catalogs/__init__.py b/ebook_converter/library/catalogs/__init__.py index 53303c8..6b4a9a7 100644 --- a/ebook_converter/library/catalogs/__init__.py +++ b/ebook_converter/library/catalogs/__init__.py @@ -1,12 +1,7 @@ -#!/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 ' __docformat__ = 'restructuredtext en' - FIELDS = ['all', 'title', 'title_sort', 'author_sort', 'authors', 'comments', 'cover', 'formats','id', 'isbn', 'library_name','ondevice', 'pubdate', 'publisher', 'rating', 'series_index', 'series', 'size', 'tags', 'timestamp', diff --git a/ebook_converter/library/catalogs/bibtex.py b/ebook_converter/library/catalogs/bibtex.py index 1ed6497..3a609ad 100644 --- a/ebook_converter/library/catalogs/bibtex.py +++ b/ebook_converter/library/catalogs/bibtex.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import re, codecs, os, numbers from collections import namedtuple @@ -17,6 +9,11 @@ from ebook_converter.ebooks.metadata import format_isbn from ebook_converter.polyglot.builtins import filter, string_or_bytes, unicode_type +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class BIBTEX(CatalogPlugin): 'BIBTEX catalog generator' diff --git a/ebook_converter/library/catalogs/csv_xml.py b/ebook_converter/library/catalogs/csv_xml.py index 4594f72..77216e2 100644 --- a/ebook_converter/library/catalogs/csv_xml.py +++ b/ebook_converter/library/catalogs/csv_xml.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import re, codecs, os from collections import namedtuple @@ -15,6 +7,11 @@ from ebook_converter.customize.conversion import DummyReporter from ebook_converter.polyglot.builtins import unicode_type +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + class CSV_XML(CatalogPlugin): 'CSV/XML catalog generator' diff --git a/ebook_converter/library/catalogs/epub_mobi.py b/ebook_converter/library/catalogs/epub_mobi.py index f03ddf3..171b7c2 100644 --- a/ebook_converter/library/catalogs/epub_mobi.py +++ b/ebook_converter/library/catalogs/epub_mobi.py @@ -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 ' -__docformat__ = 'restructuredtext en' - import datetime, os, time from collections import namedtuple @@ -18,6 +10,11 @@ from ebook_converter.ptempfile import PersistentTemporaryFile from ebook_converter.utils.localization import calibre_langcode_to_name, canonicalize_lang, get_lang from ebook_converter.polyglot.builtins import unicode_type + +__license__ = 'GPL v3' +__copyright__ = '2012, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + Option = namedtuple('Option', 'option, default, dest, action, help') diff --git a/ebook_converter/library/comments.py b/ebook_converter/library/comments.py index cc9082f..dc6d1f9 100644 --- a/ebook_converter/library/comments.py +++ b/ebook_converter/library/comments.py @@ -1,9 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai -# License: GPLv3 Copyright: 2010, Kovid Goyal - -from __future__ import absolute_import, division, print_function, unicode_literals - import re from ebook_converter import prepare_string_for_xml @@ -15,6 +9,7 @@ from ebook_converter.ebooks.BeautifulSoup import ( from ebook_converter.utils.html2text import html2text from ebook_converter.polyglot.builtins import unicode_type + # Hackish - ignoring sentences ending or beginning in numbers to avoid # confusion with decimal points. lost_cr_pat = re.compile('([a-z])([\\.\\?!])([A-Z])') diff --git a/ebook_converter/library/field_metadata.py b/ebook_converter/library/field_metadata.py index ad597f9..40b8586 100644 --- a/ebook_converter/library/field_metadata.py +++ b/ebook_converter/library/field_metadata.py @@ -1,11 +1,8 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -''' +""" Created on 25 May 2010 @author: charles -''' - +""" import traceback from collections import OrderedDict diff --git a/ebook_converter/polyglot/binary.py b/ebook_converter/polyglot/binary.py index 417e958..bf21e2d 100644 --- a/ebook_converter/polyglot/binary.py +++ b/ebook_converter/polyglot/binary.py @@ -1,9 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPL v3 Copyright: 2019, Kovid Goyal - -from __future__ import absolute_import, division, print_function, unicode_literals - from base64 import standard_b64decode, standard_b64encode from binascii import hexlify, unhexlify diff --git a/ebook_converter/polyglot/builtins.py b/ebook_converter/polyglot/builtins.py index cb78f7f..15dca35 100644 --- a/ebook_converter/polyglot/builtins.py +++ b/ebook_converter/polyglot/builtins.py @@ -1,12 +1,7 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPL v3 Copyright: 2018, Kovid Goyal - -from __future__ import absolute_import, division, print_function, unicode_literals - import os import sys + is_py3 = sys.version_info.major >= 3 native_string_type = str iterkeys = iter diff --git a/ebook_converter/polyglot/functools.py b/ebook_converter/polyglot/functools.py index bb77c21..589999f 100644 --- a/ebook_converter/polyglot/functools.py +++ b/ebook_converter/polyglot/functools.py @@ -1,13 +1,8 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPL v3 Copyright: 2019, Kovid Goyal - -from __future__ import absolute_import, division, print_function, unicode_literals - from ebook_converter.polyglot.builtins import is_py3 if is_py3: from functools import lru_cache else: from backports.functools_lru_cache import lru_cache + lru_cache diff --git a/ebook_converter/polyglot/urllib.py b/ebook_converter/polyglot/urllib.py index 11bce1f..97ca92a 100644 --- a/ebook_converter/polyglot/urllib.py +++ b/ebook_converter/polyglot/urllib.py @@ -1,11 +1,6 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPL v3 Copyright: 2018, Kovid Goyal - -from __future__ import absolute_import - from ebook_converter.polyglot.builtins import is_py3 + if is_py3: from urllib.request import (build_opener, getproxies, install_opener, # noqa HTTPBasicAuthHandler, HTTPCookieProcessor, HTTPDigestAuthHandler, # noqa diff --git a/ebook_converter/spell/__init__.py b/ebook_converter/spell/__init__.py index 8b5198f..0eea759 100644 --- a/ebook_converter/spell/__init__.py +++ b/ebook_converter/spell/__init__.py @@ -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__ = '2014, Kovid Goyal ' - from collections import namedtuple import json import pkg_resources from ebook_converter.utils.localization import canonicalize_lang + +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + DictionaryLocale = namedtuple('DictionaryLocale', 'langcode countrycode') ccodes, ccodemap, country_names = None, None, None diff --git a/ebook_converter/tinycss/color3.py b/ebook_converter/tinycss/color3.py index e0cb0bd..6b63a6b 100644 --- a/ebook_converter/tinycss/color3.py +++ b/ebook_converter/tinycss/color3.py @@ -1,4 +1,3 @@ -# coding: utf8 """ tinycss.colors3 --------------- @@ -12,8 +11,6 @@ :copyright: (c) 2012 by Simon Sapin. :license: BSD, see LICENSE for more details. """ - -from __future__ import unicode_literals, division import collections import itertools import re diff --git a/ebook_converter/tinycss/css21.py b/ebook_converter/tinycss/css21.py index 7581e8f..2ed2095 100644 --- a/ebook_converter/tinycss/css21.py +++ b/ebook_converter/tinycss/css21.py @@ -1,4 +1,3 @@ -# coding: utf8 """ tinycss.css21 ------------- @@ -9,8 +8,6 @@ :copyright: (c) 2012 by Simon Sapin. :license: BSD, see LICENSE for more details. """ - -from __future__ import unicode_literals from itertools import chain, islice from ebook_converter.tinycss.decoding import decode diff --git a/ebook_converter/tinycss/decoding.py b/ebook_converter/tinycss/decoding.py index f8e86fe..1f683e1 100644 --- a/ebook_converter/tinycss/decoding.py +++ b/ebook_converter/tinycss/decoding.py @@ -1,4 +1,3 @@ -# coding: utf8 """ tinycss.decoding ---------------- @@ -9,9 +8,6 @@ :copyright: (c) 2012 by Simon Sapin. :license: BSD, see LICENSE for more details. """ - -from __future__ import unicode_literals - import operator import re diff --git a/ebook_converter/tinycss/fonts3.py b/ebook_converter/tinycss/fonts3.py index ee959f7..cd32ec9 100644 --- a/ebook_converter/tinycss/fonts3.py +++ b/ebook_converter/tinycss/fonts3.py @@ -1,17 +1,14 @@ -#!/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 ' - - import re + from ebook_converter.polyglot.builtins import map from ebook_converter.tinycss.css21 import CSS21Parser, ParseError from ebook_converter.tinycss.tokenizer import tokenize_grouped +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + def parse_font_family_tokens(tokens): families = [] current_family = '' diff --git a/ebook_converter/tinycss/media3.py b/ebook_converter/tinycss/media3.py index dff6499..e429582 100644 --- a/ebook_converter/tinycss/media3.py +++ b/ebook_converter/tinycss/media3.py @@ -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__ = '2014, Kovid Goyal ' - from ebook_converter.tinycss.css21 import CSS21Parser from ebook_converter.tinycss.parsing import remove_whitespace, split_on_comma, ParseError from ebook_converter.polyglot.builtins import error_message +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + class MediaQuery(object): __slots__ = 'media_type', 'expressions', 'negated' diff --git a/ebook_converter/tinycss/page3.py b/ebook_converter/tinycss/page3.py index 8a4e150..391e0de 100644 --- a/ebook_converter/tinycss/page3.py +++ b/ebook_converter/tinycss/page3.py @@ -1,4 +1,3 @@ -# coding: utf8 """ tinycss.page3 ------------------ @@ -11,8 +10,6 @@ :copyright: (c) 2012 by Simon Sapin. :license: BSD, see LICENSE for more details. """ - -from __future__ import unicode_literals, division from .css21 import CSS21Parser, ParseError diff --git a/ebook_converter/tinycss/parsing.py b/ebook_converter/tinycss/parsing.py index 86e93c0..466a7f0 100644 --- a/ebook_converter/tinycss/parsing.py +++ b/ebook_converter/tinycss/parsing.py @@ -1,4 +1,3 @@ -# coding: utf8 """ tinycss.parsing --------------- @@ -8,12 +7,9 @@ :copyright: (c) 2012 by Simon Sapin. :license: BSD, see LICENSE for more details. """ - -from __future__ import unicode_literals - - # TODO: unit tests + def split_on_comma(tokens): """Split a list of tokens on commas, ie ``,`` DELIM tokens. diff --git a/ebook_converter/tinycss/tests/__init__.py b/ebook_converter/tinycss/tests/__init__.py index 991303e..44c3f2a 100644 --- a/ebook_converter/tinycss/tests/__init__.py +++ b/ebook_converter/tinycss/tests/__init__.py @@ -1,12 +1,9 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +import unittest + __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -import unittest - def jsonify(tokens): """Turn tokens into "JSON-compatible" data structures.""" diff --git a/ebook_converter/tinycss/tests/color3.py b/ebook_converter/tinycss/tests/color3.py index 036c193..4bc217d 100644 --- a/ebook_converter/tinycss/tests/color3.py +++ b/ebook_converter/tinycss/tests/color3.py @@ -1,13 +1,10 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +from tinycss.color3 import parse_color_string, hsl_to_rgb +from tinycss.tests import BaseTest + __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -from tinycss.color3 import parse_color_string, hsl_to_rgb -from tinycss.tests import BaseTest - class TestColor3(BaseTest): diff --git a/ebook_converter/tinycss/tests/css21.py b/ebook_converter/tinycss/tests/css21.py index 571d37a..47006bf 100644 --- a/ebook_converter/tinycss/tests/css21.py +++ b/ebook_converter/tinycss/tests/css21.py @@ -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 ' - import io import os import tempfile @@ -13,6 +6,11 @@ from tinycss.css21 import CSS21Parser from tinycss.tests.tokenizing import jsonify from tinycss.tests import BaseTest + +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + class CoreParser(CSS21Parser): """A parser that always accepts unparsed at-rules.""" def parse_at_rule(self, rule, stylesheet_rules, errors, context): diff --git a/ebook_converter/tinycss/tests/decoding.py b/ebook_converter/tinycss/tests/decoding.py index be3dde1..56ea96e 100644 --- a/ebook_converter/tinycss/tests/decoding.py +++ b/ebook_converter/tinycss/tests/decoding.py @@ -1,12 +1,10 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +from tinycss.decoding import decode +from tinycss.tests import BaseTest + __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -from tinycss.decoding import decode -from tinycss.tests import BaseTest def params(css, encoding, use_bom=False, expect_error=False, **kwargs): """Nicer syntax to make a tuple.""" diff --git a/ebook_converter/tinycss/tests/fonts3.py b/ebook_converter/tinycss/tests/fonts3.py index 08c7297..94d5358 100644 --- a/ebook_converter/tinycss/tests/fonts3.py +++ b/ebook_converter/tinycss/tests/fonts3.py @@ -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__ = '2014, Kovid Goyal ' - from tinycss.fonts3 import CSSFonts3Parser, parse_font_family, parse_font, serialize_font from tinycss.tests import BaseTest from polyglot.builtins import iteritems +__license__ = 'GPL v3' +__copyright__ = '2014, Kovid Goyal ' + + class TestFonts3(BaseTest): def test_font_face(self): diff --git a/ebook_converter/tinycss/tests/main.py b/ebook_converter/tinycss/tests/main.py index 321722b..cb5cfe3 100644 --- a/ebook_converter/tinycss/tests/main.py +++ b/ebook_converter/tinycss/tests/main.py @@ -1,11 +1,9 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +import unittest, os, argparse + __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -import unittest, os, argparse def find_tests(): from calibre.utils.run_tests import find_tests_in_dir diff --git a/ebook_converter/tinycss/tests/media3.py b/ebook_converter/tinycss/tests/media3.py index 0d37156..c94bc33 100644 --- a/ebook_converter/tinycss/tests/media3.py +++ b/ebook_converter/tinycss/tests/media3.py @@ -1,12 +1,10 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +from tinycss.media3 import CSSMedia3Parser, MediaQuery as MQ +from tinycss.tests import BaseTest, jsonify + __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -from tinycss.media3 import CSSMedia3Parser, MediaQuery as MQ -from tinycss.tests import BaseTest, jsonify def jsonify_expr(e): if e is None: diff --git a/ebook_converter/tinycss/tests/page3.py b/ebook_converter/tinycss/tests/page3.py index aa3fac3..736ccde 100644 --- a/ebook_converter/tinycss/tests/page3.py +++ b/ebook_converter/tinycss/tests/page3.py @@ -1,12 +1,10 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +from tinycss.page3 import CSSPage3Parser +from tinycss.tests import BaseTest + __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -from tinycss.page3 import CSSPage3Parser -from tinycss.tests import BaseTest class TestPage3(BaseTest): diff --git a/ebook_converter/tinycss/tests/tokenizing.py b/ebook_converter/tinycss/tests/tokenizing.py index e99077d..e4374f1 100644 --- a/ebook_converter/tinycss/tests/tokenizing.py +++ b/ebook_converter/tinycss/tests/tokenizing.py @@ -1,13 +1,10 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -from __future__ import absolute_import, division, print_function, unicode_literals +from tinycss.tests import BaseTest, jsonify +from tinycss.tokenizer import python_tokenize_flat, c_tokenize_flat, regroup + __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -from tinycss.tests import BaseTest, jsonify -from tinycss.tokenizer import python_tokenize_flat, c_tokenize_flat, regroup - if c_tokenize_flat is None: tokenizers = (python_tokenize_flat,) else: diff --git a/ebook_converter/tinycss/token_data.py b/ebook_converter/tinycss/token_data.py index dfbafc1..04f0eb1 100644 --- a/ebook_converter/tinycss/token_data.py +++ b/ebook_converter/tinycss/token_data.py @@ -1,4 +1,3 @@ -# coding: utf8 """ tinycss.token_data ------------------ @@ -8,9 +7,6 @@ :copyright: (c) 2012 by Simon Sapin. :license: BSD, see LICENSE for more details. """ - -from __future__ import unicode_literals - import re import sys import operator diff --git a/ebook_converter/tinycss/tokenizer.py b/ebook_converter/tinycss/tokenizer.py index 6e03c8b..8770c58 100644 --- a/ebook_converter/tinycss/tokenizer.py +++ b/ebook_converter/tinycss/tokenizer.py @@ -1,4 +1,3 @@ -# coding: utf8 """ tinycss.tokenizer ----------------- @@ -11,9 +10,6 @@ :copyright: (c) 2012 by Simon Sapin. :license: BSD, see LICENSE for more details. """ - -from __future__ import unicode_literals - from ebook_converter.tinycss import token_data diff --git a/ebook_converter/utils/cleantext.py b/ebook_converter/utils/cleantext.py index 79f7ed7..f376d1e 100644 --- a/ebook_converter/utils/cleantext.py +++ b/ebook_converter/utils/cleantext.py @@ -1,9 +1,5 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2010, Kovid Goyal -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 diff --git a/ebook_converter/utils/config.py b/ebook_converter/utils/config.py index 6608690..ee25fa7 100644 --- a/ebook_converter/utils/config.py +++ b/ebook_converter/utils/config.py @@ -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._ = _ diff --git a/ebook_converter/utils/date.py b/ebook_converter/utils/date.py index 8979a0b..d2cb829 100644 --- a/ebook_converter/utils/date.py +++ b/ebook_converter/utils/date.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + _utc_tz = utc_tz _local_tz = local_tz diff --git a/ebook_converter/utils/filenames.py b/ebook_converter/utils/filenames.py index 586663c..04d1f19 100644 --- a/ebook_converter/utils/filenames.py +++ b/ebook_converter/utils/filenames.py @@ -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 diff --git a/ebook_converter/utils/fonts/metadata.py b/ebook_converter/utils/fonts/metadata.py index 135e5c6..a2c247e 100644 --- a/ebook_converter/utils/fonts/metadata.py +++ b/ebook_converter/utils/fonts/metadata.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class UnsupportedFont(ValueError): pass diff --git a/ebook_converter/utils/fonts/scanner.py b/ebook_converter/utils/fonts/scanner.py index efea5f1..4463d0e 100644 --- a/ebook_converter/utils/fonts/scanner.py +++ b/ebook_converter/utils/fonts/scanner.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class NoFonts(ValueError): pass diff --git a/ebook_converter/utils/fonts/sfnt/__init__.py b/ebook_converter/utils/fonts/sfnt/__init__.py index f7534d9..561d9ca 100644 --- a/ebook_converter/utils/fonts/sfnt/__init__.py +++ b/ebook_converter/utils/fonts/sfnt/__init__.py @@ -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 ' __docformat__ = 'restructuredtext en' -from datetime import datetime, timedelta - def align_block(raw, multiple=4, pad=b'\0'): ''' diff --git a/ebook_converter/utils/fonts/sfnt/cff/constants.py b/ebook_converter/utils/fonts/sfnt/cff/constants.py index 62ddf05..8ac938b 100644 --- a/ebook_converter/utils/fonts/sfnt/cff/constants.py +++ b/ebook_converter/utils/fonts/sfnt/cff/constants.py @@ -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 ' __docformat__ = 'restructuredtext en' diff --git a/ebook_converter/utils/fonts/sfnt/cff/dict_data.py b/ebook_converter/utils/fonts/sfnt/cff/dict_data.py index 71bae35..d256b1f 100644 --- a/ebook_converter/utils/fonts/sfnt/cff/dict_data.py +++ b/ebook_converter/utils/fonts/sfnt/cff/dict_data.py @@ -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 ' __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"] diff --git a/ebook_converter/utils/fonts/sfnt/cff/table.py b/ebook_converter/utils/fonts/sfnt/cff/table.py index d167e2f..104ba27 100644 --- a/ebook_converter/utils/fonts/sfnt/cff/table.py +++ b/ebook_converter/utils/fonts/sfnt/cff/table.py @@ -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 ' -__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 ' +__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 diff --git a/ebook_converter/utils/fonts/sfnt/cmap.py b/ebook_converter/utils/fonts/sfnt/cmap.py index 5691a12..a9a08f1 100644 --- a/ebook_converter/utils/fonts/sfnt/cmap.py +++ b/ebook_converter/utils/fonts/sfnt/cmap.py @@ -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 ' -__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 ' +__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" diff --git a/ebook_converter/utils/fonts/sfnt/common.py b/ebook_converter/utils/fonts/sfnt/common.py index 696c156..5d2bd72 100644 --- a/ebook_converter/utils/fonts/sfnt/common.py +++ b/ebook_converter/utils/fonts/sfnt/common.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class Unpackable(object): def __init__(self, raw, offset): diff --git a/ebook_converter/utils/fonts/sfnt/container.py b/ebook_converter/utils/fonts/sfnt/container.py index 38c90d4..e21270e 100644 --- a/ebook_converter/utils/fonts/sfnt/container.py +++ b/ebook_converter/utils/fonts/sfnt/container.py @@ -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 -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 diff --git a/ebook_converter/utils/fonts/sfnt/errors.py b/ebook_converter/utils/fonts/sfnt/errors.py index e7d0e3c..ab01cb6 100644 --- a/ebook_converter/utils/fonts/sfnt/errors.py +++ b/ebook_converter/utils/fonts/sfnt/errors.py @@ -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 ' __docformat__ = 'restructuredtext en' diff --git a/ebook_converter/utils/fonts/sfnt/glyf.py b/ebook_converter/utils/fonts/sfnt/glyf.py index 3ccf3fb..50817f4 100644 --- a/ebook_converter/utils/fonts/sfnt/glyf.py +++ b/ebook_converter/utils/fonts/sfnt/glyf.py @@ -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 ' -__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 ' +__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 diff --git a/ebook_converter/utils/fonts/sfnt/gsub.py b/ebook_converter/utils/fonts/sfnt/gsub.py index 7d31d67..1288f0e 100644 --- a/ebook_converter/utils/fonts/sfnt/gsub.py +++ b/ebook_converter/utils/fonts/sfnt/gsub.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class SingleSubstitution(UnknownLookupSubTable): formats = {1, 2} diff --git a/ebook_converter/utils/fonts/sfnt/head.py b/ebook_converter/utils/fonts/sfnt/head.py index 4d09f86..6af8ddc 100644 --- a/ebook_converter/utils/fonts/sfnt/head.py +++ b/ebook_converter/utils/fonts/sfnt/head.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class HeadTable(UnknownTable): created = DateTimeProperty('_created') diff --git a/ebook_converter/utils/fonts/sfnt/kern.py b/ebook_converter/utils/fonts/sfnt/kern.py index 68d7476..57d878e 100644 --- a/ebook_converter/utils/fonts/sfnt/kern.py +++ b/ebook_converter/utils/fonts/sfnt/kern.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class KernTable(UnknownTable): version = FixedProperty('_version') diff --git a/ebook_converter/utils/fonts/sfnt/loca.py b/ebook_converter/utils/fonts/sfnt/loca.py index 1c5bdbe..07d60ca 100644 --- a/ebook_converter/utils/fonts/sfnt/loca.py +++ b/ebook_converter/utils/fonts/sfnt/loca.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + def four_byte_type_code(): for c in 'IL': a = array.array(c) diff --git a/ebook_converter/utils/fonts/sfnt/maxp.py b/ebook_converter/utils/fonts/sfnt/maxp.py index 060d3f6..8b81b27 100644 --- a/ebook_converter/utils/fonts/sfnt/maxp.py +++ b/ebook_converter/utils/fonts/sfnt/maxp.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class MaxpTable(UnknownTable): version = FixedProperty('_version') diff --git a/ebook_converter/utils/fonts/sfnt/subset.py b/ebook_converter/utils/fonts/sfnt/subset.py index 4604c19..78ca7ee 100644 --- a/ebook_converter/utils/fonts/sfnt/subset.py +++ b/ebook_converter/utils/fonts/sfnt/subset.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + # TrueType outlines {{{ diff --git a/ebook_converter/utils/fonts/utils.py b/ebook_converter/utils/fonts/utils.py index 4a51f8c..9716221 100644 --- a/ebook_converter/utils/fonts/utils.py +++ b/ebook_converter/utils/fonts/utils.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class UnsupportedFont(ValueError): pass diff --git a/ebook_converter/utils/formatter.py b/ebook_converter/utils/formatter.py index e7379db..87fa1cb 100644 --- a/ebook_converter/utils/formatter.py +++ b/ebook_converter/utils/formatter.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class _Parser(object): LEX_OP = 1 LEX_ID = 2 diff --git a/ebook_converter/utils/formatter_functions.py b/ebook_converter/utils/formatter_functions.py index e5026c8..310c3cd 100644 --- a/ebook_converter/utils/formatter_functions.py +++ b/ebook_converter/utils/formatter_functions.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class FormatterFunctions(object): error_function_body = ('def evaluate(self, formatter, kwargs, mi, locals):\n' diff --git a/ebook_converter/utils/html2text.py b/ebook_converter/utils/html2text.py index b17e223..96ed1ca 100644 --- a/ebook_converter/utils/html2text.py +++ b/ebook_converter/utils/html2text.py @@ -1,9 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2019, Kovid Goyal -from __future__ import absolute_import, division, print_function, unicode_literals - - def html2text(html): from html2text import HTML2Text import re diff --git a/ebook_converter/utils/icu.py b/ebook_converter/utils/icu.py index 3cac366..0db3fd7 100644 --- a/ebook_converter/utils/icu.py +++ b/ebook_converter/utils/icu.py @@ -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 ' __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 diff --git a/ebook_converter/utils/img.py b/ebook_converter/utils/img.py index 46f24f0..dac0d5d 100644 --- a/ebook_converter/utils/img.py +++ b/ebook_converter/utils/img.py @@ -1,8 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2015-2019, Kovid Goyal -from __future__ import absolute_import, division, print_function, unicode_literals - import errno import os import shutil diff --git a/ebook_converter/utils/imghdr.py b/ebook_converter/utils/imghdr.py index 3774c64..9bd273e 100644 --- a/ebook_converter/utils/imghdr.py +++ b/ebook_converter/utils/imghdr.py @@ -1,15 +1,13 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2016, Kovid Goyal -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 diff --git a/ebook_converter/utils/ipc/__init__.py b/ebook_converter/utils/ipc/__init__.py index 6e35132..77d19e6 100644 --- a/ebook_converter/utils/ipc/__init__.py +++ b/ebook_converter/utils/ipc/__init__.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + VADDRESS = None diff --git a/ebook_converter/utils/ipc/launch.py b/ebook_converter/utils/ipc/launch.py index 94354ae..dec57d7 100644 --- a/ebook_converter/utils/ipc/launch.py +++ b/ebook_converter/utils/ipc/launch.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + if iswindows: - import win32process try: windows_null_file = open(os.devnull, 'wb') except: diff --git a/ebook_converter/utils/ipc/simple_worker.py b/ebook_converter/utils/ipc/simple_worker.py index 0a6cb83..d297695 100644 --- a/ebook_converter/utils/ipc/simple_worker.py +++ b/ebook_converter/utils/ipc/simple_worker.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + + class WorkerError(Exception): def __init__(self, msg, orig_tb='', log_path=None): diff --git a/ebook_converter/utils/iso8601.py b/ebook_converter/utils/iso8601.py index 2b52fbd..d0cb8a1 100644 --- a/ebook_converter/utils/iso8601.py +++ b/ebook_converter/utils/iso8601.py @@ -1,8 +1,3 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2016, Kovid Goyal - -from __future__ import absolute_import, division, print_function, unicode_literals from datetime import datetime from dateutil.tz import tzlocal, tzutc, tzoffset diff --git a/ebook_converter/utils/localunzip.py b/ebook_converter/utils/localunzip.py index 2aaa74e..1a471b3 100644 --- a/ebook_converter/utils/localunzip.py +++ b/ebook_converter/utils/localunzip.py @@ -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 ' -__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 ' +__docformat__ = 'restructuredtext en' + HEADER_SIG = 0x04034b50 HEADER_BYTE_SIG = pack(b' - -from __future__ import absolute_import, division, print_function, unicode_literals - from ebook_converter.polyglot.builtins import unicode_type from ebook_converter.constants import ispy3 diff --git a/ebook_converter/utils/shared_file.py b/ebook_converter/utils/shared_file.py index ac6fecd..251d6ff 100644 --- a/ebook_converter/utils/shared_file.py +++ b/ebook_converter/utils/shared_file.py @@ -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 ' - -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 ' # speedup, err = plugins['speedup'] diff --git a/ebook_converter/utils/short_uuid.py b/ebook_converter/utils/short_uuid.py index efe1a50..0293420 100644 --- a/ebook_converter/utils/short_uuid.py +++ b/ebook_converter/utils/short_uuid.py @@ -1,12 +1,6 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2015, Kovid Goyal -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 diff --git a/ebook_converter/utils/smartypants.py b/ebook_converter/utils/smartypants.py index 7f44d06..fa46143 100644 --- a/ebook_converter/utils/smartypants.py +++ b/ebook_converter/utils/smartypants.py @@ -1,11 +1,3 @@ -#!/usr/bin/python2 -# vim:fileencoding=utf-8 - -from __future__ import absolute_import, division, print_function, unicode_literals - -__author__ = "Chad Miller , Kovid Goyal " -__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 , Kovid Goyal " +__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*>$') diff --git a/ebook_converter/utils/speedups.py b/ebook_converter/utils/speedups.py index 6121f9e..10665e1 100644 --- a/ebook_converter/utils/speedups.py +++ b/ebook_converter/utils/speedups.py @@ -1,10 +1,5 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPLv3 Copyright: 2016, Kovid Goyal - -from __future__ import absolute_import, division, print_function, unicode_literals - import os + from ebook_converter.polyglot.builtins import range, unicode_type diff --git a/ebook_converter/utils/terminal.py b/ebook_converter/utils/terminal.py index 62ff25c..005ed45 100644 --- a/ebook_converter/utils/terminal.py +++ b/ebook_converter/utils/terminal.py @@ -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 ' __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', diff --git a/ebook_converter/utils/titlecase.py b/ebook_converter/utils/titlecase.py index 46cea9b..17063d2 100644 --- a/ebook_converter/utils/titlecase.py +++ b/ebook_converter/utils/titlecase.py @@ -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' diff --git a/ebook_converter/utils/wordcount.py b/ebook_converter/utils/wordcount.py index 86ba287..0c92629 100644 --- a/ebook_converter/utils/wordcount.py +++ b/ebook_converter/utils/wordcount.py @@ -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 diff --git a/ebook_converter/utils/xml_parse.py b/ebook_converter/utils/xml_parse.py index 9e20af7..c83bd5a 100644 --- a/ebook_converter/utils/xml_parse.py +++ b/ebook_converter/utils/xml_parse.py @@ -1,15 +1,9 @@ -#!/usr/bin/env python2 -# vim:fileencoding=utf-8 -# License: GPL v3 Copyright: 2019, Kovid Goyal - -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: # ]> - fs = etree.fromstring diff --git a/ebook_converter/utils/zipfile.py b/ebook_converter/utils/zipfile.py index e953665..e279613 100644 --- a/ebook_converter/utils/zipfile.py +++ b/ebook_converter/utils/zipfile.py @@ -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"]