Beispiel #1
0
def parse(bibfile):

	with open(bibfile) as bibtex_file:
		writer = BibTexWriter()
		bib_database = bibtexparser.load(bibtex_file)

		for entry in bib_database.entries:
			print "\t-"
			print "\t\tlayout: paper"
			print "\t\tpaper-type: "+ preprocess(entry["type"])
			print "\t\tyear: " + preprocess(entry["year"])
			print "\t\tselected: no"
			print "\t\ttitle: >\n\t\t\t"+preprocess(entry["title"])
			print "\t\tauthors: "+ parseauthors(preprocess(entry["author"])).encode('UTF8')
			print "\t\timg: "
			print "\t\tvenue: "
			if("pages" in entry.keys()):
				print "\t\tpages: "+preprocess(entry["pages"])
			if("booktitle" in entry.keys()):
				print "\t\tbooktitle: "+preprocess(entry["booktitle"])
			if("journal" in entry.keys()):
				print "\t\tjournal: "+preprocess(entry["journal"])
			if("url" in entry.keys()):
				print "\t\tdoc-url: "+preprocess(entry["url"])
			else:
				print "\t\tdoc-url: "

			if("abstract" in entry.keys()):
				print "\t\tabstract: >\n\t\t\t" + preprocess(entry["abstract"]).encode('UTF8')

			print "\t\tbibtex: >\n\t\t\t"+ writer._entry_to_bibtex(entry).replace("\n","\n\t\t\t").encode('UTF8')
Beispiel #2
0
    def extract(self, writer: TextIOWrapper = sys.stdout):
        """Extract the master source BibTex matching citation references from the LaTex
        file(s) and write them to ``writer``.

        :param writer: the BibTex entry data sink

        """
        bwriter = BibTexWriter()
        for bid, entry in self.entries.items():
            logger.info(f'writing entry {bid}')
            writer.write(bwriter._entry_to_bibtex(entry))
            logger.debug(f'extracting: {bid}: <{entry}>')
        writer.flush()
Beispiel #3
0
def write_bibtex_dict(stream, entries):
    """bibtexparser.write converts the entire database to one big string and
    writes it out in one go. I'm sure it will always all fit in RAM but some
    things just will not stand.

    """
    from bibtexparser.bwriter import BibTexWriter

    writer = BibTexWriter()
    writer.indent = '  '
    writer.entry_separator = ''
    first = True

    for rec in entries:
        if first:
            first = False
        else:
            stream.write(b'\n')
        stream.write(writer._entry_to_bibtex(rec).encode('utf8'))
Beispiel #4
0
def write_bibtex_dict (stream, entries):
    """bibtexparser.write converts the entire database to one big string and
    writes it out in one go. I'm sure it will always all fit in RAM but some
    things just will not stand.

    """
    from bibtexparser.bwriter import BibTexWriter

    writer = BibTexWriter ()
    writer.indent = '  '
    writer.entry_separator = ''
    first = True

    for rec in entries:
        if first:
            first = False
        else:
            stream.write ('\n')
        stream.write (writer._entry_to_bibtex (rec))
Beispiel #5
0
def parse(bibfile):

	with open(bibfile) as bibtex_file:
		writer = BibTexWriter()
		bib_database = bibtexparser.load(bibtex_file)


		for entry in bib_database.entries:
			authors=parseauthors(preprocess(entry["author"])) #.encode('UTF8')
			if("booktitle" in entry.keys()):
				venue= preprocess(entry["booktitle"]) #.encode('UTF8')
			else:
				venue=""
			print( "  -")
			print ("    layout: paper")
			print ("    paper-type: "+ preprocess(entry["ENTRYTYPE"]) +" #changes display of reference in paper list")
			print ("    year: " + preprocess(entry["year"]))
			print ("    selected: no #yes/no")
			print ("    title: >\n      "+preprocess(entry["title"]))
			print ("    authors: "+ authors)
			print ("    id: "+ abbrevVenue(venue) + preprocess(entry["year"]) + "_" + processAuthor(authors.split()[1]))
			print ("    img: #image_id to be found in img/paper/ID.jpg")
			print ("    slides: # e.g. media/$ID.pptx ")
			print ("    code: #e.g. github.com/project")
			print ("    errata: #if you have errata, insert here")
			print ("    venue: #for CV e.g. book[chapters], conference[journal],  workshop[demo], techreport")
			if("pages" in entry.keys()):
				print ("    pages: "+preprocess(entry["pages"]))
			if("booktitle" in entry.keys()):
				print ("    booktitle: >\n      "+venue)
			if("journal" in entry.keys()):
				print ("    journal: "+preprocess(entry["journal"]))
			if("url" in entry.keys()):
				print ("    doc-url: "+preprocess(entry["url"]))
			elif "link" in entry.keys() :
				print ("    doc-url: "+preprocess(entry["link"]))
			else:
				print ("    doc-url:  # e.g. papers/$ID.pdf")

			if("abstract" in entry.keys()):
				print ("    abstract: >\n      " + preprocess(entry["abstract"]) )#.encode('UTF8'))

			print ("    bibtex: >\n      "+ writer._entry_to_bibtex(entry).replace("\n","\n      ") )#.encode('UTF8'))
Beispiel #6
0
def bibTexIn(filename):
    #load database into bibtexdatabase object
    with codecs.open(filename, 'r', 'utf-8') as bibtex_file:
        parser = BibTexParser()
        parser.customization = convert_to_unicode
        bibtex_database = bibtexparser.load(bibtex_file,parser)

    #load all the keys we want to add into the dialectsDB database
    dbbibtexkeys = [x.bibTexKey for x in BiblioEntryBibTex.objects.all()]
    btdbdict = bibtex_database.entries_dict

    for item in dbbibtexkeys:
        try:
            currentbtitem = btdbdict[item]
            currentBEobject = BiblioEntryBibTex.objects.get(bibTexKey=item)
            writer = BibTexWriter()
            bibtexofentry = writer._entry_to_bibtex(currentbtitem)
            currentBEobject.fullBibtex = bibtexofentry
            print("Currently saving: {}".format(item))
            currentBEobject.save() #The saving function should put the relevant info into the other fields
        except KeyError:
            print("No bibliography entry for: {}".format(item))
def toString(e):
    writer = BibTexWriter()
    writer.indent = '    '     # indent entries with 4 spaces instead of one
    writer.comma_first = True  # place the comma at the beginning of the line

    return writer._entry_to_bibtex(e)
Beispiel #8
0
 def get_bibliography_data(self):
     writer = BibTexWriter()
     # noinspection PyProtectedMember
     entry = writer._entry_to_bibtex(self.bibliography_data)
     return entry
def toString(e):
    writer = BibTexWriter()
    writer.indent = '    '  # indent entries with 4 spaces instead of one
    writer.comma_first = True  # place the comma at the beginning of the line

    return writer._entry_to_bibtex(e)