Skip to content

Commit

Permalink
Fixes for new (broken) bibtexparser
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Mar 5, 2018
1 parent 95ca468 commit 09bfe04
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions UsersGuide/Makefile
Expand Up @@ -226,7 +226,7 @@ source/media/systemoverview.pdf: source/media/systemoverview.svg
inkscape -f $< --export-pdf $@
FNAME=`echo $@ | sed "s/[.]/-/g" | sed "s/-pdf/.pdf/g"`; if test "$$FNAME" != "$@"; then cp -a "$@" "$$FNAME"; fi
source/openmodelica.bib: resolve-crossref.py ../bibliography/openmodelica.bib
python resolve-crossref.py "../bibliography/openmodelica.bib" source/openmodelica.bib
./resolve-crossref.py "../bibliography/openmodelica.bib" source/openmodelica.bib
source/interface.inc: interface.mos
@mkdir -p tmp
$(OPENMODELICA_ROOT)/build/bin/omc -g=MetaModelica -d=nogen interface.mos
Expand Down Expand Up @@ -268,4 +268,4 @@ source/omchelptext.rst:
$(OPENMODELICA_ROOT)/build/bin/omc +help=omcall-sphinxoutput > "$@.tmp"
mv "$@.tmp" "$@"
source/tracreleases.rst: source/tracreleases.py
cd source && python ./tracreleases.py
cd source && ./tracreleases.py
14 changes: 8 additions & 6 deletions UsersGuide/resolve-crossref.py 100644 → 100755
@@ -1,22 +1,24 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import bibtexparser
import sys
import re, sys

with open(sys.argv[1], 'r') as bibtex_file:
bibtex_str = bibtex_file.read()

# Work-around for new (broken?) bibtexparser
for (m,month) in [("jan","January"),("feb","February"),("mar","March"),("apr","April"),("may","May"),("jun","June"),("jul","July"),("aug","August"),("sep","September"),("oct","October"),("nov","November"),("dec","December")]:
bibtex_str = re.sub(r"\n *month *= *%s *" % m, "\nmonth={%s}\n" % month, bibtex_str, flags=re.IGNORECASE)
bib_database = bibtexparser.loads(bibtex_str)

for e in bib_database.entries:
if e.has_key('crossref'):
if 'crossref' in e:
e2 = bib_database.entries_dict[e['crossref']]
for k in e2.keys():
if not e.has_key(k):
if not k in e:
e[k] = e2[k]
del(e['crossref'])
if 'pdf' in e:
del(e['pdf']) # Not used by the template and contains %20 sometimes...

open(sys.argv[2], "w").write(bibtexparser.dumps(bib_database).encode("utf8"))
open(sys.argv[2], "w").write(bibtexparser.dumps(bib_database))
2 changes: 1 addition & 1 deletion bibliography/openmodelica.bib
Expand Up @@ -1682,7 +1682,7 @@ @InProceedings{openmodelica.org:wladimir:TMS/DEVS:2012
@InProceedings{openmodelica.org:broman:SAC:2012,
author = {David Broman and Peter Fritzson and Görel Hedin and Johan Åkesson},
title = {A comparison of two metacompilation approaches to implementing a complex domain-specific language.},
crossref = {SAC2012 },
crossref = {SAC2012},
doi = {10.1145/2245276.2232092},
}

Expand Down

0 comments on commit 09bfe04

Please sign in to comment.