瀏覽代碼

Implement __iternodes__, __strip__, and __showtree__ for Argument.

tags/v0.1
Ben Kurtovic 12 年之前
父節點
當前提交
2e44343dbc
共有 1 個檔案被更改,包括 22 行新增0 行删除
  1. +22
    -0
      mwparserfromhell/nodes/argument.py

+ 22
- 0
mwparserfromhell/nodes/argument.py 查看文件

@@ -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…
取消
儲存