本文整理汇总了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))
示例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
示例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
示例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)
示例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)
示例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))
示例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
示例8: _deprecatedWarningWrapInTuple
def _deprecatedWarningWrapInTuple(txt):
warnings.warn("deprecated syntax, wrap x and y values in a tuple: '%s'" % txt)
示例9: _deprecatedWarningLowercase
def _deprecatedWarningLowercase(txt):
warnings.warn("lowercase API is deprecated use: '%s'" % txt)
示例10: _get_pageCount
def _get_pageCount(self):
warnings.warn("Magic variables are deprecated.'")
return self.pageCount()
示例11: _get_height
def _get_height(self):
warnings.warn("Magic variables are deprecated.'")
return self.height()
示例12: _get_width
def _get_width(self):
warnings.warn("Magic variables are deprecated.'")
return self.width()