MCPcopy Index your code
hub / github.com/docker/docker-py / contexts

Method contexts

docker/context/api.py:101–125  ·  view source on GitHub ↗

Context list. Returns: (Context): List of context objects. Raises: :py:class:`docker.errors.APIError` If the server returns an error.

(cls)

Source from the content-addressed store, hash-verified

99
100 @classmethod
101 def contexts(cls):
102 """Context list.
103 Returns:
104 (Context): List of context objects.
105 Raises:
106 :py:class:`docker.errors.APIError`
107 If the server returns an error.
108 """
109 names = []
110 for dirname, dirnames, fnames in os.walk(get_meta_dir()):
111 for filename in fnames + dirnames:
112 if filename == METAFILE:
113 try:
114 data = json.load(
115 open(os.path.join(dirname, filename)))
116 names.append(data["Name"])
117 except Exception as e:
118 raise errors.ContextException(
119 f"Failed to load metafile {filename}: {e}",
120 ) from e
121
122 contexts = [cls.DEFAULT_CONTEXT]
123 for name in names:
124 contexts.append(Context.load_context(name))
125 return contexts
126
127 @classmethod
128 def get_current_context(cls):

Callers 2

test_lifecycleMethod · 0.80

Calls 5

get_meta_dirFunction · 0.85
walkMethod · 0.80
loadMethod · 0.80
joinMethod · 0.80
load_contextMethod · 0.80

Tested by 2

test_lifecycleMethod · 0.64