Write dictionary as a JavaScript object with the given name. If printValues is False, just output keys with undefined values.
(self, dict, name, printValues = True)
| 31 | return '}' |
| 32 | |
| 33 | def writeDict(self, dict, name, printValues = True): |
| 34 | """Write dictionary as a JavaScript object with the given name. |
| 35 | If printValues is False, just output keys with undefined |
| 36 | values.""" |
| 37 | |
| 38 | write(self.beginDict(name), file=self.outFile) |
| 39 | for key in sorted(dict): |
| 40 | if printValues: |
| 41 | value = undefquote(dict[key]) |
| 42 | else: |
| 43 | value = 'undefined' |
| 44 | write(f'{enquote(key)} : {value},', file=self.outFile) |
| 45 | write(self.endDict(), file=self.outFile) |
| 46 | |
| 47 | def writeList(self, l, name): |
| 48 | """Write list l as a JavaScript hash with the given name""" |