- chapter, position = 0 , 0
- book_file = os.path.join(self.books_path, self.selected)
- log.debug("getting time from: " + book_file)
- with open(book_file, 'r') as f:
- chapter = int(f.readline())
- position = int(f.readline())
-
- return chapter, position
+ bookInfo = self._books[self.selected]
+ return bookInfo["chapter"], bookInfo["position"]
+
+ def _load_old_settings(self):
+ conf = os.path.join(self.path, "current")
+
+ try:
+ with open(conf) as f:
+ self.selected = f.readline()
+
+ books_path = os.path.join(self.path, "books/")
+ for book in os.listdir(books_path):
+ book_file = os.path.join(books_path, book)
+ with open(book_file, 'r') as f:
+ chapter = int(f.readline())
+ position = int(f.readline())
+ self._books[book] = {
+ "chapter": chapter,
+ "position": position,
+ }
+ except IOError, e:
+ if e.errno == 2:
+ pass
+ else:
+ raise
+ except OSError, e:
+ if e.errno == 2:
+ pass
+ else:
+ raise