From ede45bbc7865b903eb491a4246f4fdc0acd79e5c Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 25 Jan 2011 22:40:38 +0000 Subject: [PATCH 1/6] Another 'right' fix for the multiple user category problem --- src/calibre/library/field_metadata.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/calibre/library/field_metadata.py b/src/calibre/library/field_metadata.py index c8706f2137..474f70d500 100644 --- a/src/calibre/library/field_metadata.py +++ b/src/calibre/library/field_metadata.py @@ -485,7 +485,6 @@ class FieldMetadata(dict): return self._tb_cats[key]['rec_index'] + 1 def add_user_category(self, label, name): - label = lower(label) if label in self._tb_cats: raise ValueError('Duplicate user field [%s]'%(label)) self._tb_cats[label] = {'table':None, 'column':None, @@ -525,7 +524,6 @@ class FieldMetadata(dict): def _add_search_terms_to_map(self, key, terms): if terms is not None: for t in terms: - t = t.lower() if t in self._search_term_map: raise ValueError('Attempt to add duplicate search term "%s"'%t) self._search_term_map[t] = key From bb063d655b0eadcceca2aa6e4fc18d3ce86b4073 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 25 Jan 2011 15:55:12 -0700 Subject: [PATCH 2/6] ... --- resources/calibre-portable.bat | 101 ++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 38 deletions(-) diff --git a/resources/calibre-portable.bat b/resources/calibre-portable.bat index 473cdc4236..f22c72cd8c 100644 --- a/resources/calibre-portable.bat +++ b/resources/calibre-portable.bat @@ -6,25 +6,37 @@ REM - Calibre Library Files REM - Calibre Config Files REM - Calibre Metadata database REM - Calibre Source files +REM - Calibre Temp Files REM By setting the paths correctly it can be used to run: REM - A "portable calibre" off a USB stick. REM - A network installation with local metadata database REM (for performance) and books stored on a network share +REM - A local installation using customised settings REM -REM If trying to run off a USB stick then the following -REM folder structure is recommended: +REM If trying to run off a USB stick then the folder structure +REM shown below is recommended (relative to the location of +REM this batch file). This can structure can also be used +REM when running of a local hard disk if you want to get the +REM level of control this batch file provides. REM - Calibre2 Location of program files REM - CalibreConfig Location of Configuration files REM - CalibreLibrary Location of Books and metadata +REM - CalibreSource Location of Calibre Source files (Optional) +REM +REM This batch file is designed so that if you create the recommended +REM folder structure then it can be used 'as is' without modification. REM ------------------------------------- REM Set up Calibre Config folder +REM +REM This is where user specific settings +REM are stored. REM ------------------------------------- IF EXIST CalibreConfig ( SET CALIBRE_CONFIG_DIRECTORY=%cd%\CalibreConfig - ECHO CONFIG=%cd%\CalibreConfig + ECHO CONFIG FILES: %cd%\CalibreConfig ) @@ -35,21 +47,18 @@ REM Location where Book files are located REM Either set explicit path, or if running from a USB stick REM a relative path can be used to avoid need to know the REM drive letter of the USB stick. - +REM REM Comment out any of the following that are not to be used +REM (although leaving them in does not really matter) REM -------------------------------------------------------------- IF EXIST U:\eBooks\CalibreLibrary ( SET CALIBRE_LIBRARY_DIRECTORY=U:\eBOOKS\CalibreLibrary - ECHO LIBRARY=U:\eBOOKS\CalibreLibrary + ECHO LIBRARY FILES: U:\eBOOKS\CalibreLibrary ) IF EXIST CalibreLibrary ( SET CALIBRE_LIBRARY_DIRECTORY=%cd%\CalibreLibrary - ECHO LIBRARY=%cd%\CalibreLibrary -) -IF EXIST CalibreBooks ( - SET CALIBRE_LIBRARY_DIRECTORY=%cd%\CalibreBooks - ECHO LIBRARY=%cd%\CalibreBooks + ECHO LIBRARY FILES: %cd%\CalibreLibrary ) @@ -60,7 +69,7 @@ REM Location where the metadata.db file is located. If not set REM the same location as Books files will be assumed. This. REM options is used to get better performance when the Library is REM on a (slow) network drive. Putting the metadata.db file -REM locally makes gives a big performance improvement. +REM locally then makes gives a big performance improvement. REM REM NOTE. If you use this option, then the ability to switch REM libraries within Calibre will be disabled. Therefore @@ -68,19 +77,10 @@ REM you do not want to set it if the metadata.db file REM is at the same location as the book files. REM -------------------------------------------------------------- -IF EXIST CalibreBooks ( - IF NOT "%CALIBRE_LIBRARY_DIRECTORY%" == "%cd%\CalibreBooks" ( - SET SET CALIBRE_OVERRIDE_DATABASE_PATH=%cd%\CalibreBooks\metadata.db - ECHO DATABASE=%cd%\CalibreBooks\metadata.db - ECHO ' - ECHO ***CAUTION*** Library Switching will be disabled - ECHO ' - ) -) -IF EXIST CalibreMetadata ( +IF EXIST %cd%\CalibreMetadata\metadata.db ( IF NOT "%CALIBRE_LIBRARY_DIRECTORY%" == "%cd%\CalibreMetadata" ( SET CALIBRE_OVERRIDE_DATABASE_PATH=%cd%\CalibreMetadata\metadata.db - ECHO DATABASE=%cd%\CalibreMetadata\metadata.db + ECHO DATABASE: %cd%\CalibreMetadata\metadata.db ECHO ' ECHO ***CAUTION*** Library Switching will be disabled ECHO ' @@ -96,37 +96,60 @@ REM When running from source the GUI will have a '*' after the version. REM number that is displayed at the bottom of the Calibre main screen. REM -------------------------------------------------------------- -IF EXIST Calibre\src ( - SET CALIBRE_DEVELOP_FROM=%cd%\Calibre\src - ECHO SOURCE=%cd%\Calibre\src -) -IF EXIST D:\Calibre\Calibre\src ( - SET CALIBRE_DEVELOP_FROM=D:\Calibre\Calibre\src - ECHO SOURCE=D:\Calibre\Calibre\src +IF EXIST CalibreSource\src ( + SET CALIBRE_DEVELOP_FROM=%cd%\CalibreSource\src + ECHO SOURCE FILES: %cd%\CalibreSource\src ) + REM -------------------------------------------------------------- REM Specify Location of calibre binaries (optional) REM REM To avoid needing Calibre to be set in the search path, ensure REM that Calibre Program Files is current directory when starting. REM The following test falls back to using search path . -REM This folder can be populated by cpying the Calibre2 folder from -REM an existing isntallation or by isntalling direct to here. +REM This folder can be populated by copying the Calibre2 folder from +REM an existing installation or by installing direct to here. REM -------------------------------------------------------------- -IF EXIST Calibre2 ( - Calibre2 CD Calibre2 - ECHO PROGRAMS=%cd% +IF EXIST %cd%\Calibre2 ( + CD %cd%\Calibre2 + ECHO PROGRAM FILES: %cd% ) + +REM -------------------------------------------------------------- +REM Location of Calibre Temporary files (optional) +REM +REM Calibre creates a lot of temproary files while running +REM In theory these are removed when Calibre finishes, but +REM in practise files can be left behind (particularily if +REM any errors occur. Using this option allows some +REM explicit clean-up of these files. +REM If not set Calibre uses the normal system TEMP location +REM -------------------------------------------------------------- + +SET CALIBRE_TEMP_DIR=%TEMP%\CALIBRE_TEMP +ECHO TEMPORARY FILES: %CALIBRE_TEMP_DIR% + +IF NOT "%CALIBRE_TEMP_DIR%" == "" ( + IF EXIST "%CALIBRE_TEMP_DIR%" RMDIR /s /q "%CALIBRE_TEMP_DIR%" + MKDIR "%CALIBRE_TEMP_DIR%" + REM set the following for any components that do + REM not obey the CALIBRE_TEMP_DIR setting + SET TMP=%CALIBRE_TEMP_DIR% + SET TEMP=%CALIBRE_TEMP_DIR% +) + + REM ---------------------------------------------------------- REM The following gives a chance to check the settings before REM starting Calibre. It can be commented out if not wanted. REM ---------------------------------------------------------- -echo "Press CTRL-C if you do not want to continue" -pause +ECHO ' +ECHO "Press CTRL-C if you do not want to continue" +PAUSE REM -------------------------------------------------------- @@ -141,5 +164,7 @@ REM If used without /WAIT opotion launches Calibre and contines batch file. REM Use with /WAIT to wait until Calibre completes to run a task on exit REM -------------------------------------------------------- -echo "Starting up Calibre" -START /belownormal Calibre --with-library "%CALIBRE_LIBRARY_DIRECTORY%" +ECHO "Starting up Calibre" +ECHO OFF +ECHO %cd% +START /belownormal Calibre --with-library "%CALIBRE_LIBRARY_DIRECTORY%" \ No newline at end of file From 9006bf624db25b44d9003b74d462564d39608977 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 25 Jan 2011 16:00:12 -0700 Subject: [PATCH 3/6] ... --- src/calibre/library/field_metadata.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/calibre/library/field_metadata.py b/src/calibre/library/field_metadata.py index 474f70d500..a7d05d396a 100644 --- a/src/calibre/library/field_metadata.py +++ b/src/calibre/library/field_metadata.py @@ -7,7 +7,6 @@ import copy from calibre.utils.ordered_dict import OrderedDict from calibre.utils.config import tweaks -from calibre.utils.icu import lower class TagsIcons(dict): ''' @@ -478,8 +477,6 @@ class FieldMetadata(dict): del self._tb_cats[key] if key in self._search_term_map: del self._search_term_map[key] - if key in self._search_term_map: - del self._search_term_map[key] def cc_series_index_column_for(self, key): return self._tb_cats[key]['rec_index'] + 1 From 76fe7be36f219bd0d7ac3a5abec01fed5613fefe Mon Sep 17 00:00:00 2001 From: John Schember Date: Tue, 25 Jan 2011 19:17:41 -0500 Subject: [PATCH 4/6] Heuristic: Tweak italicizing common works to ensure it does not match inside of a word. --- src/calibre/ebooks/conversion/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/utils.py b/src/calibre/ebooks/conversion/utils.py index f6e259b6f9..7882d82d47 100644 --- a/src/calibre/ebooks/conversion/utils.py +++ b/src/calibre/ebooks/conversion/utils.py @@ -155,7 +155,7 @@ class HeuristicProcessor(object): ] for word in ITALICIZE_WORDS: - html = html.replace(word, '%s' % word) + html = re.sub(r'(?<=\s|>)' + word + r'(?=\s|<)', '%s' % word, html) for pat in ITALICIZE_STYLE_PATS: html = re.sub(pat, lambda mo: '%s' % mo.group('words'), html) From 6145761654060151179b1b1c02c3911fab6a04b8 Mon Sep 17 00:00:00 2001 From: John Schember Date: Tue, 25 Jan 2011 21:44:01 -0500 Subject: [PATCH 5/6] FB2 Output: Set language correctly. --- src/calibre/ebooks/fb2/fb2ml.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py index 796a94533a..515bdee9df 100644 --- a/src/calibre/ebooks/fb2/fb2ml.py +++ b/src/calibre/ebooks/fb2/fb2ml.py @@ -99,7 +99,10 @@ class FB2MLizer(object): metadata['appname'] = __appname__ metadata['version'] = __version__ metadata['date'] = '%i.%i.%i' % (datetime.now().day, datetime.now().month, datetime.now().year) - metadata['lang'] = u''.join(self.oeb_book.metadata.lang) if self.oeb_book.metadata.lang else 'en' + if self.oeb_book.metadata.language: + metadata['lang'] = self.oeb_book.metadata.language[0].value + else: + metadata['lang'] = u'en' metadata['id'] = None metadata['cover'] = self.get_cover() From 952f03c18bc6e80e2bbbf46c188e696be112ce49 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 25 Jan 2011 21:24:19 -0700 Subject: [PATCH 6/6] ... --- src/calibre/gui2/dialogs/metadata_bulk.ui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index 163d49b328..b0f2c144fc 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -7,7 +7,7 @@ 0 0 962 - 727 + 645 @@ -45,7 +45,7 @@ 0 0 954 - 666 + 584 @@ -996,8 +996,8 @@ not multiple and the destination field is multiple 0 0 - 197 - 60 + 938 + 268