MCPcopy Index your code
hub / github.com/pyload/pyload / try_get

Function try_get

module/plugins/hoster/YoutubeCom.py:21–44  ·  view source on GitHub ↗
(data, *path)

Source from the content-addressed store, hash-verified

19
20
21def try_get(data, *path):
22 def get_one(src, what):
23 if isinstance(src, dict) and isinstance(what, basestring):
24 return src.get(what, None)
25 elif isinstance(src, list) and type(what) is int:
26 try:
27 return src[what]
28 except IndexError:
29 return None
30 elif callable(what):
31 try:
32 return what(src)
33 except Exception:
34 return None
35 else:
36 return None
37
38 res = get_one(data, path[0])
39 for item in path[1:]:
40 if res is None:
41 break
42 res = get_one(res, item)
43
44 return res
45
46
47class BIGHTTPRequest(HTTPRequest):

Callers 1

processMethod · 0.85

Calls 1

get_oneFunction · 0.85

Tested by

no test coverage detected