model_config.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import yaml
  2. def get_global_config(draw_type):
  3. app_name = _get_app_name()
  4. with open(f'config/{app_name}/global-{draw_type}.yaml', 'r', encoding='utf-8') as file:
  5. return yaml.safe_load(file)
  6. def _get_app_name():
  7. with open('config/application.yaml', 'r', encoding='utf-8') as file:
  8. app_config = yaml.safe_load(file)
  9. app_name = app_config['app']['name']
  10. return app_name
  11. class ModelConfig:
  12. def __init__(self,draw_type):
  13. config = get_global_config(draw_type)
  14. self.request_url = config['request']['url']
  15. self.agg_route = config['agg']['route']
  16. self.agg_scale = config['agg']['scale']
  17. self.agg_shift = config['agg']['shift']['x'], config['agg']['shift']['y']
  18. self.div_route = config['div']['route']
  19. self.div_scale = config['div']['scale']
  20. shift_config = config['div']['shift']
  21. self.div_shift = [(shift_config['x'][i], shift_config['y'][i]) for i in range(len(shift_config['x']))]
  22. self.gate_style = config['style']['gate']
  23. self.window_style = config['style']['window']
  24. self.wind_bridge_style = config['style']['wind-bridge']
  25. self.fan_main_style = config['style']['fan-main']
  26. self.fan_local_style = config['style']['fan-local']
  27. self.sealed_style = config['style']['sealed']
  28. self.shaft_style = config['style']['shaft']
  29. self.air_duct_style = config['style']['air-duct']
  30. self.tun_2d_style = config['style']['tun-2d']
  31. self.tun_3d_style = config['style']['tun-3d']
  32. self.air_flow_style = config['style']['air-flow']
  33. self.tun_text_style = config['style']['tun-text']
  34. _global_model_configs = {
  35. '2d': ModelConfig('2d'),
  36. '3d': ModelConfig('3d')
  37. }