/usr/lib/python3/dist-packages/defcon/objects/groups.py is in python3-defcon 0.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | from __future__ import absolute_import
import weakref
from defcon.objects.base import BaseDictObject
class Groups(BaseDictObject):
"""
This object contains all of the groups in a font.
**This object posts the following notifications:**
===================
Name
===================
Groups.Changed
Groups.BeginUndo
Groups.EndUndo
Groups.BeginRedo
Groups.EndRedo
Groups.GroupSet
Groups.GroupDeleted
Groups.Cleared
Groups.Updated
===================
This object behaves like a dict. The keys are group names and the
values are lists of glyph names::
{
"myGroup" : ["a", "b"],
"myOtherGroup" : ["a.alt", "g.alt"],
}
The API for interacting with the data is the same as a standard dict.
For example, to get a list of all group names::
groupNames = groups.keys()
To get all groups including the glyph lists::
for groupName, glyphList in groups.items():
To get the glyph list for a particular group name::
glyphList = groups["myGroup"]
To set the glyph list for a particular group name::
groups["myGroup"] = ["x", "y", "z"]
And so on.
**Note:** You should not modify the group list and expect the object to
know about it. For example, this could cause your changes to be lost::
glyphList = groups["myGroups"]
glyphList.append("n")
To make sure the change is noticed, reset the list into the object::
glyphList = groups["myGroups"]
glyphList.append("n")
groups["myGroups"] = glyphList
This may change in the future.
"""
changeNotificationName = "Groups.Changed"
beginUndoNotificationName = "Groups.BeginUndo"
endUndoNotificationName = "Groups.EndUndo"
beginRedoNotificationName = "Groups.BeginRedo"
endRedoNotificationName = "Groups.EndRedo"
setItemNotificationName = "Groups.GroupSet"
deleteItemNotificationName = "Groups.GroupDeleted"
clearNotificationName = "Groups.Cleared"
updateNotificationName = "Groups.Updated"
representationFactories = {}
def __init__(self, font=None):
self._font = None
if font is not None:
self._font = weakref.ref(font)
super(Groups, self).__init__()
self.beginSelfNotificationObservation()
# --------------
# Parent Objects
# --------------
def getParent(self):
return self.font
def _get_font(self):
if self._font is not None:
return self._font()
return None
font = property(_get_font, doc="The :class:`Font` that this object belongs to.")
# ------------------------
# Notification Observation
# ------------------------
def endSelfNotificationObservation(self):
super(Groups, self).endSelfNotificationObservation()
self._font = None
if __name__ == "__main__":
import doctest
doctest.testmod()
|