Skip to content

Commit

Permalink
Allow searching for multiple possible sets of headers
Browse files Browse the repository at this point in the history
  • Loading branch information
natezb committed Jun 1, 2017
1 parent 45b5d41 commit 84a1613
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions nicelib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def select_platform_value(platform_dict):


def to_tuple(value):
"""Convert value to a tuple, or if it is a string, wrap it in a tuple"""
return (value,) if isinstance(value, basestring) else tuple(value)
"""Convert value to a tuple, or if it is a string or dict, wrap it in a tuple"""
return (value,) if isinstance(value, (basestring, dict)) else tuple(value)


def handle_header_path(path):
Expand All @@ -48,21 +48,29 @@ def handle_header_path(path):
else:
raise ValueError("Cannot find library header")

header_dict = select_platform_value(path)
if 'header' not in header_dict:
raise KeyError("Header dict must contain key 'header'")
header_tup = to_tuple(select_platform_value(path))
for header_dict in header_tup:
if 'header' not in header_dict:
raise KeyError("Header dict must contain key 'header'")

header_names = to_tuple(header_dict['header'])
include_dirs = to_tuple(header_dict.get('path', ()))
header_names = to_tuple(header_dict['header'])
include_dirs = to_tuple(header_dict.get('path', ()))

headers = [find_header(h, include_dirs) for h in header_names]
try:
headers = [find_header(h, include_dirs) for h in header_names]
except:
continue

if 'predef' in header_dict:
predef_header = find_header(header_dict['predef'], include_dirs)
else:
predef_header = None
if 'predef' in header_dict:
try:
predef_header = find_header(header_dict['predef'], include_dirs)
except:
continue
else:
predef_header = None

return headers, predef_header
return headers, predef_header
raise ValueError("Could not find library header")


def find_header(header_name, include_dirs):
Expand Down

0 comments on commit 84a1613

Please sign in to comment.