diff --git a/src/interface/__main__.py b/src/interface/__main__.py index f298664..07a44c4 100644 --- a/src/interface/__main__.py +++ b/src/interface/__main__.py @@ -1,6 +1,6 @@ # python-exiv2 - Python interface to exiv2 # http://github.com/jim-easterbrook/python-exiv2 -# Copyright (C) 2021-22 Jim Easterbrook jim@jim-easterbrook.me.uk +# Copyright (C) 2021-24 Jim Easterbrook jim@jim-easterbrook.me.uk # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,7 +31,6 @@ def main(): print('python-exiv2 version:', exiv2.__version__) print('python-exiv2 examples:', os.path.join(os.path.dirname(__file__), 'examples')) - print('BMFF support:', exiv2.enableBMFF(False)) if args.verbosity: print('libexiv2 build options:') pprint.pprint(exiv2.versionInfo()) diff --git a/src/interface/image.i b/src/interface/image.i index 23d4cd9..fcee5c6 100644 --- a/src/interface/image.i +++ b/src/interface/image.i @@ -139,19 +139,30 @@ Create a MemIo subclass of BasicIo using the provided memory. } } +// Enable BMFF if libexiv2 was compiled with BMFF support +%init %{ +#if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0, 28, 3) +Exiv2::enableBMFF(true); +#endif +%} + // Make enableBMFF() function available regardless of exiv2 version %feature("docstring") enableBMFF "Enable BMFF support. -If libexiv2 has been built with BMFF support included it can be enabled -by calling enableBMFF(True). +If libexiv2 has been built with BMFF support it is already enabled +and this fubction does nothing. :type enable: bool, optional :param enable: Set to True to enable BMFF file access. :rtype: bool :return: True if libexiv2 has been built with BMFF support."; %inline %{ static bool enableBMFF(bool enable) { + // deprecated since 2024-08-01 + PyErr_WarnEx(PyExc_DeprecationWarning, + "BMFF is already enabled if libexiv2 was built with BMFF support", + 1); #ifdef EXV_ENABLE_BMFF - return Exiv2::enableBMFF(enable); + return true; #else return false; #endif // EXV_ENABLE_BMFF diff --git a/src/swig-0_27_7/__main__.py b/src/swig-0_27_7/__main__.py index f298664..07a44c4 100644 --- a/src/swig-0_27_7/__main__.py +++ b/src/swig-0_27_7/__main__.py @@ -1,6 +1,6 @@ # python-exiv2 - Python interface to exiv2 # http://github.com/jim-easterbrook/python-exiv2 -# Copyright (C) 2021-22 Jim Easterbrook jim@jim-easterbrook.me.uk +# Copyright (C) 2021-24 Jim Easterbrook jim@jim-easterbrook.me.uk # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,7 +31,6 @@ def main(): print('python-exiv2 version:', exiv2.__version__) print('python-exiv2 examples:', os.path.join(os.path.dirname(__file__), 'examples')) - print('BMFF support:', exiv2.enableBMFF(False)) if args.verbosity: print('libexiv2 build options:') pprint.pprint(exiv2.versionInfo()) diff --git a/src/swig-0_27_7/image_wrap.cxx b/src/swig-0_27_7/image_wrap.cxx index 394ebaa..3fc7b44 100644 --- a/src/swig-0_27_7/image_wrap.cxx +++ b/src/swig-0_27_7/image_wrap.cxx @@ -4358,8 +4358,12 @@ namespace Exiv2 { static bool enableBMFF(bool enable) { + // deprecated since 2024-08-01 + PyErr_WarnEx(PyExc_DeprecationWarning, + "BMFF is already enabled if libexiv2 was built with BMFF support", + 1); #ifdef EXV_ENABLE_BMFF - return Exiv2::enableBMFF(enable); + return true; #else return false; #endif // EXV_ENABLE_BMFF @@ -7047,8 +7051,8 @@ static PyMethodDef SwigMethods[] = { { "enableBMFF", _wrap_enableBMFF, METH_VARARGS, "\n" "Enable BMFF support.\n" "\n" - "If libexiv2 has been built with BMFF support included it can be enabled\n" - "by calling enableBMFF(True).\n" + "If libexiv2 has been built with BMFF support it is already enabled\n" + "and this fubction does nothing.\n" ":type enable: bool, optional\n" ":param enable: Set to True to enable BMFF file access.\n" ":rtype: bool\n" @@ -7062,8 +7066,8 @@ SWIGINTERN PyGetSetDef SwigPyBuiltin__Exiv2__Image_getset[] = { { (char *)"__dict__", SwigPyBuiltin_FunpackGetterClosure, 0, (char *)"\n" "Enable BMFF support.\n" "\n" - "If libexiv2 has been built with BMFF support included it can be enabled\n" - "by calling enableBMFF(True).\n" + "If libexiv2 has been built with BMFF support it is already enabled\n" + "and this fubction does nothing.\n" ":type enable: bool, optional\n" ":param enable: Set to True to enable BMFF file access.\n" ":rtype: bool\n" @@ -8887,6 +8891,11 @@ SWIG_init(void) { } +#if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0, 28, 3) + Exiv2::enableBMFF(true); +#endif + + { PyObject* module = PyImport_ImportModule("enum"); if (!module) diff --git a/src/swig-0_28_3/__main__.py b/src/swig-0_28_3/__main__.py index f298664..07a44c4 100644 --- a/src/swig-0_28_3/__main__.py +++ b/src/swig-0_28_3/__main__.py @@ -1,6 +1,6 @@ # python-exiv2 - Python interface to exiv2 # http://github.com/jim-easterbrook/python-exiv2 -# Copyright (C) 2021-22 Jim Easterbrook jim@jim-easterbrook.me.uk +# Copyright (C) 2021-24 Jim Easterbrook jim@jim-easterbrook.me.uk # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,7 +31,6 @@ def main(): print('python-exiv2 version:', exiv2.__version__) print('python-exiv2 examples:', os.path.join(os.path.dirname(__file__), 'examples')) - print('BMFF support:', exiv2.enableBMFF(False)) if args.verbosity: print('libexiv2 build options:') pprint.pprint(exiv2.versionInfo()) diff --git a/src/swig-0_28_3/image_wrap.cxx b/src/swig-0_28_3/image_wrap.cxx index 9bd49ed..85ebfa7 100644 --- a/src/swig-0_28_3/image_wrap.cxx +++ b/src/swig-0_28_3/image_wrap.cxx @@ -4358,8 +4358,12 @@ namespace Exiv2 { static bool enableBMFF(bool enable) { + // deprecated since 2024-08-01 + PyErr_WarnEx(PyExc_DeprecationWarning, + "BMFF is already enabled if libexiv2 was built with BMFF support", + 1); #ifdef EXV_ENABLE_BMFF - return Exiv2::enableBMFF(enable); + return true; #else return false; #endif // EXV_ENABLE_BMFF @@ -7073,8 +7077,8 @@ static PyMethodDef SwigMethods[] = { { "enableBMFF", _wrap_enableBMFF, METH_VARARGS, "\n" "Enable BMFF support.\n" "\n" - "If libexiv2 has been built with BMFF support included it can be enabled\n" - "by calling enableBMFF(True).\n" + "If libexiv2 has been built with BMFF support it is already enabled\n" + "and this fubction does nothing.\n" ":type enable: bool, optional\n" ":param enable: Set to True to enable BMFF file access.\n" ":rtype: bool\n" @@ -7088,8 +7092,8 @@ SWIGINTERN PyGetSetDef SwigPyBuiltin__Exiv2__Image_getset[] = { { (char *)"__dict__", SwigPyBuiltin_FunpackGetterClosure, 0, (char *)"\n" "Enable BMFF support.\n" "\n" - "If libexiv2 has been built with BMFF support included it can be enabled\n" - "by calling enableBMFF(True).\n" + "If libexiv2 has been built with BMFF support it is already enabled\n" + "and this fubction does nothing.\n" ":type enable: bool, optional\n" ":param enable: Set to True to enable BMFF file access.\n" ":rtype: bool\n" @@ -8904,6 +8908,11 @@ SWIG_init(void) { } +#if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0, 28, 3) + Exiv2::enableBMFF(true); +#endif + + { PyObject* module = PyImport_ImportModule("enum"); if (!module) diff --git a/tests/test_image.py b/tests/test_image.py index d93ab83..778c3d1 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -39,8 +39,9 @@ def check_result(self, result, expected_type, expected_value): self.assertEqual(result, expected_value) def test_BMFF(self): - self.assertEqual(exiv2.enableBMFF(True), - exiv2.versionInfo()['EXV_ENABLE_BMFF']) + with self.assertWarns(DeprecationWarning): + enabled = exiv2.enableBMFF(True) + self.assertEqual(enabled, exiv2.versionInfo()['EXV_ENABLE_BMFF']) with open(self.bmff_path, 'rb') as f: image_data = f.read() if not exiv2.versionInfo()['EXV_ENABLE_BMFF']: