本文整理匯總了Python中log.Log.Log.write方法的典型用法代碼示例。如果您正苦於以下問題:Python Log.write方法的具體用法?Python Log.write怎麽用?Python Log.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類log.Log.Log
的用法示例。
在下文中一共展示了Log.write方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: createBufferForSvgFile
# 需要導入模塊: from log.Log import Log [as 別名]
# 或者: from log.Log.Log import write [as 別名]
class SvgPresentation:
@staticmethod
def createBufferForSvgFile(path):
baseFolderPath, svgFileName = os.path.split(path)
baseFileName, extension = os.path.splitext(svgFileName)
return FileBuffer(os.path.join(baseFolderPath, "SvgPresentation-"+baseFileName))
def __init__(self, svgPath):
self.log = Log()
self.svgPath = svgPath
self.baseFolderPath, svgFileName = os.path.split(svgPath)
self.buffer = SvgPresentation.createBufferForSvgFile(svgPath)
self.slideBuffer = self.buffer.subBuffer("slides")
self.log.write("Reading %s..."%svgPath)
file = open(svgPath, 'r')
data = file.read()
file.close()
hash = FileBuffer.hashFromData(data)
# self.log.write("Done.")
xmlPath = self.buffer.useFileWithHash(hash)
if xmlPath is None:
if not self.loadFromSvgData(data):
return
data = None
xmlPath = self.buffer.registerAndUseFileWithHash(hash, ".xml")
self.saveToXmlFile(xmlPath)
else:
data = None
self.loadFromXmlFile(xmlPath)
def reset(self):
self.slides = []
self.pagecolor = None
def __iter__(self):
return self.slides.__iter__()
def cleanUp(self):
self.buffer.cleanUp()
def loadFromSvgData(self, data):
self.reset()
# parse data
self.log.write("Parsing...")
# try:
tree = etree.ElementTree(etree.fromstring(data))
# except:
# print "Problem with lxml, falling back to standard library."
# import xml.etree.ElementTree as etree
# tree = etree.ElementTree(etree.fromstring(data))
data = None
root = tree.getroot()
# self.log.write("Done.")
# check dimensions
self.width = float(root.get("width"))
self.height = float(root.get("height"))
# look for layers and slides
self.log.write("Looking for layers...")
layers = SvgManipulations.extractAllLayers(root)
self.log.write("%d layers found."%len(layers))
# remove unneeded data (for a higher probability of hashs being equal)
CopyKeys = ["id", "pagecolor", "{%s}pageopacity"%NSS["inkscape"]]
sodipodis = root.findall("sodipodi:namedview", NSS)
for s in sodipodis:
a = {}
for key in CopyKeys:
a[key] = s.attrib[key]
if key=="pagecolor":
self.pagecolor = a[key]
s.attrib = a
if self.pagecolor is None:
self.pagecolor = "#ffffff"
# show all layers
for layer in layers:
SvgManipulations.removeStyleAttribute(layer, "display:none")
SvgManipulations.removeStyleAttribute(layer, "display:inline")
# tree.write(svgPath+"-debug.svg", encoding="UTF-8", xml_declaration=True)
# create slides
self.log.write("Creating slides...")
for layerIndex, layer in enumerate(layers):
# only loop over slides
if SvgManipulations.isBackground(layer):
continue
# print "."
# xmlNamespacesnew svg tree, because we will delete stuff!
newSvgTree = etree.ElementTree(root.copy())
newSvgRoot = newSvgTree.getroot()
newLayers = SvgManipulations.extractAllLayers(newSvgRoot)
#.........這裏部分代碼省略.........