Mercurial > p > roundup > code
comparison scripts/schema_diagram.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 | 64b05e24dbd8 |
| children | 9c3ec0a5c7fc |
comparison
equal
deleted
inserted
replaced
| 5394:c26d88ec071e | 5395:23b8e6067f7c |
|---|---|
| 23 print('size="8,6"') | 23 print('size="8,6"') |
| 24 print('node [shape="record" bgcolor="#ffe4c4" style=filled]') | 24 print('node [shape="record" bgcolor="#ffe4c4" style=filled]') |
| 25 print('edge [taillabel="1" headlabel="1" dir=back arrowtail=ediamond]') | 25 print('edge [taillabel="1" headlabel="1" dir=back arrowtail=ediamond]') |
| 26 | 26 |
| 27 # get all the classes | 27 # get all the classes |
| 28 types = db.classes.keys() | 28 types = list(db.classes.keys()) |
| 29 | 29 |
| 30 # one record node per class | 30 # one record node per class |
| 31 for i in range(len(types)): | 31 for i in range(len(types)): |
| 32 print('node%d [label=\"{%s|}"]'%(i, types[i])) | 32 print('node%d [label=\"{%s|}"]'%(i, types[i])) |
| 33 | 33 |
