|
8 | 8 | import json
|
9 | 9 | from functools import reduce
|
10 | 10 |
|
| 11 | +from six import string_types |
| 12 | + |
11 | 13 | try:
|
12 | 14 | from math import gcd
|
13 | 15 | except ImportError:
|
@@ -61,24 +63,34 @@ def __iter__(self):
|
61 | 63 | return iter(self._templates)
|
62 | 64 |
|
63 | 65 | def __getitem__(self, item):
|
64 |
| - template = self._templates[item] |
65 |
| - if template is Lazy: |
66 |
| - from plotly.graph_objs.layout import Template |
67 |
| - |
68 |
| - if item == "none": |
69 |
| - # "none" is a special built-in named template that applied no defaults |
70 |
| - template = Template() |
71 |
| - self._templates[item] = template |
72 |
| - else: |
73 |
| - # Load template from package data |
74 |
| - path = os.path.join("package_data", "templates", item + ".json") |
75 |
| - template_str = pkgutil.get_data("plotly", path).decode("utf-8") |
76 |
| - template_dict = json.loads(template_str) |
77 |
| - template = Template(template_dict) |
78 |
| - |
79 |
| - self._templates[item] = template |
80 |
| - |
81 |
| - return template |
| 66 | + if isinstance(item, string_types): |
| 67 | + template_names = item.split("+") |
| 68 | + else: |
| 69 | + template_names = [item] |
| 70 | + |
| 71 | + templates = [] |
| 72 | + for template_name in template_names: |
| 73 | + template = self._templates[template_name] |
| 74 | + if template is Lazy: |
| 75 | + from plotly.graph_objs.layout import Template |
| 76 | + |
| 77 | + if template_name == "none": |
| 78 | + # "none" is a special built-in named template that applied no defaults |
| 79 | + template = Template() |
| 80 | + self._templates[template_name] = template |
| 81 | + else: |
| 82 | + # Load template from package data |
| 83 | + path = os.path.join( |
| 84 | + "package_data", "templates", template_name + ".json" |
| 85 | + ) |
| 86 | + template_str = pkgutil.get_data("plotly", path).decode("utf-8") |
| 87 | + template_dict = json.loads(template_str) |
| 88 | + template = Template(template_dict) |
| 89 | + |
| 90 | + self._templates[template_name] = template |
| 91 | + templates.append(self._templates[template_name]) |
| 92 | + |
| 93 | + return self.merge_templates(*templates) |
82 | 94 |
|
83 | 95 | def __setitem__(self, key, value):
|
84 | 96 | self._templates[key] = self._validate(value)
|
|
0 commit comments