Lib¶
Overview¶
Copy this object into a new object of the same type. |
|
The lib's parent glyph. |
|
The lib's parent font. |
|
Returns the number of keys in Lib as an |
|
Returns a |
|
Returns a list of |
|
Returns a |
|
Tests to see if a lib name is in the Lib. key will be a String. This returns a |
|
Sets the key to the list of items. |
|
Returns the contents of the named lib. key is a String. The returned value will be a |
|
Returns the contents of the named key. key is a String, and the returned values will either be |
|
Removes key from the Lib. key is a String.::. |
|
Removes the key from the Lib and returns the |
|
Iterates through the Lib, giving the key for each iteration. The order that the Lib will iterate though is not fixed nor is it ordered.::. |
|
Updates the Lib based on otherLib. |
|
Removes all keys from Lib, resetting the Lib to an empty dictionary. ::. |
|
Return the environment's native object that has been wrapped by this object. |
|
Tell the environment that something has changed in the object. |
Reference¶
- class fontParts.base.BaseLib(*args, **kwargs)[source]¶
A Lib object. This object normally created as part of a
BaseFont. An orphan Lib object can be created like this:>>> lib = RLib()
This object behaves like a Python dictionary. Most of the dictionary functionality comes from
BaseDict, look at that object for the required environment implementation details.Lib uses
normalizers.normalizeLibKeyto normalize the key of thedict, andnormalizers.normalizeLibValueto normalize the value of thedict.
Copy¶
- BaseLib.copy()¶
Copy this object into a new object of the same type. The returned object will not have a parent object.
Parents¶
- BaseLib.glyph¶
The lib’s parent glyph.
- BaseLib.font¶
The lib’s parent font.
Dictionary¶
- BaseLib.keys()[source]¶
Returns a
listof all the key names in Lib. This list will be unordered.:>>> font.lib.keys() ["public.glyphOrder", "org.robofab.scripts.SomeData", "public.postscriptNames"]
- BaseLib.items()[source]¶
Returns a list of
tupleof each key name and key items. Keys are String and key members are alistof String. The initial list will be unordered.>>> font.lib.items() [("public.glyphOrder", ["A", "B", "C"]), ("public.postscriptNames", {'be': 'uni0431', 'ze': 'uni0437'})]
- BaseLib.values()[source]¶
Returns a
listof each named key’s members. This will be a list of lists, the key members will be alistof String. The initial list will be unordered.>>> font.lib.items() [["A", "B", "C"], {'be': 'uni0431', 'ze': 'uni0437'}]
- BaseLib.__contains__(key)[source]¶
Tests to see if a lib name is in the Lib. key will be a String. This returns a
boolindicating if the key is in the Lib.>>> "public.glyphOrder" in font.lib True
- BaseLib.__setitem__(key, items)[source]¶
Sets the key to the list of items. key is the lib name as a String and items is a
listof items as String.>>> font.lib["public.glyphOrder"] = ["A", "B", "C"]
- BaseLib.__getitem__(key)[source]¶
Returns the contents of the named lib. key is a String. The returned value will be a
listof the lib contents.:>>> font.lib["public.glyphOrder"] ["A", "B", "C"]
It is important to understand that any changes to the returned lib contents will not be reflected in the Lib object. If one wants to make a change to the lib contents, one should do the following:
>>> lib = font.lib["public.glyphOrder"] >>> lib.remove("A") >>> font.lib["public.glyphOrder"] = lib
- BaseLib.get(key, default=None)[source]¶
Returns the contents of the named key. key is a String, and the returned values will either be
listof key contents orNoneif no key was found.>>> font.lib["public.glyphOrder"] ["A", "B", "C"]
It is important to understand that any changes to the returned key contents will not be reflected in the Lib object. If one wants to make a change to the key contents, one should do the following:
>>> lib = font.lib["public.glyphOrder"] >>> lib.remove("A") >>> font.lib["public.glyphOrder"] = lib
- BaseLib.__delitem__(key)[source]¶
Removes key from the Lib. key is a String.:
>>> del font.lib["public.glyphOrder"]
- BaseLib.pop(key, default=None)[source]¶
Removes the key from the Lib and returns the
listof key members. If no key is found, default is returned. key is a String. This must return either default or alistof items as String.>>> font.lib.pop("public.glyphOrder") ["A", "B", "C"]
- BaseLib.__iter__()[source]¶
Iterates through the Lib, giving the key for each iteration. The order that the Lib will iterate though is not fixed nor is it ordered.:
>>> for key in font.lib: >>> print key "public.glyphOrder" "org.robofab.scripts.SomeData" "public.postscriptNames"
- BaseLib.update(otherLib)[source]¶
Updates the Lib based on otherLib. otherLib* is a
dictof keys. If a key from otherLib is in Lib the key members will be replaced by the key members from otherLib. If a key from otherLib is not in the Lib, it is added to the Lib. If Lib contain a key name that is not in otherLib*, it is not changed.>>> font.lib.update(newLib)
Environment¶
- BaseLib.naked()¶
Return the environment’s native object that has been wrapped by this object.
>>> loweLevelObj = obj.naked()
- BaseLib.changed(*args, **kwargs)¶
Tell the environment that something has changed in the object. The behavior of this method will vary from environment to environment.
>>> obj.changed()