forked from Imagelibrary/littlefs
scripts: Adopted dat tweak in other scripts
This just makes dat behave similarly to Python's getattr, etc:
- dat("bogus") -> raises ValueError
- dat("bogus", 1234) -> returns 1234
This replaces try_dat, which is easy to forget about when copy-pasting
between scripts.
Though all of this wouldn't be necessary if only we could catch
exceptions in expressions...
This commit is contained in:
@@ -1296,11 +1296,11 @@ def punescape(s, attrs=None):
|
||||
f = m.group('format')
|
||||
if f[-1] in 'dboxX':
|
||||
if isinstance(v, str):
|
||||
v = try_dat(v) or 0
|
||||
v = dat(v, 0)
|
||||
v = int(v)
|
||||
elif f[-1] in 'fFeEgG':
|
||||
if isinstance(v, str):
|
||||
v = try_dat(v) or 0
|
||||
v = dat(v, 0)
|
||||
v = float(v)
|
||||
else:
|
||||
f = ('<' if '-' in f else '>') + f.replace('-', '')
|
||||
|
||||
Reference in New Issue
Block a user