read.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import os
  2. import yaml
  3. topoCheckData = None
  4. # 读取yaml
  5. def read_yaml_file(filepath):
  6. with open(filepath, 'r') as file:
  7. data = yaml.load(file, Loader=yaml.FullLoader)
  8. return data
  9. current_file_path = os.path.abspath(__file__)
  10. # 获取当前脚本所在的目录
  11. current_dir = os.path.dirname(current_file_path)
  12. topoCheckData = read_yaml_file(f"{current_dir}\\topoCheck.yaml")
  13. # print(topoCheckData)
  14. # print(topoCheckData["topoCheck"]["A03"])
  15. # tempdata = topoCheckData["topoCheck"]
  16. # print(f"标识码 名称 说明")
  17. # for attr in tempdata:
  18. # print(
  19. # f"{attr} {tempdata[attr]['note']} {tempdata[attr]['UI']['description'].replace('说明: ', '').replace('说明:', '').replace('<br/>', '')}")
  20. def getTopoCheckSQL(type, my_dict):
  21. # sqllist = []
  22. data = topoCheckData["topoCheck"][type]
  23. tempSql = data["ALG"]
  24. for key in my_dict:
  25. value = my_dict[key]
  26. k = f"@{key}@"
  27. tempSql = tempSql.replace(k, value)
  28. print(tempSql)
  29. return tempSql
  30. # 获取description
  31. def getTopoCheckDescription(type):
  32. # sqllist = []
  33. data = topoCheckData["topoCheck"][type]
  34. description = data["UI"]["description"]
  35. return description
  36. # 获取note
  37. def getTopoCheckNote(type):
  38. # sqllist = []
  39. data = topoCheckData["topoCheck"][type]
  40. note = data["note"]
  41. return f"{type}:{note}"
  42. # my_dict = {
  43. # "intable_s": "topology_table",
  44. # "outtable": "topology_table_temp"
  45. # }
  46. # sql = getTopoCheckSQL("A03", my_dict)
  47. # print(sql)
  48. # for s in sql.split(";"):
  49. # print(s)