mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-16 02:53:33 +02:00
Removed Windows bits.
This commit is contained in:
@@ -2,7 +2,6 @@ import os
|
||||
|
||||
from lxml.html.builder import IMG, HR
|
||||
|
||||
from ebook_converter.constants_old import iswindows
|
||||
from ebook_converter.ebooks.docx.names import barename
|
||||
from ebook_converter.utils.filenames import ascii_filename
|
||||
from ebook_converter.utils.img import resize_to_fit, image_to_data
|
||||
@@ -123,8 +122,6 @@ class Images(object):
|
||||
def read_image_data(self, fname, base=None):
|
||||
if fname.startswith('file://'):
|
||||
src = fname[len('file://'):]
|
||||
if iswindows and src and src[0] == '/':
|
||||
src = src[1:]
|
||||
if not src or not os.path.exists(src):
|
||||
raise LinkedImageNotFound(src)
|
||||
with open(src, 'rb') as rawsrc:
|
||||
|
||||
@@ -9,7 +9,6 @@ import urllib.parse
|
||||
|
||||
from ebook_converter.ebooks.oeb.base import urlunquote
|
||||
from ebook_converter.ebooks.chardet import detect_xml_encoding
|
||||
from ebook_converter.constants_old import iswindows
|
||||
from ebook_converter import unicode_path, replace_entities
|
||||
|
||||
|
||||
@@ -22,9 +21,6 @@ class Link(object):
|
||||
def url_to_local_path(cls, url, base):
|
||||
path = url.path
|
||||
isabs = False
|
||||
if iswindows and path.startswith('/'):
|
||||
path = path[1:]
|
||||
isabs = True
|
||||
path = urllib.parse.urlunparse(('', '', path, url.params, url.query,
|
||||
''))
|
||||
path = urlunquote(path)
|
||||
|
||||
@@ -19,7 +19,7 @@ class HTML2ZIP(FileTypePlugin):
|
||||
''')
|
||||
version = numeric_version
|
||||
file_types = {'html', 'htm', 'xhtml', 'xhtm', 'shtm', 'shtml'}
|
||||
supported_platforms = ['windows', 'osx', 'linux']
|
||||
supported_platforms = ['osx', 'linux']
|
||||
on_import = True
|
||||
|
||||
def run(self, htmlfile):
|
||||
|
||||
@@ -44,7 +44,7 @@ class KPFExtract(FileTypePlugin):
|
||||
'KPF files. Note this will not contain any edits made in '
|
||||
'the Kindle Create program itself.')
|
||||
file_types = {'kpf'}
|
||||
supported_platforms = ['windows', 'osx', 'linux']
|
||||
supported_platforms = ['osx', 'linux']
|
||||
on_import = True
|
||||
|
||||
def run(self, archive):
|
||||
@@ -67,7 +67,7 @@ class ArchiveExtract(FileTypePlugin):
|
||||
'RAR). Also try to autodetect if they are actually CBZ/CBR '
|
||||
'files.')
|
||||
file_types = {'zip', 'rar'}
|
||||
supported_platforms = ['windows', 'osx', 'linux']
|
||||
supported_platforms = ['osx', 'linux']
|
||||
on_import = True
|
||||
|
||||
def run(self, archive):
|
||||
|
||||
@@ -5,7 +5,6 @@ import os, subprocess, shutil, re
|
||||
from functools import partial
|
||||
|
||||
from ebook_converter import prints
|
||||
from ebook_converter.constants_old import iswindows
|
||||
from ebook_converter.ptempfile import TemporaryDirectory
|
||||
from ebook_converter.ebooks.metadata import (
|
||||
MetaInformation, string_to_authors, check_isbn, check_doi)
|
||||
@@ -18,7 +17,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
def get_tools():
|
||||
from ebook_converter.ebooks.pdf.pdftohtml import PDFTOHTML
|
||||
base = os.path.dirname(PDFTOHTML)
|
||||
suffix = '.exe' if iswindows else ''
|
||||
suffix = ''
|
||||
pdfinfo = os.path.join(base, 'pdfinfo') + suffix
|
||||
pdftoppm = os.path.join(base, 'pdftoppm') + suffix
|
||||
return pdfinfo, pdftoppm
|
||||
@@ -87,9 +86,6 @@ def page_images(pdfpath, outputdir='.', first=1, last=1, image_format='jpeg', pr
|
||||
pdftoppm = get_tools()[1]
|
||||
outputdir = os.path.abspath(outputdir)
|
||||
args = {}
|
||||
if iswindows:
|
||||
import win32process as w
|
||||
args['creationflags'] = w.HIGH_PRIORITY_CLASS | w.CREATE_NO_WINDOW
|
||||
try:
|
||||
subprocess.check_call([
|
||||
pdftoppm, '-cropbox', '-' + image_format, '-f', str(first),
|
||||
|
||||
@@ -3,7 +3,7 @@ from struct import pack
|
||||
from io import BytesIO
|
||||
|
||||
from ebook_converter.ebooks.oeb import base
|
||||
from ebook_converter.constants_old import iswindows, isosx
|
||||
from ebook_converter.constants_old import isosx
|
||||
from ebook_converter.ebooks.mobi.utils import (utf8_text, to_base)
|
||||
from ebook_converter.utils.localization import lang_as_iso639_1
|
||||
from ebook_converter.ebooks.metadata import authors_to_sort_string
|
||||
@@ -150,8 +150,8 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False,
|
||||
nrecs += 1
|
||||
|
||||
if be_kindlegen2:
|
||||
mv = 200 if iswindows else 202 if isosx else 201
|
||||
vals = {204:mv, 205:2, 206:9, 207:0}
|
||||
mv = 201
|
||||
vals = {204: mv, 205: 2, 206: 9, 207: 0}
|
||||
elif is_periodical:
|
||||
# Pretend to be amazon's super secret periodical generator
|
||||
vals = {204:201, 205:2, 206:0, 207:101}
|
||||
|
||||
@@ -8,7 +8,6 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import unicodedata
|
||||
import urllib.parse
|
||||
import uuid
|
||||
@@ -18,7 +17,6 @@ from lxml import etree
|
||||
|
||||
from ebook_converter import constants as const
|
||||
from ebook_converter import CurrentDir, walk
|
||||
from ebook_converter.constants_old import iswindows
|
||||
from ebook_converter.customize.ui import plugin_for_input_format, plugin_for_output_format
|
||||
from ebook_converter.ebooks import escape_xpath_attr
|
||||
from ebook_converter.ebooks.chardet import xml_to_unicode
|
||||
@@ -109,10 +107,7 @@ def href_to_name(href, root, base=None):
|
||||
if purl.scheme or not purl.path:
|
||||
return None
|
||||
href = oeb_base.urlunquote(purl.path)
|
||||
if iswindows and ':' in href:
|
||||
# path manipulations on windows fail for paths with : in them, so we
|
||||
# assume all such paths are invalid/absolute paths.
|
||||
return None
|
||||
|
||||
fullpath = os.path.join(base, *href.split('/'))
|
||||
return unicodedata.normalize('NFC', abspath_to_name(fullpath, root))
|
||||
|
||||
@@ -1040,10 +1035,8 @@ class Container(ContainerBase): # {{{
|
||||
try:
|
||||
os.unlink(path)
|
||||
except EnvironmentError:
|
||||
if not iswindows:
|
||||
raise
|
||||
time.sleep(1) # Wait for whatever has locked the file to release it
|
||||
os.unlink(path)
|
||||
raise
|
||||
|
||||
os.rename(temp, path)
|
||||
return path
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ from xml.sax import saxutils
|
||||
|
||||
from ebook_converter import constants as const
|
||||
from ebook_converter.utils import date
|
||||
from ebook_converter.constants_old import iswindows
|
||||
from ebook_converter.ebooks.oeb import base
|
||||
from ebook_converter.ebooks.oeb.base import XPath, xml2text, urlnormalize
|
||||
from ebook_converter.library.comments import comments_to_html, markdown
|
||||
@@ -419,7 +418,5 @@ def referenced_images(root):
|
||||
src = img.get('src')
|
||||
if src.startswith('file://'):
|
||||
path = src[7:]
|
||||
if iswindows and path.startswith('/'):
|
||||
path = path[1:]
|
||||
if os.path.exists(path):
|
||||
yield img, path
|
||||
|
||||
@@ -8,7 +8,7 @@ import sys
|
||||
from lxml import etree
|
||||
|
||||
from ebook_converter import CurrentDir, xml_replace_entities, prints
|
||||
from ebook_converter.constants_old import isbsd, islinux, isosx, iswindows
|
||||
from ebook_converter.constants_old import isbsd, islinux, isosx
|
||||
from ebook_converter.ebooks import ConversionError, DRMError
|
||||
from ebook_converter.ebooks.chardet import xml_to_unicode
|
||||
from ebook_converter.ptempfile import PersistentTemporaryFile
|
||||
@@ -20,8 +20,6 @@ PDFTOHTML = 'pdftohtml'
|
||||
|
||||
|
||||
def popen(cmd, **kw):
|
||||
if iswindows:
|
||||
kw['creationflags'] = 0x08
|
||||
return subprocess.Popen(cmd, **kw)
|
||||
|
||||
|
||||
@@ -29,11 +27,6 @@ if isosx and hasattr(sys, 'frameworks_dir'):
|
||||
base = os.path.join(os.path.dirname(sys.frameworks_dir), 'utils.app',
|
||||
'Contents', 'MacOS')
|
||||
PDFTOHTML = os.path.join(base, PDFTOHTML)
|
||||
if iswindows and hasattr(sys, 'frozen'):
|
||||
base = os.path.dirname(sys.executable)
|
||||
if hasattr(sys, 'new_app_layout'):
|
||||
base = sys.extensions_location
|
||||
PDFTOHTML = os.path.join(base, 'pdftohtml.exe')
|
||||
if (islinux or isbsd) and getattr(sys, 'frozen', False):
|
||||
PDFTOHTML = os.path.join(sys.executables_location, 'bin', 'pdftohtml')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user