mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Fix handling of author=None in creating booklist.
This commit is contained in:
		
							parent
							
								
									18ed319a86
								
							
						
					
					
						commit
						50394f97e1
					
				@ -49,7 +49,7 @@ class Book(object):
 | 
				
			|||||||
    """ Provides a view onto the XML element that represents a book """
 | 
					    """ Provides a view onto the XML element that represents a book """
 | 
				
			||||||
    title        = book_metadata_field("title")
 | 
					    title        = book_metadata_field("title")
 | 
				
			||||||
    author       = book_metadata_field("author", \
 | 
					    author       = book_metadata_field("author", \
 | 
				
			||||||
                            formatter=lambda x: x if x.strip() else "Unknown")
 | 
					                            formatter=lambda x: x if x and x.strip() else "Unknown")
 | 
				
			||||||
    mime         = book_metadata_field("mime")
 | 
					    mime         = book_metadata_field("mime")
 | 
				
			||||||
    rpath        = book_metadata_field("path")
 | 
					    rpath        = book_metadata_field("path")
 | 
				
			||||||
    id           = book_metadata_field("id", formatter=int)
 | 
					    id           = book_metadata_field("id", formatter=int)
 | 
				
			||||||
@ -143,6 +143,7 @@ class BookList(list):
 | 
				
			|||||||
            for book in self.document.getElementsByTagName(self.prefix + "text"): 
 | 
					            for book in self.document.getElementsByTagName(self.prefix + "text"): 
 | 
				
			||||||
                self.append(Book(book, root=root, prefix=prefix))
 | 
					                self.append(Book(book, root=root, prefix=prefix))
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    def max_id(self):
 | 
					    def max_id(self):
 | 
				
			||||||
        """ Highest id in underlying XML file """
 | 
					        """ Highest id in underlying XML file """
 | 
				
			||||||
        cid = -1
 | 
					        cid = -1
 | 
				
			||||||
@ -183,10 +184,13 @@ class BookList(list):
 | 
				
			|||||||
        mime = MIME_MAP[name[name.rfind(".")+1:]]
 | 
					        mime = MIME_MAP[name[name.rfind(".")+1:]]
 | 
				
			||||||
        cid = self.max_id()+1
 | 
					        cid = self.max_id()+1
 | 
				
			||||||
        sourceid = str(self[0].sourceid) if len(self) else "1"
 | 
					        sourceid = str(self[0].sourceid) if len(self) else "1"
 | 
				
			||||||
        attrs = { "title":info["title"], "author":info["authors"], \
 | 
					        attrs = {
 | 
				
			||||||
 | 
					                 "title":info["title"], 
 | 
				
			||||||
 | 
					                 "author":info["authors"] if info['authors'] else 'Unknown', \
 | 
				
			||||||
                 "page":"0", "part":"0", "scale":"0", \
 | 
					                 "page":"0", "part":"0", "scale":"0", \
 | 
				
			||||||
                 "sourceid":sourceid,  "id":str(cid), "date":"", \
 | 
					                 "sourceid":sourceid,  "id":str(cid), "date":"", \
 | 
				
			||||||
                      "mime":mime, "path":name, "size":str(size)} 
 | 
					                 "mime":mime, "path":name, "size":str(size)
 | 
				
			||||||
 | 
					                 } 
 | 
				
			||||||
        for attr in attrs.keys():
 | 
					        for attr in attrs.keys():
 | 
				
			||||||
            node.setAttributeNode(self.document.createAttribute(attr))
 | 
					            node.setAttributeNode(self.document.createAttribute(attr))
 | 
				
			||||||
            node.setAttribute(attr, attrs[attr])        
 | 
					            node.setAttribute(attr, attrs[attr])        
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user