Ejemplo n.º 1
0
    def testTranslateOrgToHTMLTables(self):

        vSource = ["Some randome text"
                   ,"this is -> something"
                   ,"| id | description |"
                   ,"|----+-------------|"
                   ,"| 1  | text        |"
                   ,"Some other lines * -> Hello"
                   ,"| id | XXxxxxxxxyy |"
                   ,"|----+-------------|"
                   ,"| 3  | None        |"
                   ,"Hellosdlsf. End."]

        vCache = utils.cacheFile(vSource)
        vResult = enmlOutput.translateOrgToHTMLTables(vCache)
    
        vTarget = ["Some randome text", "this is -> something"
                   ,"<TABLE>"
                   ,"<TR><TH>id</TH><TH>description</TH></TR>"
                   ,"<TR><TD>1</TD><TD>text</TD></TR>"
                   ,"</TABLE>"
                   ,"Some other lines * -> Hello"
                   ,"<TABLE>"
                   ,"<TR><TH>id</TH><TH>XXxxxxxxxyy</TH></TR>"
                   ,"<TR><TD>3</TD><TD>None</TD></TR>"
                   ,"</TABLE>"
                   ,"Hellosdlsf. End."
        ]

        self.assertEqual(vResult, vTarget)
Ejemplo n.º 2
0
    def testCacheFile(self):
        vSource = ["Hello", "second line"]
        vTarget = ["Hello", "second line"]

        vResult = utils.cacheFile(vSource)

        self.assertEqual(vTarget, vResult)
def org2ever(pSourceFile, pDestinationFile):
    vCache = cacheFile(pSourceFile)
    if isOrgModeFile(vCache):
        vCache = enmlOutput.convertDoneToEvernote(pCache = vCache)
        vCache = enmlOutput.convertTodoToEvernote(pCache = vCache)
        vCache = enmlOutput.convertToEvernoteLinkNotation(pCache=vCache)
        vCache = escapeCharsFile(pSource=vCache, pChars=fEscapeChars)
        vCache =  enmlOutput.translateOrgToHTMLTables(pCache = vCache)
        writeFile(pDestinationFile, vCache)
def ever2org(pSourceFile, pDestinationFile):
    vCache = cacheFile(pSourceFile)
    if isOrgModeFile(vCache):
        vCache = removeEmptyLines(vCache)
        vCache = orgOutput.completeOrgTableNotation(vCache)
        vCache = unescapeCharsFile(vCache, fEscapeChars)
        vCache = orgOutput.convertToOrgLinkNotation(pSource=vCache)
        vCache = orgOutput.convertDoneToOrg(pCache = vCache)
        vCache = orgOutput.convertTodoToOrg(pCache = vCache)
        writeFile(pDestinationFile, vCache)
    def testFullConversionToOrgMode(self):
        vSourceFile = codecs.open(filename="./tests/resources/test.evernote", mode="r", encoding="utf-8")
        vDestinationFile = codecs.open(filename="./tests/resources/test.org.out", mode="w+", encoding="utf-8")
        try:
            geeknoteConvertorLib.ever2org(vSourceFile, vDestinationFile)
        finally:
            vSourceFile.close()
            vDestinationFile.close()

        vResultFile = codecs.open(filename="./tests/resources/test.org.out", mode="r", encoding="utf-8")
        vTargetFile = codecs.open(filename="./tests/resources/test.org.target", mode="r", encoding="utf-8")

        try:
            vResult = utils.cacheFile(vResultFile)
            vTarget = utils.cacheFile(vTargetFile)
            self.assertEqual(vResult, vTarget)
        except Exception as e:
            self.assertTrue(False, "Exception happened while comparing files: " + str(e))
        finally:
            vResultFile.close()
            vTargetFile.close()