From 5bb0ce0694ce736a5b6e7a884f439371b6ac99b0 Mon Sep 17 00:00:00 2001 From: Fabien Bochu Date: Thu, 9 Mar 2017 14:19:55 +0100 Subject: [PATCH] Support zbar 0.11 symbologies --- src/zbarlight/__init__.py | 4 ++-- src/zbarlight/_zbarlight.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/zbarlight/__init__.py b/src/zbarlight/__init__.py index f65b11a..b76f910 100644 --- a/src/zbarlight/__init__.py +++ b/src/zbarlight/__init__.py @@ -8,7 +8,7 @@ __version__ = pkg_resources.get_distribution('zbarlight').version -__ALL__ = ['scan_codes', 'qr_code_scanner'] +__ALL__ = ['Symbologies', 'UnknownSymbologieError', 'scan_codes', 'qr_code_scanner'] class UnknownSymbologieError(Exception): @@ -29,7 +29,7 @@ def scan_codes(code_type, image): .. [#zbar_symbologies] http://zbar.sourceforge.net/iphone/userguide/symbologies.html Args: - code_type (str): Code type to search + code_type (str): Code type to search (see ``zbarlight.Symbologies`` for supported values) image (PIL.Image.Image): Image to scan returns: diff --git a/src/zbarlight/_zbarlight.c b/src/zbarlight/_zbarlight.c index cebb0c0..8d47f39 100644 --- a/src/zbarlight/_zbarlight.c +++ b/src/zbarlight/_zbarlight.c @@ -116,7 +116,15 @@ static struct PyModuleDef zbarlight_moduledef = { PyObject* PyInit__zbarlight(void) { /* Python 3 way */ PyObject* module = PY_INIT_FCT(); PyObject * symbologies = Py_BuildValue( + #if ZBAR_VERSION_MAJOR == 0 && ZBAR_VERSION_MINOR < 11 "{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}", + #else + "{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}", + "DATABAR", ZBAR_DATABAR, + "DATABAR_EXP", ZBAR_DATABAR_EXP, + "CODABAR", ZBAR_CODABAR, + "CODE93", ZBAR_CODE93, + #endif "EAN8", ZBAR_EAN8, "UPCE", ZBAR_UPCE, "ISBN10", ZBAR_ISBN10, @@ -129,7 +137,6 @@ PyObject* PyInit__zbarlight(void) { /* Python 3 way */ "QRCODE", ZBAR_QRCODE, "CODE128", ZBAR_CODE128 ); - PyModule_AddObject(module, "Symbologies", symbologies); return module; }