MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / context_from_sample

Function context_from_sample

samples-index.py:96–128  ·  view source on GitHub ↗

Return info for expanding a sample into a template. Args: api: string, name of api. keywords: list of string, list of keywords for the given api. dirname: string, directory name of the sample. desc: string, long description of the sample. uri: string, uri of the sample code if

(api, keywords, dirname, desc, uri)

Source from the content-addressed store, hash-verified

94
95
96def context_from_sample(api, keywords, dirname, desc, uri):
97 """Return info for expanding a sample into a template.
98
99 Args:
100 api: string, name of api.
101 keywords: list of string, list of keywords for the given api.
102 dirname: string, directory name of the sample.
103 desc: string, long description of the sample.
104 uri: string, uri of the sample code if provided in the README.
105
106 Returns:
107 A dictionary of values useful for template expansion.
108 """
109 if uri is None:
110 uri = BASE_HG_URI + dirname.replace("/", "%2F")
111 else:
112 uri = "".join(uri)
113 if api is None:
114 return None
115 else:
116 entry = DIRECTORY[api]
117 context = {
118 "api": api,
119 "version": entry["version"],
120 "api_name": wiki_escape(entry.get("title", entry.get("description"))),
121 "api_desc": wiki_escape(entry["description"]),
122 "api_icon": entry["icons"]["x32"],
123 "keywords": keywords,
124 "dir": dirname,
125 "uri": uri,
126 "desc": wiki_escape(desc),
127 }
128 return context
129
130
131def keyword_context_from_sample(keywords, dirname, desc, uri):

Callers 1

mainFunction · 0.85

Calls 2

wiki_escapeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…