diff --git a/epubadapter.py b/epubadapter.py index b2b9959..d059a66 100644 --- a/epubadapter.py +++ b/epubadapter.py @@ -5,7 +5,7 @@ # import speech -from cStringIO import StringIO +from io import StringIO _logger = logging.getLogger('read-activity') @@ -51,7 +51,7 @@ def update_metadata(self, activity): self.metadata = activity.metadata - self.metadata['Read_zoom'] = self.get_zoom() + self.metadata['Read_zoom'] = str(self.get_zoom()) def zoom_to_width(self): pass diff --git a/epubview/__init__.py b/epubview/__init__.py index 20d9fc6..ffdb946 100644 --- a/epubview/__init__.py +++ b/epubview/__init__.py @@ -15,6 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from epub import _Epub as Epub -from epubview import _View as EpubView -from jobs import _JobFind as JobFind +from .epub import _Epub as Epub +from .epubview import _View as EpubView +from .jobs import _JobFind as JobFind diff --git a/epubview/epub.py b/epubview/epub.py index 38ccf98..b059d5a 100644 --- a/epubview/epub.py +++ b/epubview/epub.py @@ -22,8 +22,8 @@ import shutil import logging -import navmap -import epubinfo +from . import navmap +from . import epubinfo class _Epub(object): @@ -40,7 +40,7 @@ self._tempdir = tempfile.mkdtemp() if not self._verify(): - print 'Warning: This does not seem to be a valid epub file' + print('Warning: This does not seem to be a valid epub file') self._get_opf() self._get_ncx() @@ -111,7 +111,7 @@ Method to crudely check to verify that what we are dealing with is a epub file or not ''' - if isinstance(self._file, basestring): + if isinstance(self._file, str): if not os.path.exists(self._file): return False @@ -124,7 +124,7 @@ mimetype = mtypefile.readline() # Some files seem to have trailing characters - if not mimetype.startswith('application/epub+zip'): + if not mimetype.startswith(b'application/epub+zip'): return False return True diff --git a/epubview/epubview.py b/epubview/epubview.py index 6ba667d..a5cdcf5 100644 --- a/epubview/epubview.py +++ b/epubview/epubview.py @@ -23,14 +23,14 @@ from gi.repository import GObject from gi.repository import Gdk from gi.repository import WebKit2 -import widgets +from . import widgets import logging import os.path import math import shutil -from jobs import _JobPaginator as _Paginator +from .jobs import _JobPaginator as _Paginator LOADING_HTML = ''' @@ -484,7 +484,7 @@ j = 0 word_begin = 0 word_end = 0 - ignore_chars = [' ', '\n', u'\r', '_', '[', '{', ']', '}', '|', + ignore_chars = [' ', '\n', '\r', '_', '[', '{', ']', '}', '|', '<', '>', '*', '+', '/', '\\'] ignore_set = set(ignore_chars) self.word_tuples = [] @@ -499,7 +499,7 @@ i = j word_tuple = (word_begin, word_end, page_text[word_begin: word_end]) - if word_tuple[2] != u'\r': + if word_tuple[2] != '\r': self.word_tuples.append(word_tuple) i = i + 1 @@ -625,8 +625,8 @@ else: self._load_page(int(value)) else: - print 'Warning: unknown scrolltype %s with value %f' \ - % (str(scrolltype), value) + print('Warning: unknown scrolltype %s with value %f' \ + % (str(scrolltype), value)) # FIXME: This should not be needed here self._scrollbar.set_value(self._loaded_page) diff --git a/epubview/jobs.py b/epubview/jobs.py index b34438e..f9bb9b0 100644 --- a/epubview/jobs.py +++ b/epubview/jobs.py @@ -23,11 +23,11 @@ from gi.repository import Gtk from gi.repository import Gdk from gi.repository import WebKit2 -import widgets +from . import widgets import math import os.path import xml.etree.ElementTree as etree -import htmlentitydefs as html_entities +import html.entities as html_entities import threading @@ -69,8 +69,8 @@ def _searchfile(self, fileobj): parser = etree.XMLParser(html=1) - for name, codepoint in html_entities.name2codepoint.iteritems(): - parser.entity[name] = unichr(codepoint) + for name, codepoint in html_entities.name2codepoint.items(): + parser.entity[name] = chr(codepoint) tree = etree.parse(fileobj, parser=parser) root = tree.getroot() @@ -230,7 +230,7 @@ ''' Returns the pageno which begins in filename ''' - for key in self._pagemap.keys(): + for key in list(self._pagemap.keys()): if self._pagemap[key][0].replace('file://', '') == filename: return key