View Single Post
Old 10-21-2012, 04:50 PM   #13
Xwang
Connoisseur
Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.Xwang ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 2136220
Join Date: Sep 2012
Device: none
Quote:
Originally Posted by JimmXinu View Post
Well, that is why I asked if you'd already tested doing it manually to make sure it worked...

Why do you need the extensions upcased? You described the problem as conflicts between files such as Aaa and AAA being different files on linux, but the same file on Windows.
I fear that the lower case extension is seen as part of the title because if I run the plugin once the db has already been upper cased, I see that it changes all the folder again. It seems that this line:
Code:
bookids = db.search_getting_ids('title:"~[a-z]" or author:"~[a-z]"', None)
return all the book in the library.

However I've searched a bit into the code and I've discovered that file extensions are forced to be lower case (see the function format_abspath in database2.py)

Code:
def format_abspath(self, index, format, index_is_id=False):
        '''
        Return absolute path to the ebook file of format `format`

        WARNING: This method will return a dummy path for a network backend DB,
        so do not rely on it, use format(..., as_path=True) instead.

        Currently used only in calibredb list, the viewer and the catalogs (via
        get_data_as_dict()).

        Apart from the viewer, I don't believe any of the others do any file
        I/O with the results of this call.
        '''
        id = index if index_is_id else self.id(index)
        try:
            name = self.format_filename_cache[id][format.upper()]
        except:
            return None
        if name:
            path = os.path.join(self.library_path, self.path(id, index_is_id=True))
            format = ('.' + format.lower()) if format else ''
            fmt_path = os.path.join(path, name+format)
            if os.path.exists(fmt_path):
                return fmt_path
            try:
                candidates = glob.glob(os.path.join(path, '*'+format))
            except: # If path contains strange characters this throws an exc
                candidates = []
            if format and candidates and os.path.exists(candidates[0]):
                try:
                    shutil.copyfile(candidates[0], fmt_path)
                except:
                    # This can happen if candidates[0] or fmt_path is too long,
                    # which can happen if the user copied the library from a
                    # non windows machine to a windows machine.
                    return None
                return fmt_path
If it is effectively so, the problem is to change the search line in my plugin to effectively return only the non already upper cased books/authors.

Moreover, making some more tests, I've discovered that if an author has more than a book, the books are correctly upper cased, but the author name remains unchanged.

Finally opening the metadata page in calibre I see a situation like the one in the attached snapshot in where author and title ordering are still not upper cased (red highlighted) (in the snapshot I've manually forced the author ordering and so noe it appears upper cased.
Xwang
Attached Thumbnails
Click image for larger version

Name:	CalibreSnapshot.png
Views:	286
Size:	22.6 KB
ID:	94619  
Xwang is offline   Reply With Quote