id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
27,400 | opf.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/check/opf.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
from lxml import etree
from calibre import prepare_string_for_xml as xml
from calibre.ebooks.oeb.base import DC, DC11_NS, OPF, OPF2_NS, XHTML_MIME
from calibre.ebooks.oeb.polish.check.base import WARN, BaseErr... | 17,629 | Python | .py | 327 | 44.538226 | 152 | 0.624419 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,401 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/check/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
| 112 | Python | .py | 3 | 34.666667 | 61 | 0.673077 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,402 | fonts.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/check/fonts.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
from css_parser.css import CSSRule
from tinycss.fonts3 import parse_font_family
from calibre import force_unicode
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES
from calibre.ebooks.oeb.polish.check.b... | 5,925 | Python | .py | 107 | 42.504673 | 150 | 0.593443 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,403 | base.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/check/base.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
from contextlib import closing
from functools import partial
from multiprocessing.pool import ThreadPool
from calibre import detect_ncpus as cpu_count
DEBUG, INFO, WARN, ERROR, CRITICAL = range(5)
class Bas... | 1,329 | Python | .py | 40 | 27.15 | 92 | 0.621664 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,404 | css.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/check/css.py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import atexit
import json
import numbers
import sys
from collections import namedtuple
from itertools import repeat
from qt.core import QApplication, QEventLoop, pyqtSignal, sip
from qt.webengine import QWebEnginePage, QWeb... | 7,789 | Python | .py | 204 | 30.269608 | 131 | 0.620507 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,405 | main.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/check/main.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
from collections import namedtuple
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES
from calibre.ebooks.oeb.polish.check.base import WARN, run_checkers
from calibre.ebooks.oeb.polish.check.fonts import... | 6,681 | Python | .py | 157 | 34.031847 | 113 | 0.627868 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,406 | container.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/tests/container.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import os
import subprocess
from zipfile import ZipFile
from calibre import CurrentDir
from calibre.ebooks.oeb.polish.container import OCF_NS, clone_container
from calibre.ebooks.oeb.polish.container import ge... | 11,552 | Python | .py | 244 | 37.17623 | 182 | 0.586935 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,407 | parsing.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/tests/parsing.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
from functools import partial
from html5lib.constants import cdataElements, rcdataElements
from lxml import etree
from calibre.ebooks.oeb.base import SVG_NS, XHTML_NS, XLINK_NS, XPath
from calibre.ebooks.oeb.... | 10,503 | Python | .py | 182 | 51.104396 | 147 | 0.628541 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,408 | structure.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/tests/structure.py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import os
from functools import partial
from io import BytesIO
from itertools import count
from zipfile import ZIP_STORED, ZipFile
from calibre.ebooks.metadata.book.base import Metadata
from calibre.ebooks.metadata.opf3 imp... | 12,951 | Python | .py | 229 | 47.100437 | 138 | 0.576107 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,409 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/tests/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
| 112 | Python | .py | 3 | 34.666667 | 61 | 0.673077 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,410 | base.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/tests/base.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import os
import shutil
import unittest
import calibre.ebooks.oeb.polish.container as pc
from calibre import CurrentDir
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
from calib... | 3,799 | Python | .py | 97 | 31.134021 | 104 | 0.607182 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,411 | cascade.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/tests/cascade.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2016, Kovid Goyal <kovid at kovidgoyal.net>'
from functools import partial
from css_parser import parseStyle
from calibre.constants import iswindows
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES
from calibre.ebooks.oeb.polish.cascade import D... | 11,437 | Python | .py | 202 | 46.371287 | 157 | 0.564849 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,412 | main.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/polish/tests/main.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
from calibre.utils.run_tests import find_tests_in_package, run_tests
def find_tests():
return find_tests_in_package('calibre.ebooks.oeb.polish.tests')
if __name__ == '__main__':
try:
import ... | 404 | Python | .py | 12 | 29.416667 | 68 | 0.677922 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,413 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/display/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
| 149 | Python | .py | 4 | 35 | 58 | 0.678571 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,414 | webview.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/display/webview.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re
from calibre import guess_type
from polyglot.builtins import iteritems
class EntityDeclarationProcessor: # {{{
def __init__(self, html):
self.decl... | 2,322 | Python | .py | 57 | 33.789474 | 97 | 0.621104 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,415 | split.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/split.py | __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 tra... | 18,723 | Python | .py | 431 | 30.171694 | 150 | 0.520184 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,416 | trimmanifest.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/trimmanifest.py | '''
OPF manifest trimming transform.
'''
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
from calibre.ebooks.oeb.base import CSS_MIME, OEB_DOCS, iterlinks, urlnormalize
from polyglot.urllib import urldefrag
class ManifestTrimmer:
@classmethod
def config(cls, cfg... | 2,678 | Python | .py | 64 | 26.859375 | 79 | 0.505372 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,417 | htmltoc.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/htmltoc.py | '''
HTML-TOC-adding transform.
'''
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
from calibre.ebooks.oeb.base import CSS_MIME, XHTML, XHTML_MIME, XHTML_NS, XML, XPath, element
from calibre.utils.localization import __
__all__ = ['HTMLTOCAdder']
DEFAULT_TITLE = __('Table... | 4,172 | Python | .py | 111 | 28.18018 | 94 | 0.561404 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,418 | rescale.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/rescale.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre import fit_image
class RescaleImages:
'Rescale all images to fit inside given screen size'
def __init__(self, check_colorspaces=False):
self... | 3,858 | Python | .py | 82 | 31.317073 | 99 | 0.504521 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,419 | manglecase.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/manglecase.py | '''
CSS case-mangling transform.
'''
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
from lxml import etree
from calibre.ebooks.oeb.base import CSS_MIME, XHTML, XHTML_NS, namespace
from calibre.ebooks.oeb.stylizer import Stylizer
from calibre.utils.icu import lower as icu_... | 3,942 | Python | .py | 103 | 27.84466 | 83 | 0.573483 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,420 | page_margin.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/page_margin.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import numbers
from collections import Counter
from calibre.ebooks.oeb.base import XPath, barename
from polyglot.builtins import iteritems
class RemoveAdobeMargins:
'... | 6,357 | Python | .py | 151 | 29.596026 | 101 | 0.537202 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,421 | cover.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/cover.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import textwrap
from calibre import guess_type
from calibre.utils.imghdr import identify
from calibre.utils.xml_parse import safe_xml_fromstring
from polyglot.urllib import... | 6,667 | Python | .py | 155 | 29.670968 | 86 | 0.517475 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,422 | structure.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/structure.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re
import uuid
from collections import Counter, OrderedDict
from lxml import etree
from calibre.ebooks import ConversionError
from calibre.ebooks.oeb.base import TO... | 13,615 | Python | .py | 287 | 30.756098 | 106 | 0.497103 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,423 | embed_fonts.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/embed_fonts.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import logging
from collections import defaultdict
import css_parser
from lxml import etree
from calibre import guess_type
from calibre.ebooks.oeb.base import CSS_MIME, XHTML, XPath
from calibre.ebooks.oeb.po... | 10,391 | Python | .py | 218 | 36.807339 | 155 | 0.583366 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,424 | flatcss.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/flatcss.py | '''
CSS flattening transform.
'''
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
import math
import numbers
import operator
import re
from collections import defaultdict
from xml.dom import SyntaxErr
import css_parser
from css_parser.css import Property
from lxml import ... | 30,110 | Python | .py | 647 | 32.933539 | 139 | 0.533408 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,425 | unsmarten.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/unsmarten.py | __license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en'
from calibre.ebooks.oeb.base import OEB_DOCS, XPath, barename
from calibre.utils.unsmarten import unsmarten_text
class UnsmartenPunctuation:
def __init__(self):
self.html_tags = XPath... | 890 | Python | .py | 21 | 32.714286 | 61 | 0.579374 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,426 | metadata.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/metadata.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import re
from calibre import guess_type
from calibre.utils.date import isoformat, now
from polyglot.builtins import iteritems
def meta_info_to_oeb_metadata(mi,... | 8,541 | Python | .py | 204 | 30.779412 | 101 | 0.55426 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,427 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
| 146 | Python | .py | 4 | 35 | 58 | 0.678571 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,428 | linearize_tables.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/linearize_tables.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.ebooks.oeb.base import OEB_DOCS, XHTML, XPath
class LinearizeTables:
def linearize(self, root):
for x in XPath('//h:table|//h:td|//h:tr|//h:th|//... | 947 | Python | .py | 21 | 32.904762 | 76 | 0.515778 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,429 | data_url.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/data_url.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import re
from calibre.ebooks.oeb.base import XPath, urlunquote
from polyglot.builtins import as_bytes
class DataURL:
def __call__(self, oeb, opts):
from calibre.utils.imghdr import what
... | 1,984 | Python | .py | 44 | 31.545455 | 93 | 0.538302 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,430 | jacket.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/jacket.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import re
import sys
from contextlib import suppress
from string import Formatter
from xml.sax.saxutils import escape
from calibre import guess_type, prepare_stri... | 17,034 | Python | .py | 391 | 33.214834 | 114 | 0.577835 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,431 | filenames.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/filenames.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import posixpath
from lxml import etree
from calibre.ebooks.oeb.base import rewrite_links, urlnormalize
from polyglot.urllib import urldefrag, urlparse
class RenameFiles... | 6,077 | Python | .py | 147 | 29.537415 | 93 | 0.56442 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,432 | guide.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/guide.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
class Clean:
'''Clean up guide, leaving only known values '''
def __call__(self, oeb, opts):
self.oeb, self.log, self.opts = oeb, oeb.log, opts
if... | 2,198 | Python | .py | 45 | 33.688889 | 80 | 0.504198 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,433 | rasterize.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/rasterize.py | '''
SVG rasterization transform.
'''
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
import os
import re
from base64 import standard_b64encode
from functools import lru_cache
from lxml import etree
from qt.core import QBuffer, QByteArray, QColor, QImage, QIODevice, QPainte... | 11,536 | Python | .py | 237 | 38.966245 | 1,114 | 0.633265 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,434 | alt_text.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/alt_text.py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
from io import BytesIO
from PIL import Image
from calibre.ebooks.oeb.base import SVG_MIME, urlnormalize, xpath
from calibre.utils.img import read_alt_text
def process_spine_item(item, hrefs, log):
html = item.data
... | 1,141 | Python | .py | 27 | 33.222222 | 87 | 0.613575 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,435 | subset.py | kovidgoyal_calibre/src/calibre/ebooks/oeb/transforms/subset.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
from collections import defaultdict
from io import BytesIO
from tinycss.fonts3 import parse_font_family
from calibre.ebooks.oeb.base import css_text, urlnorma... | 11,736 | Python | .py | 287 | 29.425087 | 103 | 0.529494 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,436 | input.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/input.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import operator
import textwrap
from copy import copy, deepcopy
from lxml import etree
from calibre import guess_type
from polyglot.builtins import as_bytes
class Canvas... | 14,393 | Python | .py | 350 | 29.688571 | 102 | 0.528125 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,437 | meta.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/meta.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
"""
This module presents an easy to use interface for getting and setting
meta information in LRF files.
Just create an L{LRFMetaFile} object and use its properties
to get and set meta information. For example:
>>> lrf = LRFMetaFil... | 27,568 | Python | .py | 650 | 33.187692 | 154 | 0.584048 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,438 | tags.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/tags.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
''''''
import struct
from calibre.ebooks.lrf import LRFParseError
class Tag:
tags = {
0x00 : (6, "*ObjectStart"),
0x01 : (0, "*ObjectEnd"),
0x02 : (4, "*ObjectInfoLink"),
... | 8,699 | Python | .py | 243 | 21.460905 | 81 | 0.377177 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,439 | lrfparser.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/lrfparser.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
''''''
import array
import codecs
import logging
import os
import re
import sys
from itertools import chain
from calibre import setup_cli_handlers
from calibre.ebooks.lrf.meta import LRFMetaFile
from calibre.ebooks.lrf.objects impo... | 7,418 | Python | .py | 160 | 36.93125 | 118 | 0.590966 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,440 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/__init__.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
"""
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}.
"""
from calibre.ebooks import ConversionError
from calibre.ebooks.lrf.fonts import FON... | 4,421 | Python | .py | 97 | 36.608247 | 99 | 0.60803 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,441 | fonts.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/fonts.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
from PIL import ImageFont
'''
Default fonts used in the PRS500
'''
LIBERATION_FONT_MAP = {
'Swis721 BT Roman' : 'LiberationSans-Regular',
'Dutch801 Rm BT Roman' : 'LiberationSerif-Regular',
... | 1,095 | Python | .py | 25 | 37.84 | 116 | 0.659454 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,442 | objects.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/objects.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import array
import collections
import io
import re
import struct
import zlib
from calibre import prepare_string_for_xml
from calibre.ebooks.html_entities import entity_to_unicode_in_python
from calibre.ebooks.lrf import PRS500_PROF... | 41,785 | Python | .py | 1,043 | 30.238734 | 131 | 0.542007 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,443 | convert_from.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/lrs/convert_from.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
Compile a LRS file into a LRF file.
'''
import logging
import os
import sys
from calibre import setup_cli_handlers
from calibre.ebooks.BeautifulSoup import BeautifulStoneSoup, CData, NavigableString, Tag
from calibre.ebooks.cha... | 12,861 | Python | .py | 304 | 30.404605 | 120 | 0.53781 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,444 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/lrs/__init__.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
''''''
| 94 | Python | .py | 3 | 30.333333 | 61 | 0.604396 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,445 | convert_from.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/html/convert_from.py | # License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
import copy
import glob
import os
import re
import sys
import tempfile
from collections import deque
from itertools import chain
from math import ceil, floor
from calibre import __appname__, entity_regex, entity_to_unicode, fit_image, force_unic... | 84,836 | Python | .py | 1,788 | 32.563758 | 146 | 0.512368 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,446 | color_map.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/html/color_map.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import re
NAME_MAP = {
'aliceblue': '#F0F8FF',
'antiquewhite': '#FAEBD7',
'aqua': '#00FFFF',
'aquamarine': '#7FFFD4',
'azure': '#F0FFFF',
'beige': '#F5F5... | 4,023 | Python | .py | 108 | 24.777778 | 108 | 0.446547 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,447 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/html/__init__.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
"""
This package contains code to convert HTML ebooks to LRF ebooks.
"""
__docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
| 240 | Python | .py | 7 | 33.142857 | 64 | 0.681034 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,448 | table.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/html/table.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import math
import numbers
import re
import sys
from calibre.ebooks.lrf.fonts import get_font
from calibre.ebooks.lrf.pylrs.pylrs import CR, CharButton, LrsTextTag, Paragraph, Plot, Span, Text, TextBlock
from polyglot.builtins impor... | 13,953 | Python | .py | 333 | 30.201201 | 109 | 0.544878 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,449 | pylrs.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/pylrs/pylrs.py | # Copyright (c) 2007 Mike Higgins (Falstaff)
# Modifications from the original:
# Copyright (C) 2007 Kovid Goyal <kovid@kovidgoyal.net>
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software with... | 80,084 | Python | .py | 1,866 | 33.415327 | 114 | 0.621672 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,450 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/pylrs/__init__.py | """
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.
"""
| 175 | Python | .py | 5 | 34 | 80 | 0.8 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,451 | elements.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/pylrs/elements.py | """ elements.py -- replacements and helpers for ElementTree """
from polyglot.builtins import string_or_bytes
class ElementWriter:
def __init__(self, e, header=False, sourceEncoding="ascii",
spaceBeforeClose=True, outputEncodingName="UTF-16"):
self.header = header
self.e = e
... | 2,101 | Python | .py | 58 | 26.413793 | 86 | 0.551605 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,452 | pylrf.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/pylrs/pylrf.py | #!/usr/bin/env python
"""
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 codecs
import io
import os
import struct
import zlib
from polyglot.builtins import iteritems, string_or_bytes
from .pylrfopt i... | 24,069 | Python | .py | 619 | 30.476575 | 80 | 0.62288 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,453 | pylrfopt.py | kovidgoyal_calibre/src/calibre/ebooks/lrf/pylrs/pylrfopt.py | def _optimize(tagList, tagName, conversion):
# copy the tag of interest plus any text
newTagList = []
for tag in tagList:
if tag.name == tagName or tag.name == "rawtext":
newTagList.append(tag)
# now, eliminate any duplicates (leaving the last one)
for i, newTag in enumerate(new... | 1,466 | Python | .py | 35 | 35.228571 | 70 | 0.669474 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,454 | htmls.py | kovidgoyal_calibre/src/calibre/ebooks/readability/htmls.py | import re
import lxml.html
from lxml.html import tostring
from calibre.ebooks.chardet import xml_to_unicode
from calibre.ebooks.readability.cleaners import clean_attributes, normalize_spaces
from polyglot.builtins import iteritems
def build_doc(page):
page_unicode = xml_to_unicode(page, strip_encoding_pats=True... | 3,934 | Python | .py | 97 | 31.319588 | 121 | 0.542257 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,455 | debug.py | kovidgoyal_calibre/src/calibre/ebooks/readability/debug.py | def save_to_file(text, filename):
with open(filename, 'wb') as f:
f.write(b'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />')
f.write(text.encode('utf-8'))
uids = {}
def describe(node, depth=2):
if not hasattr(node, 'tag'):
return "[%s]" % type(node)
name = ... | 855 | Python | .py | 24 | 28.625 | 89 | 0.525998 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,456 | readability.py | kovidgoyal_calibre/src/calibre/ebooks/readability/readability.py | #!/usr/bin/env python
import re
import sys
from collections import defaultdict
from lxml.html import document_fromstring, fragment_fromstring
from lxml.html import tostring as htostring
from calibre.ebooks.readability.cleaners import clean_attributes, html_cleaner
from calibre.ebooks.readability.htmls import build_... | 20,623 | Python | .py | 428 | 35.5 | 199 | 0.531868 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,457 | cleaners.py | kovidgoyal_calibre/src/calibre/ebooks/readability/cleaners.py | # strip out a set of nuisance html attributes that can mess up rendering in RSS feeds
import re
try:
from lxml_html_clean import Cleaner
except ImportError:
from lxml.html.clean import Cleaner
bad_attrs = ['width', 'height', 'style', '[-a-z]*color', 'background[-a-z]*', 'on*']
single_quoted = "'[^']+'"
double... | 1,294 | Python | .py | 32 | 34.8125 | 85 | 0.618022 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,458 | tweak.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/tweak.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import glob
import os
from calibre import CurrentDir
from calibre.customize.ui import plugin_for_input_format, plugin_for_output_format
from calibre.ebooks import DRMError
... | 3,532 | Python | .py | 82 | 35.426829 | 84 | 0.649051 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,459 | mobiml.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/mobiml.py | '''
Transform XHTML/OPS-ish content into Mobipocket HTML 3.2.
'''
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.cam>'
import copy
import numbers
import re
from contextlib import suppress
from lxml import etree
from calibre.ebooks.mobi.utils import convert_color_for_font_tag
f... | 26,324 | Python | .py | 592 | 30.594595 | 121 | 0.514715 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,460 | langcodes.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/langcodes.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
from struct import pack
from calibre.utils.localization import lang_as_iso639_1
lang_codes = {
}
main_language = {
0 : "NEUTRAL",
54 : "AFRIKAANS"... | 9,889 | Python | .py | 343 | 19.008746 | 61 | 0.373859 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,461 | utils.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/utils.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import string
import struct
import zlib
from collections import OrderedDict
from io import BytesIO
from tinycss.color3 import parse_color_string
from calibre.ebo... | 19,836 | Python | .py | 536 | 29.981343 | 129 | 0.622225 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,462 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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
MAX_THUMB_SIZE = 16 * 1024
MAX_THUMB_DIMEN = (180, 240)
| 318 | Python | .py | 8 | 37.5 | 109 | 0.710526 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,463 | huffcdic.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/huffcdic.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
'''
Decompress MOBI files compressed with the Huff/cdic algorithm. Code thanks to darkninja
and igorsk.
'''
import struct
from calibre.ebooks.mobi import MobiError
class... | 3,172 | Python | .py | 82 | 28.560976 | 87 | 0.529354 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,464 | serializer.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer2/serializer.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re
import unicodedata
from collections import defaultdict
from io import BytesIO
from calibre.ebooks.mobi.mobiml import MBP_NS
from calibre.ebooks.mobi.utils import... | 15,005 | Python | .py | 344 | 31.47093 | 106 | 0.551122 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,465 | indexer.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer2/indexer.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import io
import numbers
from collections import OrderedDict, defaultdict
from struct import pack
from calibre.ebooks.mobi.utils import CNCX as CNCX_
from calibre.ebooks.mo... | 30,384 | Python | .py | 725 | 29.177931 | 111 | 0.537653 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,466 | resources.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer2/resources.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
from io import BytesIO
from PIL import Image, ImageOps
from calibre.ebooks import generate_masthead
from calibre.ebooks.mobi import MAX_THUMB_DIMEN, MAX_THUMB_SI... | 7,256 | Python | .py | 163 | 32.392638 | 213 | 0.57343 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,467 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer2/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
UNCOMPRESSED = 1
PALMDOC = 2
HUFFDIC = 17480
PALM_MAX_IMAGE_SIZE = 63 * 1024
| 226 | Python | .py | 8 | 26.625 | 58 | 0.704225 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,468 | main.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer2/main.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import io
import random
import time
from struct import pack
from calibre.ebooks import normalize
from calibre.ebooks.compression.palmdoc import compress_doc
from calibre.eb... | 17,868 | Python | .py | 399 | 34.649123 | 131 | 0.600955 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,469 | headers.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/headers.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import re
import struct
from calibre import replace_entities
from calibre.ebooks.metadata import MetaInformation, check_isbn
from calibre.ebooks.mobi import MobiE... | 14,165 | Python | .py | 322 | 30.596273 | 102 | 0.526796 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,470 | ncx.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/ncx.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
from calibre import replace_entities
from calibre.ebooks.metadata.toc import TOC
from calibre.ebooks.mobi.reader.headers import NULL_INDEX
from calibre.ebooks.mob... | 3,357 | Python | .py | 84 | 27.619048 | 87 | 0.496314 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,471 | mobi8.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/mobi8.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import re
import struct
from collections import namedtuple
from itertools import repeat
from uuid import uuid4
from lxml import etree
from calibre.ebooks.metadat... | 24,537 | Python | .py | 527 | 33.358634 | 139 | 0.539101 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,472 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
| 149 | Python | .py | 4 | 35 | 58 | 0.678571 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,473 | index.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/index.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import struct
from collections import OrderedDict, namedtuple
from calibre.ebooks.mobi.utils import count_set_bits, decint, decode_string
from polyglot.builtins import iter... | 10,061 | Python | .py | 234 | 32.871795 | 83 | 0.576309 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,474 | markup.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/markup.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import re
from calibre.ebooks.chardet import strip_encoding_declarations
def update_internal_links(mobi8_reader, log):
# need to update all links that are i... | 15,288 | Python | .py | 320 | 34.503125 | 108 | 0.525119 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,475 | mobi6.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/mobi6.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import io
import os
import re
import shutil
import struct
import textwrap
from lxml import etree, html
from calibre import guess_type, replace_entities, xml_replace_entiti... | 40,024 | Python | .py | 858 | 32.249417 | 155 | 0.50819 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,476 | containers.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/reader/containers.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
from struct import error, unpack_from
from calibre.utils.imghdr import what
def find_imgtype(data):
return what(None, data) or 'unknown'
class Container:
def __init__(self, data):
self.is_... | 1,249 | Python | .py | 35 | 24.028571 | 88 | 0.507077 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,477 | toc.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/toc.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.ebooks.oeb.base import XHTML, XHTML_MIME, XHTML_NS, XPath, css_text, urlnormalize
from calibre.utils.localization import __
from calibre.utils.xml_parse import ... | 4,854 | Python | .py | 118 | 31.559322 | 114 | 0.574852 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,478 | header.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/header.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import numbers
import random
from collections import OrderedDict
from io import BytesIO
from struct import pack
from calibre.ebooks.mobi.utils import align_block
from polyg... | 2,523 | Python | .py | 70 | 27.414286 | 78 | 0.581109 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,479 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
| 149 | Python | .py | 4 | 35 | 58 | 0.678571 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,480 | index.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/index.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from collections import namedtuple
from io import BytesIO
from struct import pack
from calibre.ebooks.mobi.utils import CNCX, align_block, encint
from calibre.ebooks.mobi.wr... | 12,782 | Python | .py | 317 | 30.022082 | 138 | 0.521269 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,481 | skeleton.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/skeleton.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re
from collections import namedtuple
from functools import partial
from xml.sax.saxutils import escape
from lxml import etree
from calibre import my_unichr
from ca... | 16,892 | Python | .py | 372 | 34.287634 | 110 | 0.566365 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,482 | mobi.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/mobi.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import random
import time
from struct import pack
from calibre.ebooks.mobi.langcodes import iana2mobi
from calibre.ebooks.mobi.utils import RECORD_SIZE, utf8_text
from cali... | 10,264 | Python | .py | 275 | 29.541818 | 101 | 0.622982 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,483 | cleanup.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/cleanup.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.ebooks.oeb.base import XPath
class CSSCleanup:
def __init__(self, log, opts):
self.log, self.opts = log, opts
def __call__(self, item, styli... | 1,289 | Python | .py | 32 | 29.96875 | 77 | 0.567763 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,484 | main.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/main.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import copy
import logging
from collections import defaultdict, namedtuple
from functools import partial
from io import BytesIO
from struct import pack
import css_parser
fr... | 20,076 | Python | .py | 432 | 33.069444 | 108 | 0.543876 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,485 | exth.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/exth.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re
from io import BytesIO
from struct import pack
from calibre.constants import ismacos, iswindows
from calibre.ebooks.metadata import authors_to_sort_string
from ca... | 7,438 | Python | .py | 205 | 27.658537 | 119 | 0.569109 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,486 | tbs.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/writer8/tbs.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
DOC = '''
Trailing Byte Sequences contain information about which index entries touch a
particular text record. Every text records has a set of trailing byte
sequences. In o... | 7,879 | Python | .py | 174 | 35.747126 | 114 | 0.622848 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,487 | headers.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/debug/headers.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import binascii
import datetime
import numbers
import os
import struct
from calibre.ebooks.mobi.debug import format_bytes
from calibre.ebooks.mobi.langcodes import main_lan... | 25,814 | Python | .py | 540 | 35.859259 | 127 | 0.551135 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,488 | mobi8.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/debug/mobi8.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import struct
import sys
import textwrap
from calibre import CurrentDir
from calibre.ebooks.mobi.debug import format_bytes
from calibre.ebooks.mobi.debug.containe... | 13,569 | Python | .py | 297 | 33.387205 | 114 | 0.550832 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,489 | __init__.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/debug/__init__.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
def format_bytes(byts):
byts = bytearray(byts)
byts = [hex(b)[2:] for b in byts]
return ' '.join(byts)
| 265 | Python | .py | 8 | 29.875 | 58 | 0.649402 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,490 | index.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/debug/index.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import struct
from collections import OrderedDict, namedtuple
from calibre.ebooks.mobi.reader.headers import NULL_INDEX
from calibre.ebooks.mobi.reader.index import CNCX, I... | 9,225 | Python | .py | 193 | 34.823834 | 152 | 0.525495 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,491 | mobi6.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/debug/mobi6.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import struct
import sys
from collections import OrderedDict, defaultdict
from lxml import html
from calibre.ebooks.mobi.debug import format_bytes
from calibre.e... | 32,267 | Python | .py | 715 | 33.475524 | 126 | 0.541774 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,492 | main.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/debug/main.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import shutil
import sys
from calibre.ebooks.mobi.debug.headers import MOBIFile
from calibre.ebooks.mobi.debug.mobi6 import inspect_mobi as inspect_mobi6
from cal... | 1,206 | Python | .py | 38 | 26.526316 | 81 | 0.642734 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,493 | containers.py | kovidgoyal_calibre/src/calibre/ebooks/mobi/debug/containers.py | #!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
from struct import unpack_from
from calibre.ebooks.mobi.debug.headers import EXTHHeader
class ContainerHeader:
def __init__(self, data):
self.ident = data[:4]
self.record_size, self.type... | 2,724 | Python | .py | 55 | 40.581818 | 112 | 0.591729 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,494 | plucker.py | kovidgoyal_calibre/src/calibre/ebooks/metadata/plucker.py | '''
Read meta information from Plucker pdb files.
'''
__license__ = 'GPL v3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en'
import struct
from datetime import datetime
from calibre.ebooks.metadata import MetaInformation
from calibre.ebooks.pdb.header import PdbHe... | 2,083 | Python | .py | 59 | 28.474576 | 94 | 0.624254 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,495 | lit.py | kovidgoyal_calibre/src/calibre/ebooks/metadata/lit.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
Support for reading the metadata from a LIT file.
'''
import io
import os
from calibre.ebooks.metadata.opf2 import OPF
def get_metadata(stream):
from calibre.ebooks.lit.reader import LitContainer
from calibre.utils.lo... | 1,315 | Python | .py | 38 | 26.578947 | 76 | 0.574234 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,496 | kfx.py | kovidgoyal_calibre/src/calibre/ebooks/metadata/kfx.py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>, John Howell <jhowell@acm.org>'
# Based on work of John Howell reversing the KFX format
# https://www.mobileread.com/forums/showpost.php?p=3176029&postcount=89
import re
import struct
import sys
from collections import defa... | 10,819 | Python | .py | 273 | 32.043956 | 103 | 0.623039 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,497 | topaz.py | kovidgoyal_calibre/src/calibre/ebooks/metadata/topaz.py | __license__ = 'GPL 3'
__copyright__ = '2010, Greg Riker <griker@hotmail.com>'
__docformat__ = 'restructuredtext en'
''' Read/write metadata from Amazon's topaz format '''
import io
import numbers
import sys
from struct import pack
from calibre import force_unicode
from calibre.ebooks.metadata import MetaInformation
f... | 14,349 | Python | .py | 346 | 30.433526 | 123 | 0.552775 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,498 | txt.py | kovidgoyal_calibre/src/calibre/ebooks/metadata/txt.py | __license__ = 'GPL v3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
'''
Read meta information from TXT files
'''
import os
import re
from calibre.ebooks.metadata import MetaInformation
def get_metadata(stream, extract_cover=True):
'''
Return metadata as a L{MetaInfo} object
'''
na... | 953 | Python | .py | 30 | 26.333333 | 113 | 0.574398 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |
27,499 | pdf.py | kovidgoyal_calibre/src/calibre/ebooks/metadata/pdf.py | __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''Read meta information from PDF files'''
import os
import re
import shutil
import subprocess
from functools import partial
from calibre import prints
from calibre.constants import iswindows
from calibre.ebooks.metadata import Met... | 6,525 | Python | .py | 158 | 33.734177 | 102 | 0.634112 | kovidgoyal/calibre | 19,243 | 2,250 | 4 | GPL-3.0 | 9/5/2024, 5:13:50 PM (Europe/Amsterdam) |