Use transcrypt --sform to enable string formatting

The Python string formatting mini language isn't enabled by default.
"{}".format(42) works fine but "{0:x}.format(42)" returns "{0:x}"
instead of "2a" if the mini language isn't enabled.
This commit is contained in:
Carsten Grohmann 2020-11-20 21:51:33 +01:00
parent ad2bcfd551
commit 967d231be5
2 changed files with 2 additions and 3 deletions

View File

@ -62,7 +62,7 @@ venv-clean:
#+ Compile Python to JavaScript
build: venv
. $(VIRTUAL_ENV_DIR)/bin/activate
transcrypt --build --map --nomin -e 6 OOMAnalyser.py
transcrypt --build --map --nomin --sform -e 6 OOMAnalyser.py
rollup --format=umd --name OOMAnalyser --file=OOMAnalyser.js -- __target__/OOMAnalyser.js
#+ Serve the current directory on http://127.0.0.1:8080

View File

@ -651,8 +651,7 @@ class OOMAnalyser(object):
else:
flags, unknown = self._hex2flags(self.results['trigger_proc_gfp_mask'], self.kernel_cfg.GFP_FLAGS)
if unknown:
# TODO Missing format specifier {0:x} in Transcrypt?
flags.append('0x{}'.format(unknown.toString(16)))
flags.append('0x{0:x}'.format(unknown))
flags = ' | '.join(flags)
self.results['trigger_proc_gfp_mask'] = '{} ({})'.format(self.results['trigger_proc_gfp_mask'], flags)