当前位置: 首页>>代码示例>>Python>>正文


Python Parse.at方法代码示例

本文整理汇总了Python中fit.Parse.Parse.at方法的典型用法代码示例。如果您正苦于以下问题:Python Parse.at方法的具体用法?Python Parse.at怎么用?Python Parse.at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fit.Parse.Parse的用法示例。


在下文中一共展示了Parse.at方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testIndexing

# 需要导入模块: from fit.Parse import Parse [as 别名]
# 或者: from fit.Parse.Parse import at [as 别名]
 def testIndexing(self):
     p = Parse("leader<table><tr><td>one</td><td>two</td><td>three</td></tr><tr><td>four</td></tr></table>trailer")
     self.assertEquals("one", p.at(0, 0, 0).body)
     self.assertEquals("two", p.at(0, 0, 1).body)
     self.assertEquals("three", p.at(0, 0, 2).body)
     self.assertEquals("three", p.at(0, 0, 3).body)
     self.assertEquals("three", p.at(0, 0, 4).body)
     self.assertEquals("four", p.at(0, 1, 0).body)
     self.assertEquals("four", p.at(0, 1, 1).body)
     self.assertEquals("four", p.at(0, 2, 0).body)
     self.assertEquals(1, p.size())
     self.assertEquals(2, p.parts.size())
     self.assertEquals(3, p.parts.parts.size())
     self.assertEquals("one", p.leaf().body)
     self.assertEquals("four", p.parts.last().leaf().body)
开发者ID:copyleftdev,项目名称:pyfit,代码行数:17,代码来源:FrameworkTest.py

示例2: Table

# 需要导入模块: from fit.Parse import Parse [as 别名]
# 或者: from fit.Parse.Parse import at [as 别名]
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)
开发者ID:copyleftdev,项目名称:pyfit,代码行数:49,代码来源:Table.py

示例3: ResultingHTML

# 需要导入模块: from fit.Parse import Parse [as 别名]
# 或者: from fit.Parse.Parse import at [as 别名]
    def ResultingHTML(self):
        table = Parse(self.OriginalHTML)
        row = table.at(0, self.Row - 1)
        cell = row.at(0, self.Column - 1)
        
        if (self.OverwriteCellBody is not None):
            cell.body = self.OverwriteCellBody
        if (self.AddToCellBody is not None):
            cell.addToBody(self.AddToCellBody)
        
        if (self.OverwriteCellTag is not None):
            cell.tag = self.OverwriteCellTag
        if (self.OverwriteEndCellTag is not None):
            cell.end = self.OverwriteEndCellTag
        if (self.AddToCellTag is not None):
            cell.addToTag(self.stripDelimiters(self.AddToCellTag))
        
        if (self.OverwriteRowTag is not None):
            row.tag = self.OverwriteRowTag
        if (self.OverwriteEndRowTag is not None):
            row.end = self.OverwriteEndRowTag
        if (self.AddToRowTag is not None):
            row.addToTag(self.stripDelimiters(self.AddToRowTag))

        if (self.OverwriteTableTag is not None):
            table.tag = self.OverwriteTableTag
        if (self.OverwriteEndTableTag is not None):
            table.end = self.OverwriteEndTableTag
        if (self.AddToTableTag is not None):
            table.addToTag(self.stripDelimiters(self.AddToTableTag))

        if (self.AddCellFollowing is not None):
            self.addParse(cell, self.AddCellFollowing, ["td"])
        if (self.RemoveFollowingCell is not None):
            self.removeParse(cell)
                
        if (self.AddRowFollowing is not None):
            self.addParse(row, self.AddRowFollowing, ["tr", "td"])
        if (self.RemoveFollowingRow is not None):
            self.removeParse(row)
        
        if (self.AddTableFollowing is not None):
            self.addParse(table, self.AddTableFollowing,
                          ["table", "tr", "td"])

        return self.GenerateOutput(table)
开发者ID:copyleftdev,项目名称:pyfit,代码行数:48,代码来源:AnnotationFixture.py


注:本文中的fit.Parse.Parse.at方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。