def get_download_url_for_platform(url_templates, platform_info_dict):
 os_ok = False
 architecture_ok = False
 for url_template in url_templates:
  os_name = url_template.get('os', None)
  architecture = url_template.get('architecture', None)
  if os_name:
   if (os_name.lower() == platform_info_dict['os']):
    os_ok = True
   else:
    os_ok = False
  else:
   os_ok = True
  if architecture:
   if (architecture.lower() == platform_info_dict['architecture']):
    architecture_ok = True
   else:
    architecture_ok = False
  else:
   architecture_ok = True
  if (os_ok and architecture_ok):
   return url_template
 return None

def get_download_url_for_platform ( url_templates , platform_info_dict ) : os_ok = False architecture_ok = False for url_template in url_templates : os_name = url_template . get ( 'os' , None ) architecture = url_template . get ( 'architecture' , None ) if os_name : if ( os_name . lower ( ) == platform_info_dict [ 'os' ] ) : os_ok = True else : os_ok = False else : os_ok = True if architecture : if ( architecture . lower ( ) == platform_info_dict [ 'architecture' ] ) : architecture_ok = True else : architecture_ok = False else : architecture_ok = True if ( os_ok and architecture_ok ) : return url_template return None
compare the dict returned by get_platform_info() with the values specified in the url_template element .