本文整理汇总了Python中formatter.Formatter.start方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.start方法的具体用法?Python Formatter.start怎么用?Python Formatter.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类formatter.Formatter
的用法示例。
在下文中一共展示了Formatter.start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import start [as 别名]
def main():
#define busses, . means black, + means green, - means red
#busList = [
# {'name': 'bus1','description': '6kV','status': '.'},
# {'name': 'bus2','description': '12kV','status': '.'},
# {'name': 'bus3','description': '18kV','status': '.'},
# {'name': 'bus4','description': '22kV','status': '.'},
# {'name': 'bus5','description': '54kV','status': '.'},
# ]
## define the connections. '.' means black, + means green, - means read
#connectionList = [
# {1 : 'bus1', 2 : 'bus2', 'status': '.'},
# {1 : 'bus2', 2 : 'bus3', 'status': '.'},
# {1 : 'bus1', 2 : 'bus3', 'status': '+'},
# {1 : 'bus4', 2 : 'bus1', 'status': '+'},
# {1 : 'bus5', 2 : 'bus1', 'status': '+'},
# ]
# mkae graphviz string
#get json data and deserialize it
fp = open('jsonFile.txt')
for line in fp:
print (line)
fp.close()
fp = open('jsonFile.txt')
dataDict = json.loads(fp.read())
fp.close()
# load data
nodeList = dataDict['busList']
connectionList = dataDict['connectionList']
config['destPath'] = dataDict['filepath']
# add transformer name to node list
for node in nodeList:
if node['type'] == 'transformer':
#node['name'] = node['busFrom'] + '' + node['id'] + '' + node['busTo']
node['name'] = str(int(node['busFrom']) + int(node['busTo']))
# add transformer connections
for node in nodeList:
if node['type'] == 'transformer':
makeTransformerConnection(node, connectionList)
gString = make_graphviz_string(nodeList, connectionList)
# make node info list
nodeTypeDict = {}
for item in nodeList:
nodeTypeDict[item['name']] = item['type']
# write gString to file for later use
text_file = open("temp.dot", "w")
text_file.write(gString)
text_file.close()
# write gString to file for later use
text_file = open(config['pollDir'] + "out.txt", "w")
text_file.write(gString)
text_file.close()
# write dest to file for later use
text_file = open(config['pollDir'] + "dest.txt", "w")
text_file.write(config['destPath'])
text_file.close()
# write node information
text_file = open(config['pollDir'] + "nodeInfo.txt", "w")
json.dump(nodeTypeDict,text_file)
text_file.close()
# write node list
text_file = open(config['pollDir'] + "nodeList.txt", "w")
json.dump(nodeList,text_file)
text_file.close()
command = '"' + config['graphvizPath'] + '" ' + config['dotCommand'] \
+ "temp.dot > " + config['formatlessVisioFilename']
#+ "temp.dot > " + config['destPath'] + ".png"
print (gString)
print (command)
returnCode = os.system(command)
os.remove("temp.dot")
print (returnCode)
# start formatter
formatter = Formatter(config['formatlessVisioFilename'])
#input(config['destPath'] + config['outputExtension'])
formatter.start(config['destPath'] + config['outputExtension'])
time.sleep(1)
示例2: Formatter
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import start [as 别名]
from formatter import Formatter
f = Formatter('/media/sf_test-output/temp.vdx')
f.start()