Hi,
I’m on Glyphs 3.0.5 (3117), and I’m getting an unexpected result when calling Glyphs.boolDefaults
.
When the default I am calling for is “truthy”, boolDefaults
returns False
.
boolDefaults
only returns True
if the default is literally True
, not just “truthy” as is expected.
Try the code below in the macro window.
Glyphs.clearLog()
# Should be False if it doesn't exist/returns None
assert Glyphs.boolDefaults["com.foo.bar"] == False # Passes
# Should be True if it is set/is Truthy
Glyphs.defaults["com.foo.bar"] = "baz"
assert bool(Glyphs.defaults["com.foo.bar"]) == True # Passes
assert Glyphs.boolDefaults["com.foo.bar"] == True # Fails
# Only returns True if value is literally "True"
Glyphs.defaults["com.foo.bar"] = True
assert Glyphs.boolDefaults["com.foo.bar"] == True # Passes
Returns:
Traceback (most recent call last):
File "<macro panel>", line 8
AssertionError
As I understand it from the Python API documentation, it should return True
on anything that is “truthy”:
https://docu.glyphsapp.com/#GSApplication.boolDefaults