"""Modifications de fichiers de publications BibTeX C. Fouquere, Oct. 2007 Utilise pybliographer """ from Pyblio import Open from Pyblio.Format import BibTeX import sys # VERSION='0.1' usage = "usage: %prog file.bib" # Reading member file Member = open( 'membres.txt').readlines() for g in Member: sys.stdout.write('membre:: %s\n' % g) # Reading phd file Phd = open( 'phd.txt').readlines() #for g in Phd: #sys.stdout.write('phd:: %s\n' % g) # Reading of Bibtex files if len (sys.argv) < 2: parser.error("incorrect number of arguments") else: Base = Open.bibopen( sys.argv[2]) for f in Base.keys (): if Base[f].has_key('author'): authors = Base[f]['author'] for name in authors: sys.stdout.write('auteur:: %s\n' % name.last) for g in Member: if (g.rstrip('\n') == name.last): copy = name copy.last = 'BegBraceSlashunderlineBegBrace%sEndBraceEndBrace' % copy.last i = authors.authors.index(name) authors.authors.remove(name) authors.authors.insert(i,copy) Base[f]['author'] = authors for g in Phd: if (g.rstrip('\n') == name.last): copy = name copy.last = 'BegBraceSlashunderlineBegBraceSlashunderlineBegBrace%sEndBraceEndBraceEndBrace' % copy.last i = authors.authors.index(name) authors.authors.remove(name) authors.authors.insert(i,copy) Base[f]['author'] = authors # Printing Open.bibwrite (Base.iterator (), how = "BibTeX", out = sys.stdout)