Mercurial > p > roundup > code
comparison roundup/cgi/TAL/TALGenerator.py @ 5381:0942fe89e82e
Python 3 preparation: change "x.has_key(y)" to "y in x".
(Also likewise "not in" where appropriate.) Tool-generated patch.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 22:08:17 +0000 |
| parents | 12fe83f90f0d |
| children | 1556b39fde7c |
comparison
equal
deleted
inserted
replaced
| 5380:64c4e43fbb84 | 5381:0942fe89e82e |
|---|---|
| 367 self.emit('insertTranslation', msgid, program, cexpr) | 367 self.emit('insertTranslation', msgid, program, cexpr) |
| 368 | 368 |
| 369 def emitDefineMacro(self, macroName): | 369 def emitDefineMacro(self, macroName): |
| 370 program = self.popProgram() | 370 program = self.popProgram() |
| 371 macroName = macroName.strip() | 371 macroName = macroName.strip() |
| 372 if self.macros.has_key(macroName): | 372 if macroName in self.macros: |
| 373 raise METALError("duplicate macro definition: %s" % repr(macroName), | 373 raise METALError("duplicate macro definition: %s" % repr(macroName), |
| 374 self.position) | 374 self.position) |
| 375 if not re.match('%s$' % NAME_RE, macroName): | 375 if not re.match('%s$' % NAME_RE, macroName): |
| 376 raise METALError("invalid macro name: %s" % repr(macroName), | 376 raise METALError("invalid macro name: %s" % repr(macroName), |
| 377 self.position) | 377 self.position) |
| 394 self.emit("defineSlot", slotName, program) | 394 self.emit("defineSlot", slotName, program) |
| 395 | 395 |
| 396 def emitFillSlot(self, slotName): | 396 def emitFillSlot(self, slotName): |
| 397 program = self.popProgram() | 397 program = self.popProgram() |
| 398 slotName = slotName.strip() | 398 slotName = slotName.strip() |
| 399 if self.slots.has_key(slotName): | 399 if slotName in self.slots: |
| 400 raise METALError("duplicate fill-slot name: %s" % repr(slotName), | 400 raise METALError("duplicate fill-slot name: %s" % repr(slotName), |
| 401 self.position) | 401 self.position) |
| 402 if not re.match('%s$' % NAME_RE, slotName): | 402 if not re.match('%s$' % NAME_RE, slotName): |
| 403 raise METALError("invalid slot name: %s" % repr(slotName), | 403 raise METALError("invalid slot name: %s" % repr(slotName), |
| 404 self.position) | 404 self.position) |
| 462 if not repldict: | 462 if not repldict: |
| 463 return attrlist | 463 return attrlist |
| 464 newlist = [] | 464 newlist = [] |
| 465 for item in attrlist: | 465 for item in attrlist: |
| 466 key = item[0] | 466 key = item[0] |
| 467 if repldict.has_key(key): | 467 if key in repldict: |
| 468 expr, xlat, msgid = repldict[key] | 468 expr, xlat, msgid = repldict[key] |
| 469 item = item[:2] + ("replace", expr, xlat, msgid) | 469 item = item[:2] + ("replace", expr, xlat, msgid) |
| 470 del repldict[key] | 470 del repldict[key] |
| 471 newlist.append(item) | 471 newlist.append(item) |
| 472 # Add dynamic-only attributes | 472 # Add dynamic-only attributes |
| 683 " and have a msgid in i18n:attributes") % key, | 683 " and have a msgid in i18n:attributes") % key, |
| 684 position) | 684 position) |
| 685 ce = self.compileExpression(value) | 685 ce = self.compileExpression(value) |
| 686 repldict[key] = ce, key in i18nattrs, i18nattrs.get(key) | 686 repldict[key] = ce, key in i18nattrs, i18nattrs.get(key) |
| 687 for key in i18nattrs: | 687 for key in i18nattrs: |
| 688 if not repldict.has_key(key): | 688 if key not in repldict: |
| 689 repldict[key] = None, 1, i18nattrs.get(key) | 689 repldict[key] = None, 1, i18nattrs.get(key) |
| 690 else: | 690 else: |
| 691 repldict = {} | 691 repldict = {} |
| 692 if replace: | 692 if replace: |
| 693 todo["repldict"] = repldict | 693 todo["repldict"] = repldict |
