comparison roundup/cgi/form_parser.py @ 5395:23b8e6067f7c

Python 3 preparation: update calls to dict methods. Tool-assisted patch. Changes of iterkeys / itervalues / iteritems to keys / values / items are fully automated, but may make things less efficient in Python 2. Automated tools want to add list() around many calls to keys / values / items, but I thought most such list() additions were unnecessary because it seemed the result of keys / values / items was just iterated over while the set of dict keys remained unchanged, rather than used in a way requiring an actual list, or used while the set of keys in the dict could change. It's quite possible I missed some cases where list() was really needed, or left in some unnecessary list() calls. In cases where list() was only needed because the resulting list was then sorted in-place, I changed the code to use calls to sorted().
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 23:04:42 +0000
parents 0942fe89e82e
children 99667a0cbd2d
comparison
equal deleted inserted replaced
5394:c26d88ec071e 5395:23b8e6067f7c
587 587
588 # When creating a FileClass node, it should have a non-empty content 588 # When creating a FileClass node, it should have a non-empty content
589 # property to be created. When editing a FileClass node, it should 589 # property to be created. When editing a FileClass node, it should
590 # either have a non-empty content property or no property at all. In 590 # either have a non-empty content property or no property at all. In
591 # the latter case, nothing will change. 591 # the latter case, nothing will change.
592 for (cn, id), props in all_props.items(): 592 for (cn, id), props in list(all_props.items()):
593 if id is not None and id.startswith('-') and not props: 593 if id is not None and id.startswith('-') and not props:
594 # new item (any class) with no content - ignore 594 # new item (any class) with no content - ignore
595 del all_props[(cn, id)] 595 del all_props[(cn, id)]
596 elif isinstance(self.db.classes[cn], hyperdb.FileClass): 596 elif isinstance(self.db.classes[cn], hyperdb.FileClass):
597 # three cases: 597 # three cases:

Roundup Issue Tracker: http://roundup-tracker.org/