-# -*- coding: utf-8 -*-
-#
# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
-# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
#
-from __future__ import print_function, unicode_literals
-
+import io
import os
import re
import shutil
from tempfile import NamedTemporaryFile
import urllib
from lxml import etree
-import six
-from six.moves.urllib.request import FancyURLopener
+from urllib.request import FancyURLopener
from .util import makedirs
# Compatibility imports.
from .meta.types.wluri import WLURI
-@six.python_2_unicode_compatible
class UnicodeException(Exception):
def __str__(self):
""" Dirty workaround for Python Unicode handling problems. """
args = self.args[0] if len(self.args) == 1 else self.args
try:
- message = six.text_type(args)
+ message = str(args)
except UnicodeDecodeError:
- message = six.text_type(args, encoding='utf-8', errors='ignore')
+ message = str(args, encoding='utf-8', errors='ignore')
return message
pass
-class XMLNamespace(object):
+class XMLNamespace:
'''A handy structure to repsent names in an XML namespace.'''
def __init__(self, uri):
DCNS = XMLNamespace('http://purl.org/dc/elements/1.1/')
XHTMLNS = XMLNamespace("http://www.w3.org/1999/xhtml")
PLMETNS = XMLNamespace("http://dl.psnc.pl/schemas/plmet/")
-
+FB2NS = XMLNamespace("http://www.gribuser.ru/xml/fictionbook/2.0")
+XLINKNS = XMLNamespace("http://www.w3.org/1999/xlink")
WLNS = EmptyNamespace()
-class DocProvider(object):
+class DocProvider:
"""Base class for a repository of XML files.
Used for generating joined files, like EPUBs.
return os.path.join(os.path.dirname(__file__), path)
-class OutputFile(object):
+class OutputFile:
"""Represents a file returned by one of the converters."""
_bytes = None
"""Get file as a file-like object."""
if self._bytes is not None:
- return six.BytesIO(self._bytes)
+ return io.BytesIO(self._bytes)
elif self._filename is not None:
return open(self._filename, 'rb')
class URLOpener(FancyURLopener):
- version = 'FNP Librarian (http://github.com/fnp/librarian)'
+ version = 'WL Librarian (http://github.com/fnp/librarian)'
urllib._urlopener = URLOpener()