Ejemplo n.º 1
0
 def build_items(self, bib_data):
     items = []
     for key in bib_data.entries:
         item = Item()
         item.collections = []
         bib_entry = bib_data.entries[key]
         authors = self.parse_authors(bib_entry)
         item.author = self.format_author(authors)
         item.type = bib_entry.type
         item.abstract = self.get_field(bib_entry, "abstract")
         item.doi = self.get_field(bib_entry, "doi")
         item.isbn = self.get_field(bib_entry, "isbn")
         item.publication = self.get_field(bib_entry, "journal")
         item.language = self.get_field_from(bib_entry,
                                             ["language", "langid"])
         item.issue = self.get_field(bib_entry, "number")
         item.notes = self.get_field_from(bib_entry,
                                          ["annotation", "annote"])
         item.pages = self.get_field(bib_entry, "pages")
         item.publisher = self.get_field_from(
             bib_entry, ["publisher", "school", "institution"])
         item.tags = self.get_field_from(bib_entry, ["keyword", "keywords"])
         item.title = self.get_field(bib_entry, "title")
         item.volume = self.get_field(bib_entry, "volume")
         item.date = self.format_date(bib_entry)
         item.url = self.format_url(bib_entry)
         item.file = self.format_file(bib_entry)
         item.key = key
         item.combine()
         items.append(item)
     return items
Ejemplo n.º 2
0
 def build_items(self, zot_data, bb_citekeys):
     items = []
     for zot_id, zot_item in zot_data:
         item = Item()
         item.collections = zot_item.collections  # Allways an array.
         item.abstract = self.clean(zot_item.abstractNote)
         item.doi = self.clean(zot_item.DOI)
         item.isbn = self.clean(zot_item.ISBN)
         item.publication = self.clean(zot_item.publicationTitle)
         item.language = self.clean(zot_item.language)
         item.issue = self.clean(zot_item.issue)
         item.pages = self.clean(zot_item.pages)
         item.publisher = self.clean(zot_item.publisher)
         item.title = self.clean(zot_item.title)
         item.type = self.clean(zot_item.type)
         item.url = zot_item.url
         item.volume = self.clean(zot_item.volume)
         item.author = self.clean(zot_item.format_author(self.et_al_limit))
         item.date = self.clean(zot_item.format_date())
         item.file = zot_item.format_attachment()
         item.notes = self.clean(zot_item.format_notes())
         item.tags = self.clean(zot_item.format_tags())
         item.zotero_key = self.clean(zot_item.key)
         item.key = self.format_key(item, zot_item, bb_citekeys)
         item.combine()
         items.append(item)
     return items
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    def load(self):

        """
        Returns:
        A bibtex file as an array of Items.
        """

        items = []
        try:
            bib_data = self._read_file(self.bibtex_file)
        except Exception as e:
            raiseError(u"Failed to read {}".format(self.bibtex_file, '\r', u"Message: {}".format(str(e))))

        for key in bib_data.entries:
            bib_entry = bib_data.entries[key]

            item = Item()
            item.abstract  = self.get_field(bib_entry, "abstract")
            item.author    = self.format_author(bib_entry)
            item.collections  = []
            item.date      = self.get_field(bib_entry, "year")
            item.doi       = self.get_field(bib_entry, "doi")
            item.file      = self.format_file(bib_entry)
            item.isbn      = self.get_field(bib_entry, "isbn")
            item.publication = self.get_field(bib_entry, "journal")
            item.key       = key
            item.language  = self.get_field(bib_entry, "language")
            item.issue     = self.get_field(bib_entry, "number")
            item.notes     = self.get_field(bib_entry, "annote")
            item.pages     = self.get_field(bib_entry, "pages")
            item.publisher = self.get_field(bib_entry, "publisher")
            item.tags      = self.get_field(bib_entry, "keyword")
            item.title     = self.get_field(bib_entry, "title")
            item.type      = bib_entry.type
            item.url       = self.format_url(bib_entry)
            item.volume    = self.get_field(bib_entry, "volume")
            item.combine()
            items.append(item)
        return items