Sfoglia il codice sorgente

Implement __iternodes__, __strip__, and __showtree__ for Argument.

tags/v0.1
Ben Kurtovic 12 anni fa
parent
commit
2e44343dbc
1 ha cambiato i file con 22 aggiunte e 0 eliminazioni
  1. +22
    -0
      mwparserfromhell/nodes/argument.py

+ 22
- 0
mwparserfromhell/nodes/argument.py Vedi 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."""


Caricamento…
Annulla
Salva