本文整理汇总了Python中group.Group.setDevice方法的典型用法代码示例。如果您正苦于以下问题:Python Group.setDevice方法的具体用法?Python Group.setDevice怎么用?Python Group.setDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group.Group
的用法示例。
在下文中一共展示了Group.setDevice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import setDevice [as 别名]
def main():
file = open("test.xml","r")
line = file.readline()
while not startDevices(line):
line = file.readline()
line = file.readline().strip()
devices = []
device = ""
group = ""
capability = ""
while not endDevices(line):
if beginDevice(line):
line = deleteTags(line,"<device ",">")
att_id = getAttrId(line)
att_user = getAttrUser(line)
att_fall = getAttrFall(line)
device = Device(att_id, att_user, att_fall)
line = file.readline()
if endDevice(line):
devices.append(device)
line = file.readline()
if beginGroup(line):
line = deleteTags(line,"<group ",">")
att_id = getAttrId(line)
group = Group(att_id)
group.setDevice(device)
line = file.readline()
if endGroup(line):
device.addGroup(group)
line = file.readline()
if beginCapability(line):
line = deleteTags(line, "<capability ", "/>")
att_name = getAttrName(line)
att_value = getAttrValue(line)
capability = Capability(att_name, att_value)
capability.setGroup(group)
group.addCapability(capability)
line = file.readline()
print "Devices\n"
printDevices(devices)
print "End Devices\n"
file.close()
return 0