Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bibtexparser/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def write_file(
parse_stack: Optional[Iterable[Middleware]] = None,
append_middleware: Optional[Iterable[Middleware]] = None,
bibtex_format: Optional[BibtexFormat] = None,
encoding: str = "UTF-8",
) -> None:
"""Write a BibTeX database to a file.

Expand All @@ -134,15 +135,16 @@ def write_file(
If None, a default stack will be used.
:param append_middleware: List of middleware to append to the default stack.
Only applicable if `parse_stack` is None.
:param bibtex_format: Customized BibTeX format to use (optional)."""
:param bibtex_format: Customized BibTeX format to use (optional).
:param encoding: Encoding for the .bib file. Default encoding is "UTF-8"."""
bibtex_str = write_string(
library=library,
unparse_stack=parse_stack,
prepend_middleware=append_middleware,
bibtex_format=bibtex_format,
)
if isinstance(file, str):
with open(file, "w") as f:
with open(file, "w", encoding=encoding) as f:
f.write(bibtex_str)
else:
file.write(bibtex_str)
Expand Down