コード例 #1
0
 def sort_cache_generic(self, field):
     if (self.header_cache[field] == "Author" or self.header_cache[field] == "Author Name" ):
         sorted_pubs = sorted(self.cache, key=lambda pub: utils.convertAuthorNameToList(pub[field]),\
                               reverse = self.sorted_cache[field])
     else:
         
         index = None
         reverse = self.sorted_cache[field]
         if "Author" in self.header_cache:
             index = self.header_cache.index("Author")
         if not index == None:
             sorted_pubs = sorted(self.cache, key=lambda pub: utils.convertAuthorNameToList(pub[index]))    
             self.cache = sorted_pubs
        
         try:
             sorted_pubs = sorted(self.cache, key=lambda pub: int(pub[field]), reverse = reverse)
         except:
             sorted_pubs = sorted(self.cache, key=lambda pub: pub[field], reverse = reverse)
         
     self.cache = sorted_pubs
     
     self.sorted_cache[field] = not self.sorted_cache[field]
     
     return self.cache
コード例 #2
0
 def testConvertingAuthorNameToListWhichMatches(self):
     authorName = "George V. Chairepetis"
     author_parts = ["Chairepetis", "George", "V."]
     self.assertEqual(author_parts, utils.convertAuthorNameToList(authorName))