summaryrefslogtreecommitdiff
path: root/misc/pylib/extractor/tools.py
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2017-11-29 04:11:48 +0300
committerRasmus Andersson <rasmus@notion.se>2017-11-29 04:11:48 +0300
commit1f684610cd33f3ca6aef0891bcd597669130b683 (patch)
tree17955cb034022e29293084eb02867d97c2114d41 /misc/pylib/extractor/tools.py
parent12076e07b1daaef1653593e3c6dcc9e6baeee589 (diff)
downloadinter-1f684610cd33f3ca6aef0891bcd597669130b683.tar.xz
Adds script for verifying font files
Diffstat (limited to 'misc/pylib/extractor/tools.py')
-rwxr-xr-xmisc/pylib/extractor/tools.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/misc/pylib/extractor/tools.py b/misc/pylib/extractor/tools.py
new file mode 100755
index 000000000..f0750d7c3
--- /dev/null
+++ b/misc/pylib/extractor/tools.py
@@ -0,0 +1,32 @@
+from ufoLib import fontInfoAttributesVersion3, validateFontInfoVersion3ValueForAttribute
+
+
+class RelaxedInfo(object):
+
+ """
+ This object that sets only valid info values
+ into the given info object.
+ """
+
+ def __init__(self, info):
+ self._object = info
+
+ def __getattr__(self, attr):
+ if attr in fontInfoAttributesVersion3:
+ return getattr(self._object, attr)
+ else:
+ return super(RelaxedInfo, self).__getattr__(attr)
+
+ def __setattr__(self, attr, value):
+ if attr in fontInfoAttributesVersion3:
+ if validateFontInfoVersion3ValueForAttribute(attr, value):
+ setattr(self._object, attr, value)
+ else:
+ super(RelaxedInfo, self).__setattr__(attr, value)
+
+
+def copyAttr(src, srcAttr, dest, destAttr):
+ if not hasattr(src, srcAttr):
+ return
+ value = getattr(src, srcAttr)
+ setattr(dest, destAttr, value)