Skip to content

Commit

Permalink
✨ Adding missing default allow_inplace_modification (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus authored Feb 14, 2024
1 parent 0eaf264 commit 5e00d18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bibtexparser/middlewares/month.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class _MonthInterpolator(BlockMiddleware, abc.ABC):
"""Abstract class to handle month-conversions."""

# docstr-coverage: inherited
def __init__(self, allow_inplace_modification: bool):
def __init__(self, allow_inplace_modification: bool = True):
super().__init__(
allow_inplace_modification=allow_inplace_modification,
allow_parallel_execution=True,
Expand Down
10 changes: 5 additions & 5 deletions docs/source/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The core functionality of bibtexparser is deliberately kept simple:
* Upon writing, the splitting is reversed and the blocks are joined together again, with few formatting options.

Advanced transformations of blocks, such as sorting, encoding, cross-referencing, etc. are not part of the core functionality,
but can be optionally added to the parse stack by using the corresponging middleware layers:
but can be optionally added to the parse stack by using the corresponding middleware layers:
Middleware layers helper classes providing the functionality take a library object and return a new, transformed version of said library.

Middleware Layers
Expand All @@ -28,9 +28,9 @@ Middleware Layers
# We want to add three new middleware layers to our parse stack:
layers = [
m.MonthIntMiddleware(True), # Months should be represented as int (0-12)
m.SeparateCoAuthors(True), # Co-authors should be separated as list of strings
m.SplitNameParts(True) # Individual Names should be split into first, von, last, jr parts
m.MonthIntMiddleware(), # Months should be represented as int (0-12)
m.SeparateCoAuthors(), # Co-authors should be separated as list of strings
m.SplitNameParts() # Individual Names should be split into first, von, last, jr parts
]
library = bibtexparser.parse_file('bibtex.bib', append_middleware=layers)
Expand Down Expand Up @@ -147,4 +147,4 @@ Specifically, a user may pass a :class:`bibtexparser.BibtexFormatter` object to
bib_str = bibtexparser.write_string(library, bibtex_format=bibtex_format)
A few more options are provided and we refer to the docstrings of :class:`bibtexparser.BibtexFormat` for details.
Note: Sorting of blocks and fields is done with the corresponding middleware, as described above.
Note: Sorting of blocks and fields is done with the corresponding middleware, as described above.
6 changes: 3 additions & 3 deletions examples/middelware.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@
"\n",
"# We want to add three new middleware layers to our parse stack:\n",
"layers = [\n",
" m.MonthIntMiddleware(True), # Months should be represented as int (0-12)\n",
" m.SeparateCoAuthors(True), # Co-authors should be separated\n",
" m.SplitNameParts(True) # Names should be split into first, von, last, jr parts\n",
" m.MonthIntMiddleware(), # Months should be represented as int (0-12)\n",
" m.SeparateCoAuthors(), # Co-authors should be separated\n",
" m.SplitNameParts() # Names should be split into first, von, last, jr parts\n",
"]\n",
"library_append_pstack = bibtexparser.parse_file('bibtex.bib', append_middleware=layers)\n",
"\n",
Expand Down

0 comments on commit 5e00d18

Please sign in to comment.