Ejemplo n.º 1
0
    def testOrgParserIdentifyOrgTables(self):
        source = ["some text sdfsdf", "| Header | X | Header Z |", "|------+----+------|", "| Content | 1 | Content Z |", "Some other text"]
        target = (CacheLocation(1,0), CacheLocation(3,27))

        result = OrgParser.identifyOrgTable(source, CacheLocation.getZeroCacheLocation())

        self.assertEqual(result, target)
Ejemplo n.º 2
0
    def testGetCacheLocation(self):
        vSource = ["Test A", "Line 1", "Word L", "Last"]
        vTarget = [" 1", "Word"]

        vCacheLocationStart = CacheLocation(1,4)
        vCacheLocationEnd = CacheLocation(2,4)
        vResult = CacheLocation.getCacheLocation(vSource, vCacheLocationStart, vCacheLocationEnd)

        self.assertEqual(vResult, vTarget)
Ejemplo n.º 3
0
def translateOrgToHTMLTables(pCache):
    vNewCache = pCache
    vCacheRange = OrgParser.identifyOrgTable(vNewCache, CacheLocation.getZeroCacheLocation())
    while(vCacheRange.start != None and vCacheRange.start > CacheLocation.getZeroCacheLocation()):
        vOrgTablePart = CacheLocation.getCacheLocation(vNewCache, vCacheRange.start, vCacheRange.end)
        vOrgTable = OrgParser.parse(vOrgTablePart)
        vHTMLWriter = OrgTableHTMLWriter(vOrgTable)
        vCache = vHTMLWriter.parseHTML()
        vNewCache = CacheLocation.replaceCacheLocation(vNewCache, vCacheRange.start, vCacheRange.end, vCache)

        vOriginalLines = vCacheRange.end.getLineNum() - vCacheRange.start.getLineNum()
        vNewLines = len(vCache)
        vDifference = vNewLines - vOriginalLines        

        vCacheLocationEnd = CacheLocation(vCacheRange.end.getLineNum()+vDifference, vCacheRange.end.getIndex())
        vCacheRange = OrgParser.identifyOrgTable(vNewCache, vCacheLocationEnd)


    return vNewCache
Ejemplo n.º 4
0
    def testReplaceCacheLocationDifirence(self):
        vSource = ["Test A", "Line 1", "Word L", "Last"]
        vTarget = ["Test A", "Line My", "Own", "Text L", "Last"]

        vReplacement = ["My", "Own", "Text"]

        vCacheLocationStart = CacheLocation(1,5)
        vCacheLocationEnd = CacheLocation(2,4)
        vResult = CacheLocation.replaceCacheLocation(vSource, vCacheLocationStart, vCacheLocationEnd, vReplacement)

        self.assertEqual(vResult, vTarget)