Skip to content

Commit

Permalink
Support zbar 0.11 symbologies
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Bochu committed Mar 9, 2017
1 parent c76ab6e commit 5bb0ce0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/zbarlight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion src/zbarlight/_zbarlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -129,7 +137,6 @@ PyObject* PyInit__zbarlight(void) { /* Python 3 way */
"QRCODE", ZBAR_QRCODE,
"CODE128", ZBAR_CODE128
);

PyModule_AddObject(module, "Symbologies", symbologies);
return module;
}
Expand Down

0 comments on commit 5bb0ce0

Please sign in to comment.