From 3b0eca7efaac168ede92030dc87c6d9170168816 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 19 Oct 2009 16:58:12 -0600 Subject: [PATCH] Fix #3583 (Calibre adds spaces when converting from RTF) --- src/calibre/ebooks/rtf2xml/tokenize.py | 2 +- src/calibre/gui2/main.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/rtf2xml/tokenize.py b/src/calibre/ebooks/rtf2xml/tokenize.py index ad12daa211..45887f33e7 100755 --- a/src/calibre/ebooks/rtf2xml/tokenize.py +++ b/src/calibre/ebooks/rtf2xml/tokenize.py @@ -72,7 +72,7 @@ class Tokenize: return line def __compile_expressions(self): self.__ms_hex_exp = re.compile(r"\\\'(..)") - self.__utf_exp = re.compile(r"\\u(-?\d{3,6})") + self.__utf_exp = re.compile(r"\\u(-?\d{3,6}) {0,1}") self.__splitexp = re.compile(r"(\\[\\{}]|{|}|\\[^\s\\{}&]+(?:\s)?)") self.__par_exp = re.compile(r'\\$') self.__mixed_exp = re.compile(r"(\\[a-zA-Z]+\d+)(\D+)") diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 1e06f2eb0c..26bd764ad4 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -1621,12 +1621,13 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): try: os.makedirs(self.library_path) except: - self.library_path = os.path.expanduser('~/Library') + self.library_path = os.path.expanduser('~/CalibreLibrary') error_dialog(self, _('Invalid library location'), _('Could not access %s. Using %s as the library.')% (repr(self.library_path), repr(self.library_path)) ).exec_() - os.makedirs(self.library_path) + if not os.path.exists(self.library_path): + os.makedirs(self.library_path) def read_settings(self):