From 57621cf96960a4e64a25383b50f8876183f632f6 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 4 Jan 2018 20:14:42 +0100 Subject: Use correct filtering of C API symbols from C header Recently the C API header was reformatted by adding more white-spaces, though the filtering function from example was not adjusted to it. Now the lines are stripped before further processing. Fixes #82 Signed-off-by: Szczepan Zalega --- python_bindings_example.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'python_bindings_example.py') diff --git a/python_bindings_example.py b/python_bindings_example.py index 37b70b8..1740a76 100755 --- a/python_bindings_example.py +++ b/python_bindings_example.py @@ -25,14 +25,18 @@ def get_library(): with open(fp, 'r') as f: declarations = f.readlines() + cnt = 0 a = iter(declarations) for declaration in a: - if declaration.startswith('NK_C_API'): + if declaration.strip().startswith('NK_C_API'): declaration = declaration.replace('NK_C_API', '').strip() - while not ';' in declaration: + while ';' not in declaration: declaration += (next(a)).strip() - #print(declaration) + # print(declaration) ffi.cdef(declaration, override=True) + cnt +=1 + print('Imported {} declarations'.format(cnt)) + C = None import os, sys @@ -68,10 +72,10 @@ a = raw_input() if not a == 'continue': exit() -ADMIN = raw_input('Please enter your admin PIN (empty string uses 12345678)') +ADMIN = raw_input('Please enter your admin PIN (empty string uses 12345678) ') ADMIN = ADMIN or '12345678' # use default if empty string -show_log = raw_input('Should log messages be shown (please write "yes" to enable)?') == 'yes' +show_log = raw_input('Should log messages be shown (please write "yes" to enable)? ') == 'yes' libnitrokey = get_library() libnitrokey.NK_set_debug(show_log) # do not show debug messages -- cgit v1.2.1