MCPcopy Create free account
hub / github.com/scanny/python-pptx / Category

Class Category

src/pptx/chart/category.py:145–182  ·  view source on GitHub ↗

An extension of `str` that provides the category label as its string value, and additional attributes representing other aspects of the category.

Source from the content-addressed store, hash-verified

143
144
145class Category(str):
146 """
147 An extension of `str` that provides the category label as its string
148 value, and additional attributes representing other aspects of the
149 category.
150 """
151
152 def __new__(cls, pt, *args):
153 category_label = "" if pt is None else pt.v.text
154 return str.__new__(cls, category_label)
155
156 def __init__(self, pt, idx=None):
157 """
158 *idx* is a required attribute of a c:pt element, but must be
159 specified when pt is None, as when a "placeholder" category is
160 created to represent a missing c:pt element.
161 """
162 self._element = self._pt = pt
163 self._idx = idx
164
165 @property
166 def idx(self):
167 """
168 Return an integer representing the index reference of this category.
169 For a leaf node, the index identifies the category. For a parent (or
170 other ancestor) category, the index specifies the first leaf category
171 that ancestor encloses.
172 """
173 if self._pt is None:
174 return self._idx
175 return self._pt.idx
176
177 @property
178 def label(self):
179 """
180 Return the label of this category as a string.
181 """
182 return str(self)
183
184
185class CategoryLevel(Sequence):

Callers 6

base_class_fixtureMethod · 0.90
idx_fixtureMethod · 0.90
label_fixtureMethod · 0.90
__getitem__Method · 0.70
__iter__Method · 0.70
__getitem__Method · 0.70

Calls

no outgoing calls

Tested by 3

base_class_fixtureMethod · 0.72
idx_fixtureMethod · 0.72
label_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…