@@ -42,7 +42,7 @@ class ItemTree(future.utils.with_metaclass(abc.ABCMeta, object)):
42
42
43
43
* `VectorTree` for vectors (paths).
44
44
45
- Each item in the tree is an `_Item ` instance. Each item contains `gimp.Item`
45
+ Each item in the tree is an `Item ` instance. Each item contains `gimp.Item`
46
46
attributes and additional derived attributes.
47
47
48
48
Items can be directly accessed via their ID or name. Both ID and name are
@@ -62,7 +62,7 @@ class ItemTree(future.utils.with_metaclass(abc.ABCMeta, object)):
62
62
63
63
* `name` (read-only) - Optional name of the item tree. The name is currently
64
64
used as an identifier of the persistent source for tags in items. See
65
- `_Item .tags` for more information.
65
+ `Item .tags` for more information.
66
66
67
67
* `is_filtered` - If `True`, ignore items that do not match the filter
68
68
(`ObjectFilter`) in this object when iterating.
@@ -86,14 +86,14 @@ def __init__(
86
86
self .filter = pgobjectfilter .ObjectFilter (self ._filter_match_type )
87
87
88
88
# Contains all items in the item tree (including item groups).
89
- # key: `_Item .raw.ID` or (`_Item .raw.ID`, `FOLDER_KEY`) in case of folders
90
- # value: `_Item ` instance
89
+ # key: `Item .raw.ID` or (`Item .raw.ID`, `FOLDER_KEY`) in case of folders
90
+ # value: `Item ` instance
91
91
self ._itemtree = collections .OrderedDict ()
92
92
93
93
# key:
94
- # `_Item .orig_name` (derived from `_Item .raw.name`)
95
- # or (`_Item .raw.ID`, `FOLDER_KEY`) in case of folders
96
- # value: `_Item ` instance
94
+ # `Item .orig_name` (derived from `Item .raw.name`)
95
+ # or (`Item .raw.ID`, `FOLDER_KEY`) in case of folders
96
+ # value: `Item ` instance
97
97
self ._itemtree_names = {}
98
98
99
99
self ._build_tree ()
@@ -107,10 +107,10 @@ def name(self):
107
107
return self ._name
108
108
109
109
def __getitem__ (self , id_or_name ):
110
- """Returns an `_Item ` object by its ID or original name.
110
+ """Returns an `Item ` object by its ID or original name.
111
111
112
- An item's ID is the `_Item .raw.ID` attribute. An item's original name is the
113
- `_Item .orig_name` attribute.
112
+ An item's ID is the `Item .raw.ID` attribute. An item's original name is the
113
+ `Item .orig_name` attribute.
114
114
115
115
To access an item group as a folder, pass a tuple `(ID or name, 'folder')`.
116
116
For example:
@@ -123,9 +123,9 @@ def __getitem__(self, id_or_name):
123
123
return self ._itemtree_names [id_or_name ]
124
124
125
125
def __contains__ (self , id_or_name ):
126
- """Returns `True` if an `_Item ` object is in the item tree, regardless of
127
- filters. Return `False` otherwise. The `_Item ` object is specified by its
128
- `_Item .raw.ID` attribute or its `orig_name` attribute.
126
+ """Returns `True` if an `Item ` object is in the item tree, regardless of
127
+ filters. Return `False` otherwise. The `Item ` object is specified by its
128
+ `Item .raw.ID` attribute or its `orig_name` attribute.
129
129
"""
130
130
return id_or_name in self ._itemtree or id_or_name in self ._itemtree_names
131
131
@@ -148,7 +148,7 @@ def __iter__(self):
148
148
149
149
Yields:
150
150
151
- * `item` - The current `_Item ` object.
151
+ * `item` - The current `Item ` object.
152
152
"""
153
153
return self .iter (with_folders = False , with_empty_groups = False )
154
154
@@ -169,7 +169,7 @@ def iter(self, with_folders=True, with_empty_groups=False, filtered=True):
169
169
170
170
Yields:
171
171
172
- * `item` - The current `_Item ` object.
172
+ * `item` - The current `Item ` object.
173
173
"""
174
174
for item in self ._itemtree .values ():
175
175
should_yield_item = True
@@ -196,7 +196,7 @@ def iter_all(self):
196
196
197
197
Yields:
198
198
199
- * `item` - The current `_Item ` object.
199
+ * `item` - The current `Item ` object.
200
200
"""
201
201
for item in self ._itemtree .values ():
202
202
yield item
@@ -258,10 +258,10 @@ def _build_tree(self):
258
258
child_items = []
259
259
for raw_item in self ._get_children_from_image (self ._image ):
260
260
if self ._is_group (raw_item ):
261
- child_items .append (_Item (raw_item , TYPE_FOLDER , [], [], None , None , self ._name ))
262
- child_items .append (_Item (raw_item , TYPE_GROUP , [], [], None , None , self ._name ))
261
+ child_items .append (Item (raw_item , TYPE_FOLDER , [], [], None , None , self ._name ))
262
+ child_items .append (Item (raw_item , TYPE_GROUP , [], [], None , None , self ._name ))
263
263
else :
264
- child_items .append (_Item (raw_item , TYPE_ITEM , [], [], None , None , self ._name ))
264
+ child_items .append (Item (raw_item , TYPE_ITEM , [], [], None , None , self ._name ))
265
265
266
266
item_tree = child_items
267
267
item_list = []
@@ -281,14 +281,14 @@ def _build_tree(self):
281
281
for raw_item in self ._get_children_from_raw_item (item .raw ):
282
282
if self ._is_group (raw_item ):
283
283
child_items .append (
284
- _Item (raw_item , TYPE_FOLDER , parents_for_child , [], None , None , self ._name ))
284
+ Item (raw_item , TYPE_FOLDER , parents_for_child , [], None , None , self ._name ))
285
285
child_items .append (
286
- _Item (raw_item , TYPE_GROUP , parents_for_child , [], None , None , self ._name ))
286
+ Item (raw_item , TYPE_GROUP , parents_for_child , [], None , None , self ._name ))
287
287
else :
288
288
child_items .append (
289
- _Item (raw_item , TYPE_ITEM , parents_for_child , [], None , None , self ._name ))
289
+ Item (raw_item , TYPE_ITEM , parents_for_child , [], None , None , self ._name ))
290
290
291
- # We break the convention here and access a private attribute from `_Item `.
291
+ # We break the convention here and access a private attribute from `Item `.
292
292
item ._orig_children = child_items
293
293
item .children = child_items
294
294
@@ -299,7 +299,7 @@ def _build_tree(self):
299
299
self ._itemtree_names [item .orig_name ] = item
300
300
301
301
for i in range (1 , len (item_list ) - 1 ):
302
- # We break the convention here and access private attributes from `_Item `.
302
+ # We break the convention here and access private attributes from `Item `.
303
303
item_list [i ]._prev_item = item_list [i - 1 ]
304
304
item_list [i ]._next_item = item_list [i + 1 ]
305
305
@@ -351,7 +351,7 @@ def _get_children_from_image(self, image):
351
351
352
352
353
353
@future .utils .python_2_unicode_compatible
354
- class _Item (object ):
354
+ class Item (object ):
355
355
"""Wrapper for a `gimp.Item` object containing additional attributes.
356
356
357
357
Note that the attributes will not be up to date if changes were made to the
@@ -364,29 +364,29 @@ class _Item(object):
364
364
* `type` (read-only) - Item type - one of the following:
365
365
* `TYPE_ITEM` - regular item
366
366
* `TYPE_GROUP` - item group (item whose raw `gimp.Item` is a group with
367
- children; this `_Item ` has no children and acts as a regular item)
367
+ children; this `Item ` has no children and acts as a regular item)
368
368
* `TYPE_FOLDER` - item containing children (raw item is a group with
369
369
children)
370
370
371
- * `parents` - List of `_Item ` parents for this item, sorted from the topmost
371
+ * `parents` - List of `Item ` parents for this item, sorted from the topmost
372
372
parent to the bottommost (immediate) parent.
373
373
374
- * `children` - List of `_Item ` children for this item.
374
+ * `children` - List of `Item ` children for this item.
375
375
376
376
* `depth` (read-only) - Integer indicating the depth of the item in the item
377
377
tree. 0 means the item is at the top level. The greater the depth, the lower
378
378
the item is in the item tree.
379
379
380
- * `parent` (read-only) - Immediate `_Item ` parent of this object.
380
+ * `parent` (read-only) - Immediate `Item ` parent of this object.
381
381
If this object has no parent, return `None`.
382
382
383
383
* `name` - Item name as a string, initially equal to `orig_name`. Modify this
384
384
attribute instead of `gimp.Item.name` to avoid modifying the original item.
385
385
386
- * `prev` - Previous `_Item ` in the `ItemTree`, or `None` if there is no
386
+ * `prev` - Previous `Item ` in the `ItemTree`, or `None` if there is no
387
387
previous item.
388
388
389
- * `next` - Next `_Item ` in the `ItemTree`, or `None` if there is no next item.
389
+ * `next` - Next `Item ` in the `ItemTree`, or `None` if there is no next item.
390
390
391
391
* `tags` - Set of arbitrary strings attached to the item. Tags can be used for
392
392
a variety of purposes, such as special handling of items with specific tags.
@@ -395,7 +395,7 @@ class _Item(object):
395
395
`tags_source_name` attribute.
396
396
397
397
* `orig_name` (read-only) - Original `gimp.Item.name` as a string. This
398
- attribute may be used to access `_Item `s in `ItemTree`.
398
+ attribute may be used to access `Item `s in `ItemTree`.
399
399
400
400
* `orig_parents` (read-only) - Initial `parents` of this item.
401
401
0 commit comments