/usr/lib/python2.7/dist-packages/bibtexparser/bibdatabase.py is in python-bibtexparser 0.6.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | from collections import OrderedDict
import sys
if sys.version_info.major == 2:
TEXT_TYPE = unicode
else:
TEXT_TYPE = str
class BibDatabase(object):
"""
A bibliographic database object following the data structure of a BibTeX file.
"""
def __init__(self):
#: List of BibTeX entries, for example `@book{...}`, `@article{...}`, etc. Each entry is a simple dict with
#: BibTeX field-value pairs, for example `'author': 'Bird, R.B. and Armstrong, R.C. and Hassager, O.'` Each
#: entry will always have the following dict keys (in addition to other BibTeX fields):
#: - `ID` (BibTeX key)
#: - `ENTRYTYPE` (entry type in lowercase, e.g. `book`, `article` etc.)
self.entries = []
self._entries_dict = {}
#: List of BibTeX comment (`@comment{...}`) blocks.
self.comments = []
#: OrderedDict of BibTeX string definitions (`@string{...}`). In order of definition.
self.strings = OrderedDict() # Not sure if order is import, keep order just in case
#: List of BibTeX preamble (`@preamble{...}`) blocks.
self.preambles = []
def get_entry_list(self):
"""Get a list of bibtex entries.
:returns: BibTeX entries
:rtype: list
.. deprecated:: 0.5.6
Use :attr:`entries` instead.
"""
return self.entries
@staticmethod
def entry_sort_key(entry, fields):
result = []
for field in fields:
result.append(TEXT_TYPE(entry.get(field, '')).lower()) # Sorting always as string
return tuple(result)
def get_entry_dict(self):
"""Return a dictionary of BibTeX entries.
The dict key is the BibTeX entry key
"""
# If the hash has never been made, make it
if not self._entries_dict:
for entry in self.entries:
self._entries_dict[entry['ID']] = entry
return self._entries_dict
entries_dict = property(get_entry_dict)
|