def read_string(string): """Takes a string and returns a list containing objects of type BibtexRecord""" # Mystery arguments: strictness = False name = "Name" # Read the string: return _iterate_bibtexsource(_bibtex.open_string(name, string, strictness))
def create_native(self, value): '''Parse text in native format.''' parser = _bibtex.open_string("<set_native string>", value, Config.get ('bibtex/strict').data) iter = BibtexIterator(self, parser) entry = iter.first() if entry: # set the entry parser to the current one, so # that we keep the current string definitions entry.parser = self.parser return entry
def create_native(self, value): '''Parse text in native format.''' parser = _bibtex.open_string("<set_native string>", value, Config.get('bibtex/strict').data) iter = BibtexIterator(self, parser) entry = iter.first() if entry: # set the entry parser to the current one, so # that we keep the current string definitions entry.parser = self.parser return entry
def read_bibtex(content, typemap={}): import _bibtex def expand(file, entry): items = entry[4] for k in items.keys(): items[k] = _bibtex.expand(file, items[k], typemap.get(k, -1)) items['key'] = entry[0] items['type'] = entry[1] return items file = _bibtex.open_string("/dev/null", content, 0) entries = [] while True: try: entry = _bibtex.next(file) if entry is None: break e = expand(file, entry) entries.append(e) except IOError, msg: pass
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # # Extension module for BibTeX files import _bibtex import os, sys, tempfile, pwd, time, traceback, re, string, copy from types import * from Pyblio.Fields import * from Pyblio import Base, Config, Autoload, Types from Pyblio import Open, Key, Utils, Iterator, Exceptions # this database is shared between all the unpickled entries _unpickle_db = _bibtex.open_string ("<unpickled>", '', 0); _base_fieldtype = { Text : 0, LongText : 0, Date : 3, AuthorGroup : 1, URL : 4, Reference : 4, } _text_fieldtype = Config.get ('bibtex+/capitalize').data def _fieldtype (field): if field.type is not Text: return _base_fieldtype [field.type]
# Extension module for BibTeX files import _bibtex import re import string import copy from gettext import gettext as _ from Pyblio.Fields import Author, AuthorGroup, Date, LongText from Pyblio.Fields import Reference, Text, URL from Pyblio import Base, Config, Autoload, Types from Pyblio import Open, Key, Utils, Iterator, Exceptions # this database is shared between all the unpickled entries _unpickle_db = _bibtex.open_string("<unpickled>", '', 0) _base_fieldtype = { Text: 0, LongText: 0, Date: 3, AuthorGroup: 1, URL: 4, Reference: 4, } _text_fieldtype = Config.get('bibtex+/capitalize').data def _fieldtype(field): if field.type is not Text:
if False: print importer("http://portal.acm.org/citation.cfm?id=277650.277719").load_bibtex() print importer("http://portal.acm.org/citation.cfm?id=324550").load_bibtex() print importer("http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.414").load_bibtex() test = importer("http://eprint.iacr.org/2009/137").load_bibtex() print test else: test = """@misc{cryptoeprint:2009:137, author = {Nicolas T. Courtois}, title = {The Dark Side of Security by Obscurity and Cloning MiFare Classic Rail and Building Passes Anywhere, Anytime}, howpublished = {Cryptology ePrint Archive, Report 2009/137}, year = {2009}, note = {\url{http://eprint.iacr.org/}}, }""" if "_bibtex" in sys.modules: b = _bibtex.open_string("foo", test, True) print b _bibtex.first(b) i = _bibtex.next(b) while i: print i items = i[4] for k in items.keys(): items[k] = _bibtex.expand(b, items[k], -1) print items i = _bibtex.next(b)