Skip to content

Commit

Permalink
wmltools: Use collections.defaultdict
Browse files Browse the repository at this point in the history
And minor nearby whitespace fixes.
  • Loading branch information
legoktm committed Jul 27, 2015
1 parent 3799f1e commit 6313209
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions data/tools/wesnoth/wmltools.py
Expand Up @@ -3,6 +3,7 @@
"""

import collections
import sys, os, re, sre_constants, hashlib, glob, gzip
import string

Expand Down Expand Up @@ -378,16 +379,17 @@ def __init__(self, namespace, filename, lineno=None, docstring=None, args=None):
self.lineno = lineno
self.docstring = docstring
self.args = args
self.references = {}
self.references = collections.defaultdict(list)
self.undef = None

def append(self, fn, n, a=None):
if fn not in self.references:
self.references[fn] = []
self.references[fn].append((n, a))

def dump_references(self):
"Dump all known references to this definition."
for (file, refs) in self.references.items():
print " %s: %s" % (file, repr([x[0] for x in refs])[1:-1])

def __cmp__(self, other):
"Compare two documentation objects for place in the sort order."
# Major sort by file, minor by line number. This presumes that the
Expand Down

0 comments on commit 6313209

Please sign in to comment.