Dear all,
since the introduction of the Pythonic BibFormat, Python has evolved
and is today calling for some changes in the BibFormat APIs. Indeed the
introduction of the global built-in function "format()" will lead to the
following changes:
1) Format elements interface:
In order to avoid name clash, the "format()" function defined by
format elements is now renamed to "format_element()".
2) BibFormatObject (bfo) "format" attribute:
In order to avoid confusion, the "format" attribute of
BibFormatObject instances is renamed to "output_format".
3) BibFormatObject "format" parameter of __init__ method:
Similar to change #2, the "format" parameter of the
BibFormatObject.__init__ function has been renamed to
"output_format".
For example, instead of:
def format(bfo):
"Return formatted foo"
current_output_format = bfo.format
bfo_foo = BibFormatObject(recID=5, ln='en', \
format='HB')
[...]
One will write:
def format_element(bfo): #1
"Return formatted foo"
current_output_format = bfo.output_format #2
bfo_foo = BibFormatObject(recID=5, ln='en', \
output_format='HB') #3
[...]
The above API changes will be part of next Invenio release. The changes
are trivial, but potentially touch a large number of customized files.
As a consequence, backward compatibility with code relying on previous
APIs will be enabled (except for #3) as a temporary measure to smoothen
the transition.
In any case since default provided format elements will be updated,
please review your customized format elements (or other customized
piece of code) that would import format elements to take into account
the new interface. For example:
from invenio.bibformat_elements import bfe_title
[...]
bfe_title.format_element(bfo)
To update the interface of your customized format elements, it should
be safe to use the following:
$ cd ~/my_format_elements/ # wherever your custom bfe_* files are
$ find . -name "bfe_*.py" -exec \
sed -i "s/def format(/def format_element(/" '{}' \;
Please make sure you backup your custom format elements first, review
the applied changes, and test in a non-production environment.
Changes #2 and #3 could also be updated in a similar automated way but
it is unlikely that they have been heavily used, so manual review/update
is preferred (for eg. `grep' for "bfo.format", "BibFormatObject", etc.)
Best regards
--
Jerome Caffaro