浏览代码

更新物理世界数据

李莎 1 年之前
父节点
当前提交
1092de8118
共有 1 个文件被更改,包括 44 次插入0 次删除
  1. 44 0
      physical_world_exporter/MyUtils/ConfigUtils.py

+ 44 - 0
physical_world_exporter/MyUtils/ConfigUtils.py

@@ -0,0 +1,44 @@
+import xml.etree.ElementTree as ET
+
+
+#读取xml文件
+class ConfigUtils():
+    def __init__(self,file):
+        self.url = ""
+        self.tree = ET.parse(file)
+        self.root = self.tree.getroot()
+
+    def readTop(self, key, child):
+        datas = []
+        data = self.root.find(key)
+        for key in child:
+            datas.append(data.get(key))
+        return datas
+
+    def readTopDict(self, key, child):
+        datas = {}
+        data = self.root.find(key)
+        for key in child:
+            datas[key] = data.get(key)
+        return datas
+
+    def readConfig(self,parent,child):
+        datas=[]
+        for childLine in self.root.find(parent):
+            data=[]
+            for key in child:
+                data.append(childLine.get(key))
+            datas.append(data)
+        return datas
+
+    def readConfigDict(self,parent,child):
+        datas=[]
+        for childLine in self.root.find(parent):
+            data={}
+            for key in child:
+                data[key]=childLine.get(key)
+            datas.append(data)
+        return datas
+
+if __name__ == '__main__':
+    config = ConfigUtils("logger.conf")