"""
Remove comments from bib file.
"""
from textx import metamodel_for_language
from txbibtex import bibentry_str

BIB_FILE = 'references.bib'
bibfile = metamodel_for_language('bibtex').model_from_file(BIB_FILE)

# Drop line comments.
print('\n'.join([bibentry_str(e) for e in bibfile.entries
                 if e.__class__.__name__ != 'BibLineComment']))

[((153, 185), 'textx.metamodel_for_language', 'metamodel_for_language', (['"""bibtex"""'], {}), "('bibtex')\n", (175, 185), False, 'from textx import metamodel_for_language\n'), ((252, 267), 'txbibtex.bibentry_str', 'bibentry_str', (['e'], {}), '(e)\n', (264, 267), False, 'from txbibtex import bibentry_str\n')]