本文整理汇总了Python中fit.Parse.Parse类的典型用法代码示例。如果您正苦于以下问题:Python Parse类的具体用法?Python Parse怎么用?Python Parse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shouldBeAbleToColorExceptionAsWrong
def shouldBeAbleToColorExceptionAsWrong(self):
fix = Fixture()
cell = Parse(tag="td", body="Oops.")
fix.exception(cell, "What the heck?", color="wrong")
assert cell.body.find("What the heck?") > -1
assert cell.tagIsWrong()
assert fix.counts.wrong == 1
示例2: shouldHandleStringAsExceptionParameter
def shouldHandleStringAsExceptionParameter(self):
fix = Fixture()
cell = Parse(tag="td", body="Oops.")
fix.exception(cell, "What the heck?")
assert cell.body.find("What the heck?") > -1
assert cell.tagIsError()
assert fix.counts.exceptions == 1
示例3: buildRows
def buildRows(self, rows):
root = Parse(tag="xx")
for row in rows:
newRow = Parse(tag="tr", parts=self.buildCells(row))
newRow.more = root.more
root.more = newRow
return root.more
示例4: shouldRecognizeFitFailureException
def shouldRecognizeFitFailureException(self):
fix = Fixture()
cell = Parse(tag="td", body="Oops.")
fix.exception(cell, FitFailureException("What the heck?"))
assert cell.body.find("What the heck?") > -1
assert cell.tagIsError()
assert fix.counts.exceptions == 1
示例5: performTest
def performTest(self, cell, runscript, page):
if ((runscript is None or runscript == "null") or page.startswith("?")):
self.ignore(cell)
return
try:
fileName = cell.text()
testResult = self.get(fileName)
if testResult.find("<wiki>") >= 0:
data = Parse(testResult, ("wiki", "td")).parts
else:
data = Parse(testResult, ("td",))
c = self.count(data)
message = self.anchor(" %s/%s/%s " %
(c.right, c.wrong, c.exceptions), fileName)
cell.addToBody(message);
if c.right > 0 and c.wrong == 0 and c.exceptions == 0:
self.right(cell)
else:
self.wrong(cell)
cell.addToBody(data.footnote()); # XXX see note about footnotes.
except Exception, e:
if str(e).find("Can't find tag: td") >= 0:
cell.addToBody("Can't parse <a href=\"" + testResult + "\">page</a>")
self.ignore(cell)
else:
self.exception(cell, e)
示例6: shouldAnnotateOnErrorCall
def shouldAnnotateOnErrorCall(self):
fix = Fixture()
cell = Parse(tag="td", body="Oops.")
fix.error(cell, "Not good!")
assert cell.body.find("Not good!") > -1
assert cell.tagIsError()
assert fix.counts.exceptions == 1
示例7: testToPrint
def testToPrint(self):
text = (
"leader<table><tr><td><table><tr><td>body1</td></tr></table>"
"<table><tr><td>body2</td></tr></table></td></tr></table>"
"trailer"
)
p = Parse(text)
newText = p.toPrint()
assert newText == text
示例8: testToPrintUnicode
def testToPrintUnicode(self):
text = (
u"leader<table><tr><td><table><tr><td>body1</td></tr></table>"
u"<table><tr><td>body2</td></tr></table></td></tr></table>"
u"trailer"
)
p = Parse(text)
newText = p.toPrint()
assert newText == text
assert isinstance(newText, types.StringType)
示例9: copyParse
def copyParse(tables):
if tables is None:
return None
parse = Parse(tag="", body=tables.body,
parts=copyParse(tables.parts), more=copyParse(tables.more))
parse.tag = tables.tag
parse.end = tables.end
parse.leader = tables.leader
parse.trailer = tables.trailer
return parse
示例10: shouldUseWithTypeAdapter
def shouldUseWithTypeAdapter(self):
obj = MockObject()
givenTA = TypeAdapter.on(obj, "sFloat1")
givenCell = Parse(tag="td", body="6.45")
obj.parseAndSet(givenCell, givenTA)
assert obj.sFloat1 == 6.45
assert isinstance(obj.sFloat1, ScientificFloat)
assert givenCell.tagIsNotAnnotated()
resultTA = TypeAdapter.on(obj, "sFloat2")
resultCell = Parse(tag="td", body="6.45")
obj.check(resultCell, resultTA)
assert resultCell.tagIsRight()
示例11: testSymbolHandler
def testSymbolHandler(self):
h = SymbolCellHandler()
checkCell = Parse(tag="td", body="<<sym")
parseCell = Parse(tag="td", body="sym<<")
callbacks = AccMock(IntMock())
result = h.check(checkCell, "spam", callbacks)
assert result == (OK, True)
assert callbacks.fixture.getSymbol("sym") == "spam"
assert checkCell.text().endswith(" = spam")
result = h.parse(parseCell, callbacks)
assert result == (OK, "spam")
assert parseCell.text().endswith(" = spam")
示例12: buildSurplusCells
def buildSurplusCells(self, adapters, objectOrDict):
root = Parse(tag="xx")
next = root
for adapter, name, symbols in adapters:
hasKey, obj = self._getObj(name, objectOrDict)
cell = Parse(tag="td")
if hasKey:
cell.body = adapter.toString(obj)
else:
self.exception(cell, "attribute missing")
next.more = cell
next = cell
return root.more
示例13: run
def run(self):
newFileName = "fat/Documents/" + self.fileName
inFile = open(newFileName, 'r')
theTest = inFile.read()
inFile.close()
self.fixture = Fixture()
self.footnote = None
if self.wiki:
self.tables = Parse(text=theTest, tags=("wiki", "table", "tr", "td"))
else:
self.tables = Parse(text=theTest, tags=("table", "tr", "td"))
self.fixture.doTables(self.tables)
self.runCounts.tally(self.fixture.counts)
self.summary["counts run"] = self.runCounts
示例14: Table
class Table(TableInterface):
_parse = None # Parse
def __init__(self, parse):
if isinstance(parse, types.StringTypes):
self._parse = Parse(parse)
elif isinstance(parse, Parse):
self._parse = parse
def tableAt(self, i, j, k):
at = self._parse.at(i, j, k).parts
return Table(at)
def stringAt(self, i, j, k):
p2 = self._parse.at(i, j, k)
if p2.parts or not p2.body:
return "null"
return p2.text()
def toTable(self):
return self
def parseTable(parse):
return Table(parse)
parseTable = staticmethod(parseTable)
def equals(expected, actual):
if expected is None:
return actual is None
return expected == actual
equals = staticmethod(equals)
def __eq__(self, other):
if not isinstance(other, Table):
return False
return self._parse == other._parse
def __ne__(self, other):
if isinstance(other, Table):
return False
return self._parse != other._parse
def toString(self):
return self._parse.toString()
def __str__(self):
return str(self._parse)
示例15: buildCells
def buildCells(self, row):
if not row:
nil = Parse(tag="td",body="None",parts=None,more=None)
nil.addToTag(" colspan="+str(len(self.columnBindings)))
return nil
next = root = Parse(None, None, None, None)
for i in range(len(self.columnBindings)):
next.more = Parse(tag="td",body=" ",parts=None,more=None)
next = next.more
a = self.columnBindings[i]
if not a:
self.ignore(next)
else:
try:
a.target = row
next.body = self.gray(self.escape(a.toString(a.get())))
except Exception, e:
self.exception(next, e)