当前位置: 首页>>代码示例>>Python>>正文


Python Template.subsitute方法代码示例

本文整理汇总了Python中string.Template.subsitute方法的典型用法代码示例。如果您正苦于以下问题:Python Template.subsitute方法的具体用法?Python Template.subsitute怎么用?Python Template.subsitute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在string.Template的用法示例。


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

示例1: results

# 需要导入模块: from string import Template [as 别名]
# 或者: from string.Template import subsitute [as 别名]
	def results(self):
		
		top = Template(svgTemplate.topSection);
		layer = Template(svgTemplate.pathSection);
		bottom = Template(svgTemplate.bottomSection);
		
		#build the top and bottom portion of the document
		p = {}:
		p['unitScale'] = self.unitScale;
		p['units'] = self.units;
		p['description'] = self.description;
		p['title']=self.title;
		p['sliceHeight'] = self.NUMBERFORMAT % self.sliceSet.sliceHeight;
		p['xMin'] = self.NUMBERFORMAT % self.sliceSet.analyzer.xMin;
		p['xMax'] = self.NUMBERFORMAT % self.sliceSet.analyzer.xMax;
		p['xRange'] = self.NUMBERFORMAT % self.sliceSet.analyzer.xDim;
		p['yMin'] = self.NUMBERFORMAT % self.sliceSet.analyzer.yMin;
		p['yMax'] = self.NUMBERFORMAT % self.sliceSet.analyzer.yMax;
		p['yRange'] = self.NUMBERFORMAT % self.sliceSet.analyzer.yDim;
		p['zMin'] = self.NUMBERFORMAT % self.sliceSet.analyzer.zMin;
		p['zMax'] =	self.NUMBERFORMAT % self.sliceSet.analyzer.zMax;	
		p['zRange'] = self.NUMBERFORMAT % self.sliceSet.analyzer.zDim;
		
		#svg specific properties
		p['xTranslate']=(-1)*self.sliceSet.analyzer.xMin
		p['yTranslate']=(-1)*self.sliceSet.analyzer.yMin
		
		#put layer dims as nicely formatted numbers
		p['xMinText'] = self.NUMBERFORMAT % self.sliceSet.analyzer.xMin; 
		p['xMaxText'] = "self.NUMBERFORMAT % self.sliceSet.analyzer.xMax;
		p['yMinText'] = self.NUMBERFORMAT % self.sliceSet.analyzer.yMin; 
		p['yMaxText'] = self.NUMBERFORMAT % self.sliceSet.analyzer.yMax;
		p['zMinText'] = self.NUMBERFORMAT % self.sliceSet.analyzer.zMin;
		p['zMaxText'] = self.NUMBERFORMAT % self.sliceSet.analyzer.zMax;
		
		resultDoc = top.substitute(p);
		
		for layer in self.layers:
			p['zLevel'] = layer.zLevel();
			p['layerNo'] = layer.slice.layerNo;
			p['xTransform'] = layer.xTransform();
			p['yTransform'] = layer.yTransform();
			p['path'] = layer.path();
			resultDoc += layer.subsitute(p);

		resultDoc += bottom.substitute(p);
		return resultDoc;
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:49,代码来源:Gcode_Lib.py


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