Browse Source

Implement __iternodes__, __strip__, and __showtree__ for Argument.

tags/v0.1
Ben Kurtovic 12 years ago
parent
commit
2e44343dbc
1 changed files with 22 additions and 0 deletions
  1. +22
    -0
      mwparserfromhell/nodes/argument.py

+ 22
- 0
mwparserfromhell/nodes/argument.py View File

@@ -41,6 +41,28 @@ class Argument(Node):
return start + "|" + unicode(self.default) + "}}}"
return start + "}}}"

def __iternodes__(self, getter):
yield None, self
for child in getter(self.name):
yield self.name, child
if self.default is not None:
for child in getter(self.default):
yield self.default, child

def __strip__(self, normalize, collapse):
if self.default is not None:
return self.default.strip_code(normalize, collapse)
return None

def __showtree__(self, write, get, mark):
write("{{{")
get(self.name)
if self.default is not None:
write(" | ")
mark()
get(self.default)
write("}}}")

@property
def name(self):
"""The name of the argument to substitute."""


Loading…
Cancel
Save