Full API¶
bibtexparser
— High-Level Entrypoints¶
bibtexparser.Library
— The class containing the parsed library¶
bibtexparser.model
— The classes used in the library¶
- class bibtexparser.model.Block(start_line: int | None = None, raw: str | None = None, parser_metadata: Dict[str, Any] | None = None)[source]¶
A abstract superclass of all top-level building blocks of a bibtex file.
E.g. a
@string
block, a@preamble
block, an@entry
block, a comment, etc.- get_parser_metadata(key: str) Any | None [source]¶
EXPERIMENTAL: get auxiliary information stored in
parser_metadata
.See attribute
parser_metadata
for more information.
- property parser_metadata: Dict[str, Any]¶
EXPERIMENTAL: field for middleware to store auxiliary information.
As an end-user, as long as you are not writing middleware, you probably do not need to use this field.
** Warning (experimental) ** The content of this field is undefined and may change at any time.
This field is intended for middleware to store auxiliary information. It is a key-value store, where the key is a string and the value is any python object. This allows for example to pass information between different middleware.
- property raw: str | None¶
The raw, unmodified string (bibtex) representation of this block.
Note: Middleware does not update this field, hence, after applying middleware to a library, this field may be outdated.
- set_parser_metadata(key: str, value: Any)[source]¶
EXPERIMENTAL: set auxiliary information stored in
parser_metadata
.See attribute
parser_metadata
for more information.
- property start_line: int | None¶
The line number of the first line of this block in the parsed string.
- class bibtexparser.model.Entry(entry_type: str, key: str, fields: List[Field], start_line: int | None = None, raw: str | None = None)[source]¶
Bibtex Blocks of the
@entry
type, e.g.@article{Cesar2013, ...}
.- property entry_type¶
The type of the entry, e.g.
article
in@article{Cesar2013, ...}
.
- property fields_dict: Dict[str, Field]¶
A dict of fields, with field keys as keys.
Note that with duplicate field keys, the behavior is undefined.
- get(key: str, default=None) Field | None [source]¶
Returns the field with the given key, or the default value if it does not exist.
- Parameters:
key – The key of the field.
default – The value to return if the field does not exist.
- items()[source]¶
Dict-mimicking, for partial v1.x backwards compatibility.
For newly written code, it’s recommended to use entry.entry_type, entry.key and entry.fields instead.
- property key¶
The key of the entry, e.g.
Cesar2013
in@article{Cesar2013, ...}
.
- class bibtexparser.model.ExplicitComment(comment: str, start_line: int | None = None, raw: str | None = None)[source]¶
Bibtex Blocks of the
@comment
type, e.g.@comment{This is a comment}
.- property comment: str¶
The value of the comment, e.g.
blabla
in@comment{blabla}
.
- class bibtexparser.model.Field(key: str, value: Any, start_line: int | None = None)[source]¶
A field of a Bibtex entry, e.g.
author = {John Doe}
.- property key: str¶
The key of the field, e.g.
author
inauthor = {John Doe}
.
- property start_line: int¶
The line number of the first line of this field in the originally parsed string.
- property value: Any¶
The value of the field, e.g.
{John Doe}
inauthor = {John Doe}
.
- class bibtexparser.model.ImplicitComment(comment: str, start_line: int | None = None, raw: str | None = None)[source]¶
Bibtex outside of an
@{...}
block, which is treated as a comment.- property comment: str¶
The (possibly multi-line) comment.
- class bibtexparser.model.Preamble(value: str, start_line: int | None = None, raw: str | None = None)[source]¶
Bibtex Blocks of the
@preamble
type, e.g.@preamble{This is a preamble}
.- property value: str¶
The value of the preamble, e.g.
blabla
in@preamble{blabla}
.
- class bibtexparser.model.String(key: str, value: str, start_line: int | None = None, raw: str | None = None)[source]¶
Bibtex Blocks of the
@string
type, e.g.@string{me = "My Name"}
.- property key: str¶
The key of the string, e.g.
me
in@string{me = "My Name"}
.
- property value: str¶
The value of the string, e.g.
"My Name"
in@string{me = "My Name"}
.