• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python warnings.warn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中misc.warnings.warn函数的典型用法代码示例。如果您正苦于以下问题:Python warn函数的具体用法?Python warn怎么用?Python warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: text

    def text(self, txt, x, y=None):
        """
        Draw a text at a provided position.

        .. showcode:: /../examples/text.py
        """
        try:
            txt = txt.decode("utf-8")
        except:
            pass
        if isinstance(x, (tuple, list)):
            x, y = x
        else:
            warnings.warn("postion must a tuple: text('%s', (%s, %s))" % (txt, x, y))
        attrString = self._dummyContext.attributedString(txt)
        w, h = attrString.size()
        setter = CoreText.CTFramesetterCreateWithAttributedString(attrString)
        path = Quartz.CGPathCreateMutable()
        Quartz.CGPathAddRect(path, None, Quartz.CGRectMake(x, y, w*2, h))
        box = CoreText.CTFramesetterCreateFrame(setter, (0, 0), path, None)
        ctLines = CoreText.CTFrameGetLines(box)
        origins = CoreText.CTFrameGetLineOrigins(box, (0, len(ctLines)), None)
        if origins:
            x -= origins[-1][0]
            y -= origins[-1][1]
        self.textBox(txt, (x, y-h, w*2, h*2))
开发者ID:anthrotype,项目名称:drawBotRoboFontExtension,代码行数:26,代码来源:drawBotDrawingTools.py


示例2: installFont

    def installFont(self, path):
        """
        Install a font with a given path and the postscript font name will be returned.
        The postscript font name can be used to set the font as the active font.

        Fonts are installed only for the current process.
        Fonts will not be accesible outside the scope of drawBot.

        All installed fonts will automatically be uninstalled when the script is done.

        .. showcode:: /../examples/installFont.py
        """
        success, error = self._dummyContext.installFont(path)
        self._installedFontPaths.add(path)
        self._addInstruction("installFont", path)

        from fontTools.ttLib import TTFont, TTLibError
        try:
            font = TTFont(path)
            psName = font["name"].getName(6, 1, 0)
            if psName is None:
                psName = font["name"].getName(6, 3, 1)
            font.close()
        except IOError:
            raise DrawBotError("Font '%s' does not exist." % path)
        except TTLibError:
            raise DrawBotError("Font '%s' is not a valid font." % path)
        if psName is not None:
            psName = psName.toUnicode()

        if not success:
            warnings.warn("install font: %s" % error)
        return psName
开发者ID:Floris497,项目名称:drawbot,代码行数:33,代码来源:drawBotDrawingTools.py


示例3: installFont

    def installFont(self, path):
        """
        Install a font with a given path.
        """
        success, error = self._dummyContext.installFont(path)
        self._installedFontPaths.add(path)
        self._addInstruction("installFont", path)

        from fontTools.ttLib import TTFont, TTLibError
        try:
            font = TTFont(path)
            psName = font["name"].getName(6, 1, 0)
            if psName is None:
                psName = font["name"].getName(6, 3, 1)
            font.close()
        except IOError:
            raise DrawBotError("Font '%s' does not exist." % path)
        except TTLibError:
            raise DrawBotError("Font '%s' is not a valid font." % path)
        if psName is not None:
            psName = psName.toUnicode()

        if not success:
            warnings.warn("install font: %s" % error)
        return psName
开发者ID:sannorozco,项目名称:drawBotRoboFontExtension,代码行数:25,代码来源:drawBotDrawingTools.py


示例4: uninstallFont

 def uninstallFont(self, path):
     """
     Uninstall a font with a given path.
     """
     succes, error = self._dummyContext.uninstallFont(path)
     if not succes:
         warnings.warn("uninstall font: %s" % error)
     self._addInstruction("uninstallFont", path)
开发者ID:Floris497,项目名称:drawbot,代码行数:8,代码来源:drawBotDrawingTools.py


示例5: uninstallFont

 def uninstallFont(self, path):
     """
     Uninstall a font with a given path.
     All installed fonts will automatically be uninstalled when the script is done.
     """
     succes, error = self._dummyContext.uninstallFont(path)
     if not succes:
         warnings.warn("uninstall font: %s" % error)
     self._addInstruction("uninstallFont", path)
开发者ID:sannorozco,项目名称:drawBotRoboFontExtension,代码行数:9,代码来源:drawBotDrawingTools.py


示例6: text

    def text(self, txt, x, y=None):
        """
        Draw a text at a provided position.

        .. showcode:: /../examples/text.py
        """
        if isinstance(x, (tuple, list)):
            x, y = x
        else:
            warnings.warn("postion must a tuple: text('%s', (%s, %s))" % (txt, x, y))
        w, h = self.textSize(txt)
        self.textBox(txt, (x, y, w*1.3, h))
开发者ID:imclab,项目名称:drawbot,代码行数:12,代码来源:drawBotDrawingTools.py


示例7: installFont

    def installFont(self, path):
        """
        Install a font with a given path and the postscript font name will be returned.
        The postscript font name can be used to set the font as the active font.

        Fonts are installed only for the current process.
        Fonts will not be accesible outside the scope of drawBot.

        All installed fonts will automatically be uninstalled when the script is done.

        .. showcode:: /../examples/installFont.py
        """
        if path in self._tempInstalledFonts:
            return self._tempInstalledFonts[path]

        success, error = self._dummyContext.installFont(path)
        self._addInstruction("installFont", path)

        psName = self._dummyContext._fontNameForPath(path)
        self._tempInstalledFonts[path] = psName

        if not success:
            warnings.warn("install font: %s" % error)
        return psName
开发者ID:andyclymer,项目名称:drawbot,代码行数:24,代码来源:drawBotDrawingTools.py


示例8: _deprecatedWarningWrapInTuple

def _deprecatedWarningWrapInTuple(txt):
    warnings.warn("deprecated syntax, wrap x and y values in a tuple: '%s'" % txt)
开发者ID:anthrotype,项目名称:drawBotRoboFontExtension,代码行数:2,代码来源:drawBotDrawingTools.py


示例9: _deprecatedWarningLowercase

def _deprecatedWarningLowercase(txt):
    warnings.warn("lowercase API is deprecated use: '%s'" % txt)
开发者ID:anthrotype,项目名称:drawBotRoboFontExtension,代码行数:2,代码来源:drawBotDrawingTools.py


示例10: _get_pageCount

 def _get_pageCount(self):
     warnings.warn("Magic variables are deprecated.'")
     return self.pageCount()
开发者ID:anthrotype,项目名称:drawBotRoboFontExtension,代码行数:3,代码来源:drawBotDrawingTools.py


示例11: _get_height

 def _get_height(self):
     warnings.warn("Magic variables are deprecated.'")
     return self.height()
开发者ID:anthrotype,项目名称:drawBotRoboFontExtension,代码行数:3,代码来源:drawBotDrawingTools.py


示例12: _get_width

 def _get_width(self):
     warnings.warn("Magic variables are deprecated.'")
     return self.width()
开发者ID:anthrotype,项目名称:drawBotRoboFontExtension,代码行数:3,代码来源:drawBotDrawingTools.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python miscUtils.LogMessages类代码示例发布时间:2022-05-27
下一篇:
Python util.toString函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap