MCPcopy Index your code
hub / github.com/plotly/plotly.py / __getitem__

Method __getitem__

plotly/io/_templates.py:63–91  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

61 return iter(self._templates)
62
63 def __getitem__(self, item):
64 if isinstance(item, str):
65 template_names = item.split("+")
66 else:
67 template_names = [item]
68
69 templates = []
70 for template_name in template_names:
71 template = self._templates[template_name]
72 if template is Lazy:
73 from plotly.graph_objs.layout import Template
74
75 if template_name == "none":
76 # "none" is a special built-in named template that applied no defaults
77 template = Template(data_scatter=[{}])
78 self._templates[template_name] = template
79 else:
80 # Load template from package data
81 path = os.path.join(
82 "package_data", "templates", template_name + ".json"
83 )
84 template_str = pkgutil.get_data("plotly", path).decode("utf-8")
85 template_dict = json.loads(template_str)
86 template = Template(template_dict, _validate=False)
87
88 self._templates[template_name] = template
89 templates.append(self._templates[template_name])
90
91 return self.merge_templates(*templates)
92
93 def __setitem__(self, key, value):
94 self._templates[key] = self._validate(value)

Callers

nothing calls this directly

Calls 4

merge_templatesMethod · 0.95
TemplateClass · 0.90
splitMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected