本文整理汇总了Python中zim.fs.TmpFile.touch方法的典型用法代码示例。如果您正苦于以下问题:Python TmpFile.touch方法的具体用法?Python TmpFile.touch怎么用?Python TmpFile.touch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zim.fs.TmpFile
的用法示例。
在下文中一共展示了TmpFile.touch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DitaaGenerator
# 需要导入模块: from zim.fs import TmpFile [as 别名]
# 或者: from zim.fs.TmpFile import touch [as 别名]
class DitaaGenerator(ImageGeneratorClass):
uses_log_file = False
object_type = "shaape"
scriptname = "shaape.dia"
imagename = "shaape.png"
def __init__(self, plugin):
ImageGeneratorClass.__init__(self, plugin)
self.dotfile = TmpFile(self.scriptname)
self.dotfile.touch()
self.pngfile = File(self.dotfile.path[:-4] + ".png") # len('.dot') == 4
def generate_image(self, text):
# Write to tmp file
self.dotfile.write(text)
# Call GraphViz
try:
dot = Application(dotcmd)
dot.run(("-o", self.pngfile, self.dotfile))
except ApplicationError:
return None, None # Sorry, no log
else:
return self.pngfile, None
def cleanup(self):
self.dotfile.remove()
self.pngfile.remove()
示例2: DiagramGenerator
# 需要导入模块: from zim.fs import TmpFile [as 别名]
# 或者: from zim.fs.TmpFile import touch [as 别名]
class DiagramGenerator(ImageGeneratorClass):
uses_log_file = False
type = 'diagram'
scriptname = 'diagram.dot'
imagename = 'diagram.png'
def __init__(self):
self.dotfile = TmpFile(self.scriptname)
self.dotfile.touch()
self.pngfile = File(self.dotfile.path[:-4] + '.png') # len('.dot') == 4
def generate_image(self, text):
if isinstance(text, basestring):
text = text.splitlines(True)
# Write to tmp file
self.dotfile.writelines(text)
# Call GraphViz
try:
dot = Application(dotcmd)
dot.run((self.pngfile, self.dotfile))
except ApplicationError:
return None, None # Sorry, no log
else:
return self.pngfile, None
def cleanup(self):
self.dotfile.remove()
self.pngfile.remove()
示例3: SequenceDiagramGenerator
# 需要导入模块: from zim.fs import TmpFile [as 别名]
# 或者: from zim.fs.TmpFile import touch [as 别名]
class SequenceDiagramGenerator(ImageGeneratorClass):
uses_log_file = False
object_type = 'seqdiagram'
scriptname = 'seqdiagram.diag'
imagename = 'seqdiagram.png'
def __init__(self, plugin):
ImageGeneratorClass.__init__(self, plugin)
self.diagfile = TmpFile(self.scriptname)
self.diagfile.touch()
self.pngfile = File(self.diagfile.path[:-5] + '.png') # len('.diag') == 5
def generate_image(self, text):
# Write to tmp file
self.diagfile.write(text)
# Call seqdiag
try:
diag = Application(diagcmd)
diag.run((self.pngfile, self.diagfile))
except ApplicationError:
return None, None # Sorry, no log
else:
return self.pngfile, None
def cleanup(self):
self.diagfile.remove()
self.pngfile.remove()
示例4: DiagramGenerator
# 需要导入模块: from zim.fs import TmpFile [as 别名]
# 或者: from zim.fs.TmpFile import touch [as 别名]
class DiagramGenerator(object):
# TODO: generic base class for image generators
type = 'diagram'
basename = 'diagram.dot'
def __init__(self):
self.dotfile = TmpFile('diagram-editor.dot')
self.dotfile.touch()
self.pngfile = File(self.dotfile.path[:-4] + '.png') # len('.dot') == 4
def generate_image(self, text):
if isinstance(text, basestring):
text = text.splitlines(True)
# Write to tmp file
self.dotfile.writelines(text)
# Call GraphViz
dot = Application(dotcmd)
dot.run((self.pngfile, self.dotfile))
return self.pngfile, None
def cleanup(self):
self.dotfile.remove()
self.pngfile.remove()
示例5: PlantumlGenerator
# 需要导入模块: from zim.fs import TmpFile [as 别名]
# 或者: from zim.fs.TmpFile import touch [as 别名]
class PlantumlGenerator(ImageGeneratorClass):
uses_log_file = False
object_type = 'plantuml'
scriptname = 'plantuml.pu'
imagename = 'plantuml.png'
def __init__(self, plugin):
ImageGeneratorClass.__init__(self, plugin)
self.dotfile = TmpFile(self.scriptname)
self.dotfile.touch()
self.pngfile = File(self.dotfile.path[:-3] + '.png') # len('.pu') == 3
def generate_image(self, text):
if isinstance(text, basestring):
text = text.splitlines(True)
# Write to tmp file
self.dotfile.writelines(text)
# Call PlantUML
try:
dot = Application(dotcmd)
dot.run(('', self.dotfile))
except ApplicationError:
return None, None # Sorry, no log
else:
return self.pngfile, None
def cleanup(self):
self.dotfile.remove()
self.pngfile.remove()
示例6: DiagramGenerator
# 需要导入模块: from zim.fs import TmpFile [as 别名]
# 或者: from zim.fs.TmpFile import touch [as 别名]
class DiagramGenerator(ImageGeneratorClass):
uses_log_file = False
object_type = 'diagram'
scriptname = 'diagram.dot'
imagename = 'diagram.png'
def __init__(self, plugin):
ImageGeneratorClass.__init__(self, plugin)
self.dotfile = TmpFile(self.scriptname)
self.dotfile.touch()
self.pngfile = File(self.dotfile.path[:-4] + '.png') # len('.dot') == 4
def generate_image(self, text):
if isinstance(text, basestring):
text = text.splitlines(True)
# Write to tmp file
self.dotfile.writelines(text)
# Call GraphViz
try:
dot = Application(dotcmd)
dot.run((self.pngfile, self.dotfile))
except ApplicationError:
return None, None # Sorry, no log
else:
if self.pngfile.exists():
return self.pngfile, None
else:
# When supplying a dot file with a syntax error, the dot command
# doesn't return an error code (so we don't raise
# ApplicationError), but we still don't have a png file to
# return, so return None.
return None, None
def cleanup(self):
self.dotfile.remove()
self.pngfile.remove()