# regression testsuite for OpenOffice.org integration from Pyblio.Cite.WP.OpenOffice import OOo from Pyblio.Format import B, one from Pyblio import Registry, Attribute, Store Registry.load_default_settings() s = Registry.getSchema('org.pybliographer/bibtex/0.1') db = Store.get('memory').dbcreate(None, s) style = u'This has key ' + B[one('id')] formatter = style(db) # tests begin here oo = OOo() oo.connect() oo.text.setString(u'') refs = [(1, 'a', 'bibtex-a'), (2, 'b', 'bibtex-b')] oo.cite(refs, None) # check that the citations have been inserted in the document r = oo.text.getString() assert r == u'[a][b]', repr(r) # check that the document can return the existing citations r = oo.fetch() assert r == refs, repr(r)
# bibliography. from Pyblio.Cite.Citator import Citator from Pyblio import Registry citator = Citator() citator.xmlload(os.path.join(Registry.RIP_dirs['system'], 'unsrt.cip')) # Citations are inserted in word processors. For the purpose of this # example, we use either a "virtual word processor" that helps writing # citations to a simple file, or the actual OpenOffice interface. if ou_f == 'OOo': # Connect to OpenOffice from Pyblio.Cite.WP.OpenOffice import OOo wp = OOo() wp.connect() elif ou_f == 'LyX': from Pyblio.Cite.WP.LyX import LyX wp = LyX() wp.connect() else: # Connect to a file from Pyblio.Cite.WP.File import File import codecs output = codecs.open(ou_f, 'w', encoding='utf-8') wp = File(output)