當前位置: 首頁>>代碼示例>>Python>>正文


Python thumbnails.Thumbnails類代碼示例

本文整理匯總了Python中outwiker.pages.wiki.thumbnails.Thumbnails的典型用法代碼示例。如果您正苦於以下問題:Python Thumbnails類的具體用法?Python Thumbnails怎麽用?Python Thumbnails使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Thumbnails類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testThumbnails1_attach

    def testThumbnails1_attach (self):
        thumb = Thumbnails (self.parser.page)
        thumbDir = thumb.getThumbPath (create=False)

        self.assertEqual (thumbDir,
                          os.path.join (Attachment (self.parser.page).getAttachPath(), Thumbnails.thumbDir),
                          thumbDir)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:7,代碼來源:thumbnails.py

示例2: testParse2

    def testParse2(self):
        self._attachFiles()
        # Тест на то, что игнорируется директория __thumb
        thumb = Thumbnails(self.testPage)
        thumb.getThumbPath(True)

        text = "(:attachlist:)"
        result = self.parser.toHtml(text)

        titles = [
            "[dir]",
            "[for_sort]",
            "add.png",
            "anchor.png",
            "image.jpg",
            "файл с пробелами.tmp"]
        names = [
            "dir",
            "for_sort",
            "add.png",
            "anchor.png",
            "image.jpg",
            "файл с пробелами.tmp"]

        self._compareResult(titles, names, result)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:25,代碼來源:test_wikicommandattachlist.py

示例3: _copyKatexLibrary

    def _copyKatexLibrary(self):
        thumb = Thumbnails(self.parser.page)
        thumb_path = thumb.getThumbPath(True)
        katex_path = os.path.join(thumb_path, KATEX_DIR_NAME)

        if os.path.exists(katex_path):
            shutil.rmtree(katex_path)

        shutil.copytree(self._getKaTeXPath(), katex_path)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:9,代碼來源:tokentex.py

示例4: testThumbnailsClear1_attach

    def testThumbnailsClear1_attach (self):
        fname = u"accept.png"
        attachPath = os.path.join (self.filesPath, fname)
        Attachment (self.parser.page).attach ([attachPath])

        thumb = Thumbnails (self.parser.page)
        thumb.clearDir ()

        self.assertFalse (os.path.exists (thumb.getThumbPath (create=False)))
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:9,代碼來源:thumbnails.py

示例5: testThumbnails3_attach

    def testThumbnails3_attach (self):
        fname = u"accept.png"
        attachPath = os.path.join (self.filesPath, fname)
        Attachment (self.parser.page).attach ([attachPath])

        thumb = Thumbnails (self.parser.page)
        thumbDir = thumb.getThumbPath (create=True)

        self.assertTrue (os.path.exists (thumbDir))
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:9,代碼來源:thumbnails.py

示例6: testThumbnailsClear3

    def testThumbnailsClear3 (self):
        thumb = Thumbnails (self.parser.page)

        eqn1 = "y = f(x)"
        eqn2 = "y = f_2(x)"

        self.parser.toHtml ("{$ %s $}" % (eqn1))
        self.assertEqual (len (os.listdir (thumb.getThumbPath (False))), 2)

        self.parser.toHtml ("{$ %s $}" % (eqn2))
        self.assertEqual (len (os.listdir (thumb.getThumbPath (False))), 2)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:11,代碼來源:texequation_test.py

示例7: testThumbnailsClear2

    def testThumbnailsClear2 (self):
        thumb = Thumbnails (self.parser.page)

        eqn = "y = f(x)"

        text = "{$ %s $}" % (eqn)
        self.parser.toHtml (text)

        self.assertFalse (len (os.listdir (thumb.getThumbPath (False))) == 0)

        thumb.clearDir()

        self.assertEqual (len (os.listdir (thumb.getThumbPath (False))), 0)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:13,代碼來源:texequation_test.py

示例8: testThumbnailsClear3_attach

    def testThumbnailsClear3_attach (self):
        fname = u"accept.png"
        attachPath = os.path.join (self.filesPath, fname)
        Attachment (self.parser.page).attach ([attachPath])

        thumb = Thumbnails (self.parser.page)

        eqn1 = "y = f(x)"
        eqn2 = "y = f_2(x)"

        self.parser.toHtml ("{$ %s $}" % (eqn1))
        self.assertEqual (len (os.listdir (thumb.getThumbPath (False))), 2)

        self.parser.toHtml ("{$ %s $}" % (eqn2))
        self.assertEqual (len (os.listdir (thumb.getThumbPath (False))), 2)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:15,代碼來源:texequation_test.py

示例9: testThumbnailsClear2_attach

    def testThumbnailsClear2_attach (self):
        fname = u"accept.png"
        attachPath = os.path.join (self.filesPath, fname)
        Attachment (self.parser.page).attach ([attachPath])

        thumb = Thumbnails (self.parser.page)

        eqn = "y = f(x)"

        text = "{$ %s $}" % (eqn)
        self.parser.toHtml (text)

        self.assertFalse (len (os.listdir (thumb.getThumbPath (False))) == 0)

        thumb.clearDir()

        self.assertEqual (len (os.listdir (thumb.getThumbPath (False))), 0)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:17,代碼來源:texequation_test.py

示例10: testTex1

    def testTex1 (self):
        thumb = Thumbnails (self.parser.page)
        texrender = getTexRender(thumb.getThumbPath (True))

        eqn = u"y = f(x)"
        text = u"{$ %s $}" % (eqn)

        fname = texrender.getImageName (eqn)
        path = os.path.join (Thumbnails.getRelativeThumbDir(), fname)

        result_right = u'<IMG SRC="{0}"/>'.format (path.replace ("\\", "/"))

        result = self.parser.toHtml (text)

        self.assertEqual (result_right, result, result)

        full_path = os.path.join (self.parser.page.path, path)
        self.assertTrue (os.path.exists (full_path), full_path )
開發者ID:s200999900,項目名稱:outwiker,代碼行數:18,代碼來源:parsertex.py

示例11: testTex4

    def testTex4 (self):
        thumb = Thumbnails (self.parser.page)
        texrender = getTexRender(thumb.getThumbPath (True))

        eqn = u"y = f(x)"
        text = u"[[http://jenyay.net | {$ %s $}]]" % (eqn)

        fname = texrender.getImageName (eqn)
        path = os.path.join (Thumbnails.getRelativeThumbDir(), fname)

        result_right = u'<a href="http://jenyay.net"><img src="{0}"/></a>'.format (path.replace ("\\", "/"))

        result = self.parser.toHtml (text)

        self.assertEqual (result_right, result, result)

        full_path = os.path.join (self.parser.page.path, path)
        self.assertTrue (os.path.exists (full_path), full_path )
開發者ID:qyqx,項目名稱:outwiker,代碼行數:18,代碼來源:parsertex.py

示例12: execute

    def execute (self, params, content):
        """
        Запустить команду на выполнение.
        Метод возвращает текст, который будет вставлен на место команды в вики-нотации
        """
        from blockdiag.parser import ParseException
        thumb = Thumbnails(self.parser.page)
        thumbPath = thumb.getThumbPath(True)

        md5 = hashlib.md5 (content.encode ("utf-8")).hexdigest()
        fname = self._fileNameFormat.format (md5)
        imagePath = os.path.join (thumbPath, fname)

        render = DiagramRender()

        if not os.path.exists (imagePath):
            try:
                render.renderToFile (content, imagePath)
            except (ParseException, AttributeError, TypeError):
                return u"<b>{}</b>".format(_(u"Diagram parsing error"))

        return u'<img src="{}/{}"/>'.format (thumb.getRelativeThumbDir(), fname)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:22,代碼來源:commanddiagram.py

示例13: testTex2

    def testTex2 (self):
        thumb = Thumbnails (self.parser.page)
        texrender = getTexRender(thumb.getThumbPath (True))

        eqn1 = u"y = f(x)"
        eqn2 = u"y = e^x"
        eqn3 = u"y = \sum_{i=0}\pi"

        text = u"""бла-бла-бла
* бла-бла-бла {$ %s $} 1111
* бла-бла-бла {$ %s $} 222
* бла-бла-бла {$ %s $} 333""" % (eqn1, eqn2, eqn3)

        fname1 = texrender.getImageName (eqn1)
        fname2 = texrender.getImageName (eqn2)
        fname3 = texrender.getImageName (eqn3)

        path1 = os.path.join (Thumbnails.getRelativeThumbDir(), fname1)
        path2 = os.path.join (Thumbnails.getRelativeThumbDir(), fname2)
        path3 = os.path.join (Thumbnails.getRelativeThumbDir(), fname3)

        result_right = u'''бла-бла-бла
<UL><LI>бла-бла-бла <IMG SRC="{path1}"/> 1111</LI><LI>бла-бла-бла <IMG SRC="{path2}"/> 222</LI><LI>бла-бла-бла <IMG SRC="{path3}"/> 333</LI></UL>'''.format (path1=path1.replace ("\\", "/"), 
        path2=path2.replace ("\\", "/"),
        path3=path3.replace ("\\", "/"))


        result = self.parser.toHtml (text)

        self.assertEqual (result_right, result, result)

        full_path1 = os.path.join (self.parser.page.path, path1)
        full_path2 = os.path.join (self.parser.page.path, path2)
        full_path3 = os.path.join (self.parser.page.path, path3)

        self.assertTrue (os.path.exists (full_path1), full_path1)
        self.assertTrue (os.path.exists (full_path2), full_path2)
        self.assertTrue (os.path.exists (full_path3), full_path3)
開發者ID:s200999900,項目名稱:outwiker,代碼行數:38,代碼來源:parsertex.py

示例14: makeTexEquation

    def makeTexEquation (self, s, l, t):
        eqn = t[0].strip()
        if len (eqn) == 0:
            return u""

        thumb = Thumbnails(self.parser.page)

        try:
            path = thumb.getThumbPath (True)
        except IOError:
            return u"<b>{}</b>".format(_(u"Can't create thumbnails directory"))

        tex = getTexRender (path)

        try:
            image_fname = tex.makeImage (eqn)
        except IOError:
            return u"<b>{}</b>".format(_(u"Can't create image file"))

        image_path = os.path.join (Thumbnails.getRelativeThumbDir(), image_fname)
        result = u'<img src="{image}"/>'.format (image=image_path.replace ("\\", "/"))

        return result
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:23,代碼來源:tokentex.py

示例15: testThumbnailsClear1

    def testThumbnailsClear1 (self):
        thumb = Thumbnails (self.parser.page)
        thumb.clearDir ()

        self.assertFalse (os.path.exists (thumb.getThumbPath (create=False)))
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:5,代碼來源:thumbnails.py


注:本文中的outwiker.pages.wiki.thumbnails.Thumbnails類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。