def load(self): """ Returns: A zotero database as an array of Items. """ if not check_path(os.path.join(self.zotero_path, u"zotero.sqlite")): raiseError(u"Citation.vim Error:", self.zotero_path, u"is not a valid zotero path") return [] zotero = zoteroData(self.context) zot_data = zotero.load() bb = betterBibtex(self.zotero_path, self.cache_path) citekeys = bb.load_citekeys() items = [] for zot_id, zot_item in zot_data: item = Item() item.abstract = zot_item.abstract item.author = self.format_author(zot_item) item.collections = zot_item.collections item.date = zot_item.date item.doi = zot_item.doi item.file = self.format_fulltext(zot_item) item.isbn = zot_item.isbn item.publication = zot_item.publication item.key = self.format_key(zot_item, citekeys) item.language = zot_item.language item.issue = zot_item.issue item.notes = self.format_notes(zot_item) item.pages = zot_item.pages item.publisher = zot_item.publisher item.tags = self.format_tags(zot_item) item.title = zot_item.title item.type = zot_item.type item.url = zot_item.url item.volume = zot_item.volume item.combine() items.append(item) return items
def load(self, source_field, file_path): if not valid_location(file_path): print("{} is not a valid zotero path".format(file_path)) return [] self.load_citekeys(file_path) try: zotero = zoteroData(file_path) zot_data = zotero.load() except Exception as e: print("Failed to read {}".format(file_path)) print("Message: {}".format(str(e))) items = [] for zot_id, zot_entry in zot_data: item = Item() item.abstract = zot_entry.abstract item.author = zot_entry.format_author() item.date = zot_entry.date item.doi = zot_entry.doi item.file = zot_entry.fulltext item.isbn = zot_entry.isbn item.journal = zot_entry.publication item.key = self.format_key(zot_entry.id, zot_entry.key) item.language = zot_entry.language item.issue = zot_entry.issue item.notes = zot_entry.format_notes() item.pages = zot_entry.pages item.publisher = zot_entry.publisher item.tags = zot_entry.format_tags() item.title = zot_entry.title item.type = zot_entry.type item.url = zot_entry.url item.volume = zot_entry.volume item.combine() if not getattr(item, source_field) == "": items.append(item) return items
def load(self, source_field, file_path): if not valid_location(file_path): print("{} is not a valid zotero path".format(file_path)) return [] self.load_citekeys(file_path) try: zotero = zoteroData(file_path) zot_data = zotero.load() except Exception as e: print("Failed to read {}".format(file_path)) print("Message: {}".format(str(e))) items = [] for zot_id, zot_entry in zot_data: item = Item() item.abstract = zot_entry.abstract item.author = zot_entry.format_author() item.date = zot_entry.date item.doi = zot_entry.doi item.file = zot_entry.fulltext item.isbn = zot_entry.isbn item.journal = zot_entry.publication item.key = self.format_key(zot_entry.id, zot_entry.key) item.language = zot_entry.language item.issue = zot_entry.issue item.notes = zot_entry.format_notes() item.pages = zot_entry.pages item.publisher = zot_entry.publisher item.tags = zot_entry.format_tags() item.title = zot_entry.title item.type = zot_entry.type item.url = zot_entry.url item.volume = zot_entry.volume item.combine() if not getattr(item, source_field) == "": items.append(item) return items