Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-bibtexparser for
openSUSE:Factory checked in at 2023-10-12 23:41:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-bibtexparser (Old)
and /work/SRC/openSUSE:Factory/.python-bibtexparser.new.1807 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-bibtexparser"
Thu Oct 12 23:41:50 2023 rev:9 rq:1117164 version:1.4.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-bibtexparser/python-bibtexparser.changes
2023-09-01 14:20:33.695124574 +0200
+++
/work/SRC/openSUSE:Factory/.python-bibtexparser.new.1807/python-bibtexparser.changes
2023-10-12 23:43:11.455247062 +0200
@@ -1,0 +2,12 @@
+Thu Oct 5 09:21:41 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 1.4.1:
+ * Set `align_values` to an int or bool to fix min alignment in
+ writing
+ * Fix some docstrings
+ * `customization.getnames`: respect protected names
+ * No dict caching in bibdatabase. This makes
+ the library slightly slower in some cases, but fixes
+ previously wrong caching.
+
+-------------------------------------------------------------------
Old:
----
python-bibtexparser-1.4.0.tar.gz
New:
----
python-bibtexparser-1.4.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-bibtexparser.spec ++++++
--- /var/tmp/diff_new_pack.PKF9dk/_old 2023-10-12 23:43:11.967265596 +0200
+++ /var/tmp/diff_new_pack.PKF9dk/_new 2023-10-12 23:43:11.967265596 +0200
@@ -17,7 +17,7 @@
Name: python-bibtexparser
-Version: 1.4.0
+Version: 1.4.1
Release: 0
Summary: Bibtex parser for python
License: BSD-3-Clause OR LGPL-3.0-only
++++++ python-bibtexparser-1.4.0.tar.gz -> python-bibtexparser-1.4.1.tar.gz
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-bibtexparser-1.4.0/.github/workflows/tests.yml
new/python-bibtexparser-1.4.1/.github/workflows/tests.yml
--- old/python-bibtexparser-1.4.0/.github/workflows/tests.yml 2022-09-23
14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/.github/workflows/tests.yml 2023-09-21
13:54:04.000000000 +0200
@@ -8,7 +8,7 @@
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
+ python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-bibtexparser-1.4.0/CODE_OF_CONDUCT.md
new/python-bibtexparser-1.4.1/CODE_OF_CONDUCT.md
--- old/python-bibtexparser-1.4.0/CODE_OF_CONDUCT.md 1970-01-01
01:00:00.000000000 +0100
+++ new/python-bibtexparser-1.4.1/CODE_OF_CONDUCT.md 2023-09-21
13:54:04.000000000 +0200
@@ -0,0 +1,128 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, religion, or sexual identity
+and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the
+ overall community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or
+ advances of any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email
+ address, without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for
moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail
address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+< various means of contact provided at mweiss.ch >.
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series
+of actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or
+permanent ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within
+the community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.0, available at
+https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
+
+Community Impact Guidelines were inspired by [Mozilla's code of conduct
+enforcement ladder](https://github.com/mozilla/diversity).
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see the FAQ at
+https://www.contributor-covenant.org/faq. Translations are available at
+https://www.contributor-covenant.org/translations.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-bibtexparser-1.4.0/CONTRIBUTING.md
new/python-bibtexparser-1.4.1/CONTRIBUTING.md
--- old/python-bibtexparser-1.4.0/CONTRIBUTING.md 1970-01-01
01:00:00.000000000 +0100
+++ new/python-bibtexparser-1.4.1/CONTRIBUTING.md 2023-09-21
13:54:04.000000000 +0200
@@ -0,0 +1,20 @@
+Thanks heaps for being interested in contributing to python-bibtexparser.
+
+We are always looking for people to improve the library. Contributions
include, but are not limited to:
+
+1. Opening well described issues for bugs or feature requests.
+2. Providing bugfixing PRs
+3. Implementing any of the issues or continuing any of the PRs labelled with
`needs help` or `good first issue`.
+
+Some guidelines:
+
+1. Be nice! Were all doing this in our free time; no one is obligated to do
anything.
+2. Add sufficient tests to your PRs
+3. Document your code.
+4. Don't hesitate to ask questions.
+
+Also note that there are currently two independent "default" branches:
+First, `master`, where we maintain a stable `v1.x` and where we merge almost
only backwards-compatible bugfixes.
+Second, `v2` where we work on a full re-implementation of the library.
+
+Issues targeting the `v2` branch are labelled `v2`.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-bibtexparser-1.4.0/README.rst
new/python-bibtexparser-1.4.1/README.rst
--- old/python-bibtexparser-1.4.0/README.rst 2022-09-23 14:40:05.000000000
+0200
+++ new/python-bibtexparser-1.4.1/README.rst 2023-09-21 13:54:04.000000000
+0200
@@ -1,20 +1,16 @@
python-bibtexparser
===================
-Python library to parse `bibtex <https://en.wikipedia.org/wiki/BibTeX>`_ files.
+Python 3 library to parse `bibtex <https://en.wikipedia.org/wiki/BibTeX>`_
files.
.. contents::
-Bibtexparser relies on `pyparsing <https://pypi.python.org/pypi/pyparsing>`_
and is compatible with Python 3.3 or newer.
-
Documentation
-------------
-Our documentation includes the installation procedure, a tutorial, the API and
advices to report a bug.
-References, related projects and softwares based on bibtexparser are also
listed. If you would like to appear on this list, feel free to open a ticket or
send an email.
-
+Our documentation includes the installation procedure, a tutorial, the API and
advices to report a bug:
`Documentation on readthedocs.io <https://bibtexparser.readthedocs.io/>`_
Upgrading
@@ -39,6 +35,21 @@
The parser evolved to a new core based on pyparsing.
-News (July 7h, 2022): This library has a new maintainer (`@MiWeiss
<https://github.com/MiWeiss>`_).
-Versions 1.x will be mostly bugfixes and maintenance.
-In the meantime, we are working on a new version 2.0.0 which will be a
complete rewrite of the library.
+Since 2022, after a long stale period, this library has a new maintainer
(`@MiWeiss <https://github.com/MiWeiss>`_).
+
+
+`v2` Announcement
+-----------------
+
+Version 1.x, is trusted and used by more than 1300 projects, with much of its
code being ~10 years old. Our primary objective in maintaining v1.x is to
provide stability and backwards compatibility to these projects - such that
they can safely and easily migrate to new versions.
+
+Still, there's much room for large-scale improvements and changes to modernize
bibtexparser. Hence, we are working on a new version 2.0.0 which is a complete
rewrite of the library, providing amongst other the following advantages:
+
+- Order of magnitudes faster
+- Type-Hints and extensive documentation
+- Easily customizable parsing **and** writing
+- Access to raw, unparsed bibtex.
+- Fault-Tolerant: Able to parse files with syntax errors
+- Massively simplified, robuster handling of de- and encoding (special chars,
...).
+
+Check out the `v2 dev branch
<https://github.com/sciunto-org/python-bibtexparser/tree/v2>`_ and the `v2
coordination issue
<https://github.com/sciunto-org/python-bibtexparser/issues/318>`_ to get a
sneak preview. Also - if you're keen - we're always looking for contributors.
Do not hesitate to get in contact with us.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-bibtexparser-1.4.0/bibtexparser/__init__.py
new/python-bibtexparser-1.4.1/bibtexparser/__init__.py
--- old/python-bibtexparser-1.4.0/bibtexparser/__init__.py 2022-09-23
14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/bibtexparser/__init__.py 2023-09-21
13:54:04.000000000 +0200
@@ -25,7 +25,7 @@
'loads', 'load', 'dumps', 'dump', 'bibdatabase',
'bparser', 'bwriter', 'bibtexexpression', 'latexenc', 'customization',
]
-__version__ = '1.4.0'
+__version__ = '1.4.1'
from . import bibdatabase, bibtexexpression, bparser, bwriter, latexenc,
customization
@@ -75,7 +75,7 @@
:param bib_database: bibliographic database object
:type bib_database: BibDatabase
- :param writer: custom writer to use (optional) (not yet implemented)
+ :param writer: custom writer to use (optional)
:type writer: BibTexWriter
:returns: BibTeX string
:rtype: unicode
@@ -93,7 +93,7 @@
:type bib_database: BibDatabase
:param bibtex_file: file to write to
:type bibtex_file: file
- :param writer: custom writer to use (optional) (not yet implemented)
+ :param writer: custom writer to use (optional)
:type writer: BibTexWriter
Example::
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-bibtexparser-1.4.0/bibtexparser/bibdatabase.py
new/python-bibtexparser-1.4.1/bibtexparser/bibdatabase.py
--- old/python-bibtexparser-1.4.0/bibtexparser/bibdatabase.py 2022-09-23
14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/bibtexparser/bibdatabase.py 2023-09-21
13:54:04.000000000 +0200
@@ -86,17 +86,15 @@
result.append(str(entry.get(field, '')).lower()) # Sorting always
as string
return tuple(result)
- def _make_entries_dict(self):
- for entry in self.entries:
- self._entries_dict[entry['ID']] = entry
-
def get_entry_dict(self):
- """Return a dictionary of BibTeX entries.
- The dict key is the BibTeX entry key
+ """Return a dictionary of BibTeX entries, where dict key is the BibTeX
entry key.
+
+ This method re-creates the dict every time it is called,
+ hence subsequent calls should be avoided with large databases.
"""
- # If the hash has never been made, make it
- if not self._entries_dict:
- self._make_entries_dict()
+ self._entries_dict = dict()
+ for entry in self.entries:
+ self._entries_dict[entry['ID']] = entry
return self._entries_dict
entries_dict = property(get_entry_dict)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-bibtexparser-1.4.0/bibtexparser/bparser.py
new/python-bibtexparser-1.4.1/bibtexparser/bparser.py
--- old/python-bibtexparser-1.4.0/bibtexparser/bparser.py 2022-09-23
14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/bibtexparser/bparser.py 2023-09-21
13:54:04.000000000 +0200
@@ -49,7 +49,7 @@
:param interpolate_strings: bool (default True)
If True, replace bibtex string by their value, else uses
BibDataString objects.
- :param common_strings: bool (default False)
+ :param common_strings: bool (default True)
Include common string definitions (e.g. month abbreviations) to
the bibtex file.
:param add_missing_from_crossref: bool (default False)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-bibtexparser-1.4.0/bibtexparser/bwriter.py
new/python-bibtexparser-1.4.1/bibtexparser/bwriter.py
--- old/python-bibtexparser-1.4.0/bibtexparser/bwriter.py 2022-09-23
14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/bibtexparser/bwriter.py 2023-09-21
13:54:04.000000000 +0200
@@ -5,7 +5,7 @@
import logging
from enum import Enum, auto
-from typing import Dict, Callable, Iterable
+from typing import Dict, Callable, Iterable, Union
from bibtexparser.bibdatabase import (BibDatabase, COMMON_STRINGS,
BibDataString,
BibDataStringExpression)
@@ -15,6 +15,9 @@
__all__ = ['BibTexWriter']
+# A list of entries that should not be included in the content (key = value)
of a BibTex entry
+ENTRY_TO_BIBTEX_IGNORE_ENTRIES = ['ENTRYTYPE', 'ID']
+
class SortingStrategy(Enum):
"""
@@ -89,9 +92,12 @@
self.contents = ['comments', 'preambles', 'strings', 'entries']
#: Character(s) for indenting BibTeX field-value pairs. Default:
single space.
self.indent = ' '
- #: Align values. Determines the maximal number of characters used in
any fieldname and aligns all values
- # according to that by filling up with single spaces. Default: False
- self.align_values = False
+ #: Align values. Aligns all values according to a given length by
padding with single spaces.
+ # If align_values is true, the maximum number of characters used in
any field name is used as the length.
+ # If align_values is a number, the greater of the specified value
or the number of characters used in the
+ # field name is used as the length.
+ # Default: False
+ self.align_values: Union[int, bool] = False
#: Align multi-line values. Formats a multi-line value such that the
text is aligned exactly
# on top of each other. Default: False
self.align_multiline_values = False
@@ -112,7 +118,7 @@
#: BibTeX syntax allows the comma to be optional at the end of the
last field in an entry.
#: Use this to enable writing this last comma in the bwriter output.
Defaults: False.
self.add_trailing_comma = False
- #: internal variable used if self.align_values = True
+ #: internal variable used if self.align_values = True or
self.align_values = <number>
self._max_field_width = 0
#: Whether common strings are written
self.common_strings = write_common_strings
@@ -143,10 +149,13 @@
else:
entries = bib_database.entries
- if self.align_values:
+ if self.align_values is True:
# determine maximum field width to be used
- widths = [max(map(len, entry.keys())) for entry in entries]
+ widths = [len(ele) for entry in entries for ele in entry if ele
not in ENTRY_TO_BIBTEX_IGNORE_ENTRIES]
self._max_field_width = max(widths)
+ elif type(self.align_values) == int:
+ # Use specified value
+ self._max_field_width = self.align_values
return self.entry_separator.join(self._entry_to_bibtex(entry) for
entry in entries)
@@ -165,7 +174,8 @@
else:
field_fmt = u",\n{indent}{field:<{field_max_w}} = {value}"
# Write field = value lines
- for field in [i for i in display_order if i not in ['ENTRYTYPE',
'ID']]:
+ for field in [i for i in display_order if i not in
ENTRY_TO_BIBTEX_IGNORE_ENTRIES]:
+ max_field_width = max(len(field), self._max_field_width)
try:
value = _str_or_expr_to_bibtex(entry[field])
@@ -176,12 +186,7 @@
# World}
# Calculate the indent of "World":
# Left of field (whitespaces before e.g. 'title')
- value_indent = len(self.indent)
- # Field itself (e.g. len('title'))
- if self._max_field_width > 0:
- value_indent += self._max_field_width
- else:
- value_indent += len(field)
+ value_indent = len(self.indent) + max_field_width
# Right of field ' = ' (<- 3 chars) + '{' (<- 1 char)
value_indent += 3 + 1
@@ -190,7 +195,7 @@
bibtex += field_fmt.format(
indent=self.indent,
field=field,
- field_max_w=self._max_field_width,
+ field_max_w=max_field_width,
value=value)
except TypeError:
raise TypeError(u"The field %s in entry %s must be a string"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-bibtexparser-1.4.0/bibtexparser/customization.py
new/python-bibtexparser-1.4.1/bibtexparser/customization.py
--- old/python-bibtexparser-1.4.0/bibtexparser/customization.py 2022-09-23
14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/bibtexparser/customization.py 2023-09-21
13:54:04.000000000 +0200
@@ -299,6 +299,61 @@
return parts
+def find_matching(
+ text: str,
+ opening: str,
+ closing: str,
+ ignore_escaped: bool = True,
+) -> dict:
+ r"""
+ Find matching 'brackets'.
+
+ :param text: The string to consider.
+ :param opening: The opening bracket (e.g. "(", "[", "{").
+ :param closing: The closing bracket (e.g. ")", "]", "}").
+ :param ignore_escaped: Ignore escaped bracket (e.g. "\(", "\[", "\{",
"\)", "\]", "\}").
+ :return: Dictionary with ``{index_opening: index_closing}``
+ """
+
+ a = []
+ b = []
+
+ if ignore_escaped:
+ opening = r"(?<!\\)" + opening
+ closing = r"(?<!\\)" + closing
+
+ for i in re.finditer(opening, text):
+ a.append(i.span()[0])
+
+ for i in re.finditer(closing, text):
+ b.append(-1 * i.span()[0])
+
+ if len(a) == 0 and len(b) == 0:
+ return {}
+
+ if len(a) != len(b):
+ raise IndexError(f"Unmatching {opening}...{closing} found")
+
+ brackets = sorted(a + b, key=lambda i: abs(i))
+
+ ret = {}
+ stack = []
+
+ for i in brackets:
+ if i >= 0:
+ stack.append(i)
+ else:
+ if len(stack) == 0:
+ raise IndexError(f"No closing {closing} at: {i:d}")
+ j = stack.pop()
+ ret[j] = -1 * i
+
+ if len(stack) > 0:
+ raise IndexError(f"No opening {opening} at {stack.pop():d}")
+
+ return ret
+
+
def getnames(names):
"""Convert people names as surname, firstnames
or surname, initials.
@@ -322,7 +377,29 @@
last = namesplit[0].strip()
firsts = [i.strip() for i in namesplit[1].split()]
else:
- namesplit = namestring.split()
+ if "{" in namestring and "}" in namestring:
+ try:
+ brackets = find_matching(namestring, "{", "}")
+ except IndexError:
+ tidynames.append(namestring)
+ continue
+ namesplit = []
+ start = 0
+ i = 0
+ while True:
+ if i in brackets:
+ i = brackets[i]
+ else:
+ i += 1
+ if i >= len(namestring):
+ break
+ if namestring[i] == " ":
+ namesplit.append(namestring[start:i])
+ start = i + 1
+ elif i == len(namestring) - 1:
+ namesplit.append(namestring[start:])
+ else:
+ namesplit = namestring.split()
last = namesplit.pop()
firsts = [i.replace('.', '. ').strip() for i in namesplit]
if last in ['jnr', 'jr', 'junior']:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-bibtexparser-1.4.0/bibtexparser/tests/test_bibtexwriter.py
new/python-bibtexparser-1.4.1/bibtexparser/tests/test_bibtexwriter.py
--- old/python-bibtexparser-1.4.0/bibtexparser/tests/test_bibtexwriter.py
2022-09-23 14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/bibtexparser/tests/test_bibtexwriter.py
2023-09-21 13:54:04.000000000 +0200
@@ -70,7 +70,7 @@
"""
self.assertEqual(result, expected)
- def test_align(self):
+ def test_align_bool(self):
bib_database = BibDatabase()
bib_database.entries = [{'ID': 'abc123',
'ENTRYTYPE': 'book',
@@ -87,6 +87,22 @@
"""
self.assertEqual(result, expected)
+ bib_database = BibDatabase()
+ bib_database.entries = [{'ID': 'veryveryverylongID',
+ 'ENTRYTYPE': 'book',
+ 'a': 'test',
+ 'bb': 'longvalue'}]
+ writer = BibTexWriter()
+ writer.align_values = True
+ result = bibtexparser.dumps(bib_database, writer)
+ expected = \
+"""@book{veryveryverylongID,
+ a = {test},
+ bb = {longvalue}
+}
+"""
+ self.assertEqual(result, expected)
+
with open('bibtexparser/tests/data/multiple_entries_and_comments.bib')
as bibtex_file:
bib_database = bibtexparser.load(bibtex_file)
writer = BibTexWriter()
@@ -121,6 +137,70 @@
"""
self.assertEqual(result, expected)
+ def test_align_int(self):
+ bib_database = BibDatabase()
+ bib_database.entries = [{'ID': 'abc123',
+ 'ENTRYTYPE': 'book',
+ 'author': 'test',
+ 'thisisaverylongkey': 'longvalue'}]
+ # Negative value should have no effect
+ writer = BibTexWriter()
+ writer.align_values = -20
+ result = bibtexparser.dumps(bib_database, writer)
+ expected = \
+"""@book{abc123,
+ author = {test},
+ thisisaverylongkey = {longvalue}
+}
+"""
+ self.assertEqual(result, expected)
+
+ # Value smaller than longest field name should only impact the "short"
field names
+ writer = BibTexWriter()
+ writer.align_values = 10
+ result = bibtexparser.dumps(bib_database, writer)
+ expected = \
+"""@book{abc123,
+ author = {test},
+ thisisaverylongkey = {longvalue}
+}
+"""
+ self.assertEqual(result, expected)
+
+
+ with open('bibtexparser/tests/data/multiple_entries_and_comments.bib')
as bibtex_file:
+ bib_database = bibtexparser.load(bibtex_file)
+ writer = BibTexWriter()
+ writer.contents = ['entries']
+ writer.align_values = 15
+ result = bibtexparser.dumps(bib_database, writer)
+ expected = \
+"""@book{Toto3000,
+ author = {Toto, A and Titi, B},
+ title = {A title}
+}
+
+@article{Wigner1938,
+ author = {Wigner, E.},
+ doi = {10.1039/TF9383400029},
+ issn = {0014-7672},
+ journal = {Trans. Faraday Soc.},
+ owner = {fr},
+ pages = {29--41},
+ publisher = {The Royal Society of Chemistry},
+ title = {The transition state method},
+ volume = {34},
+ year = {1938}
+}
+
+@book{Yablon2005,
+ author = {Yablon, A.D.},
+ publisher = {Springer},
+ title = {Optical fiber fusion slicing},
+ year = {2005}
+}
+"""
+ self.assertEqual(result, expected)
def test_entry_separator(self):
bib_database = BibDatabase()
@@ -206,17 +286,17 @@
result = bibtexparser.dumps(bib_database, writer)
expected = \
"""@article{Cesar2013,
- author = {Jean César},
- title = {A mutline line title is very amazing. It should be
- long enough to test multilines... with two lines or should we
- even test three lines... What an amazing title.},
- year = {2013},
- journal = {Nice Journal},
- abstract = {This is an abstract. This line should be long enough to test
- multilines... and with a french érudit word},
- comments = {A comment},
- keyword = {keyword1, keyword2,
- multiline-keyword1, multiline-keyword2}
+ author = {Jean César},
+ title = {A mutline line title is very amazing. It should be
+ long enough to test multilines... with two lines or should we
+ even test three lines... What an amazing title.},
+ year = {2013},
+ journal = {Nice Journal},
+ abstract = {This is an abstract. This line should be long enough to test
+ multilines... and with a french érudit word},
+ comments = {A comment},
+ keyword = {keyword1, keyword2,
+ multiline-keyword1, multiline-keyword2}
}
"""
self.assertEqual(result, expected)
@@ -331,17 +411,17 @@
result = bibtexparser.dumps(bib_database, writer)
expected = \
"""@article{Cesar2013,
- author = {Jean César},
- title = {A mutline line title is very amazing. It should be
- long enough to test multilines... with two lines or should we
- even test three lines... What an amazing title.},
- year = {2013},
- journal = {Nice Journal},
- abstract = {This is an abstract. This line should be long enough to test
- multilines... and with a french érudit word},
- comments = {A comment},
- keyword = {keyword1, keyword2,
- multiline-keyword1, multiline-keyword2}
+ author = {Jean César},
+ title = {A mutline line title is very amazing. It should be
+ long enough to test multilines... with two lines or should we
+ even test three lines... What an amazing title.},
+ year = {2013},
+ journal = {Nice Journal},
+ abstract = {This is an abstract. This line should be long enough to test
+ multilines... and with a french érudit word},
+ comments = {A comment},
+ keyword = {keyword1, keyword2,
+ multiline-keyword1, multiline-keyword2}
}
"""
self.assertEqual(result, expected)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-bibtexparser-1.4.0/bibtexparser/tests/test_customization.py
new/python-bibtexparser-1.4.1/bibtexparser/tests/test_customization.py
--- old/python-bibtexparser-1.4.0/bibtexparser/tests/test_customization.py
2022-09-23 14:40:05.000000000 +0200
+++ new/python-bibtexparser-1.4.1/bibtexparser/tests/test_customization.py
2023-09-21 13:54:04.000000000 +0200
@@ -22,6 +22,15 @@
'Jean la Tour',
'Jean le Tour',
'Mike ben Akar',
+ 'A. {Delgado de Molina}',
+ r'M. Vign{\'e}',
+ 'Tom {de Geus}',
+ 'Tom {de \{Geus}',
+ 'Tom \{de Geus\}',
+ 'Tom de {G\{eus}',
+ 'Foo B{\'a}r',
+ r'{G{\'{e}}rard} {Ben Arous}',
+ 'Incorrect {{name}',
#'Jean de la Tour',
#'Johannes Diderik van der Waals',
]
@@ -35,18 +44,20 @@
'la Tour, Jean',
'le Tour, Jean',
'ben Akar, Mike',
+ '{Delgado de Molina}, A.',
+ r'Vign{\'e}, M.',
+ '{de Geus}, Tom',
+ '{de \{Geus}, Tom',
+ 'Geus\}, Tom \{de',
+ 'de {G\{eus}, Tom',
+ 'B{\'a}r, Foo',
+ r'{Ben Arous}, {G{\'{e}}rard}',
+ 'Incorrect {{name}',
#'de la Tour, Jean',
#'van der Waals, Johannes Diderik',
]
self.assertEqual(result, expected)
- @unittest.skip('Bug #9')
- def test_getnames_braces(self):
- names = ['A. {Delgado de Molina}', r'M. Vign{\'e}']
- result = getnames(names)
- expected = ['Delgado de Molina, A.', 'Vigné, M.']
- self.assertEqual(result, expected)
-
###########
# page_double_hyphen
###########