def context_from_sample(api, keywords, dirname, desc, uri):
 if (uri is None):
  uri = (BASE_HG_URI + dirname.replace('/', '%2F'))
 else:
  uri = ''.join(uri)
 if (api is None):
  return None
 else:
  entry = DIRECTORY[api]
  context = {'api': api, 'version': entry['version'], 'api_name': wiki_escape(entry.get('title', entry.get('description'))), 'api_desc': wiki_escape(entry['description']), 'api_icon': entry['icons']['x32'], 'keywords': keywords, 'dir': dirname, 'uri': uri, 'desc': wiki_escape(desc)}
  return context

def context_from_sample ( api , keywords , dirname , desc , uri ) : if ( uri is None ) : uri = ( BASE_HG_URI + dirname . replace ( '/' , '%2F' ) ) else : uri = '' . join ( uri ) if ( api is None ) : return None else : entry = DIRECTORY [ api ] context = { 'api' : api , 'version' : entry [ 'version' ] , 'api_name' : wiki_escape ( entry . get ( 'title' , entry . get ( 'description' ) ) ) , 'api_desc' : wiki_escape ( entry [ 'description' ] ) , 'api_icon' : entry [ 'icons' ] [ 'x32' ] , 'keywords' : keywords , 'dir' : dirname , 'uri' : uri , 'desc' : wiki_escape ( desc ) } return context
return info for expanding a sample into a template .