Lines Matching +full:xml +full:- +full:name +full:- +full:validator
2 glifLib.py -- Generic module for reading and writing the .glif format.
54 # ---------
56 # ---------
88 # ------------
90 # ------------
119 # ---------
121 # ---------
154 function that takes two arguments: a glyph name and a list of all
155 existing filenames (if any exist). It should return a file name
157 is called whenever a file name is created for a given glyph name.
197 # network or in-memory FS may not map to the local one
202 self.dirName = fs.path.parts(path)[-1]
237 for name, fileName in contents.items():
238 if not isinstance(name, str):
256 glyph names. This is primarily an aid for custom glyph name to file
257 name schemes that want to make sure they don't generate duplicate
260 important for case-insensitive file systems.
338 Get the raw GLIF text for a given glyph name. This only works
341 This method is useful in situations when the raw XML needs to be
400 (for example if the 'glyphObject' attribute is read-
430 # Re-raise with a note that gives extra context, describing where
436 # Network or in-memory FS may not map to a local path, so use
558 # dict-like support
596 base glyph name of components in the glyph. This parses the .glif
610 Return a dictionary that maps glyph names to the file name of the image
634 # -----------------------
635 # Glyph Name to File Name
636 # -----------------------
651 # -----------------------
653 # -----------------------
693 (for example if the 'glyphObject' attribute is read-
748 """Return .glif data for a glyph as a UTF-8 encoded bytes string."""
759 raise GlifLibError("The glyph name is not properly formatted.")
761 raise GlifLibError("The glyph name is empty.")
763 [("name", glyphName), ("format", repr(formatVersion.major))]
794 # prevent lxml from writing self-closing tags
802 root, encoding="UTF-8", xml_declaration=True, pretty_print=True
815 Return .glif data for a glyph as a string. The XML declaration's
816 encoding is always set to "UTF-8".
865 return data.decode("utf-8")
921 "image attribute must be a dict or dict-like object with the proper structure."
949 name = guideline.get("name")
950 if name is not None:
951 attrs["name"] = name
973 name = anchor.get("name")
974 if name is not None:
975 attrs["name"] = name
977 pen.addPoint((x, y), segmentType="move", name=name)
991 name = anchor.get("name")
992 if name is not None:
993 attrs["name"] = name
1022 # -----------------------
1024 # -----------------------
1046 validator = dataValidationDict.get("valueValidator")
1048 # have specific options for the validator
1050 isValidValue = validator(value, valueOptions)
1053 if validator == genericTypeValidator:
1054 isValidValue = validator(value, valueType)
1056 isValidValue = validator(value)
1079 # -----------------
1081 # -----------------
1098 data = tobytes(aString, encoding="utf-8")
1105 raise GlifLibError("GLIF contains invalid XML.") from etree_exception
1168 # get the name
1223 # get the name
1324 glyphName = root.get("name")
1326 raise GlifLibError("Empty glyph name in GLIF.")
1328 _relaxedSetattr(glyphObject, "name", glyphName)
1365 # ----------------
1367 # ----------------
1380 pointAttributesFormat1 = {"x", "y", "type", "smooth", "name"}
1415 name = point.get("name")
1416 if name is None:
1426 anchor = dict(x=x, y=y, name=name)
1451 name = point["name"]
1452 pen.addPoint((x, y), segmentType=segmentType, smooth=smooth, name=name)
1528 name = point["name"]
1544 name=name,
1548 pen.addPoint((x, y), segmentType=segmentType, smooth=smooth, name=name)
1656 # name is optional
1657 if "name" not in element.attrib:
1658 point["name"] = None
1670 massaged = massaged[:-count]
1671 # validate the off-curves in the segments
1675 offCurvesCount = len(massaged) - 1 - lastOnCurvePoint
1682 # move and line can't be preceded by off-curves
1700 # ---------------------
1702 # ---------------------
1739 # --------------------
1741 # --------------------
1755 from xml.parsers.expat import ParserCreate
1762 def startElementHandler(self, name, attrs): argument
1763 self._elementStack.append(name)
1765 def endElementHandler(self, name): argument
1766 other = self._elementStack.pop(-1)
1767 assert other == name
1787 def startElementHandler(self, name, attrs): argument
1789 name == "unicode"
1791 and self._elementStack[-1] == "glyph"
1801 super().startElementHandler(name, attrs)
1809 The image file name (if any) from glif.
1824 def startElementHandler(self, name, attrs): argument
1825 if name == "image" and self._elementStack and self._elementStack[-1] == "glyph":
1828 super().startElementHandler(name, attrs)
1851 def startElementHandler(self, name, attrs): argument
1853 name == "component"
1855 and self._elementStack[-1] == "outline"
1860 super().startElementHandler(name, attrs)
1862 def endElementHandler(self, name): argument
1863 if name == "outline":
1865 super().endElementHandler(name)
1868 # --------------
1870 # --------------
1873 # field name, default value
1919 if self.validate and self.prevPointTypes[-1] == "offcurve":
1921 # prevent lxml from writing self-closing tags
1930 self, pt, segmentType=None, smooth=None, name=None, identifier=None, **kwargs argument
1952 and self.prevPointTypes[-1] == "offcurve"
1971 # name
1972 if name is not None:
1973 attrs["name"] = name