forked from flashlxy/PyMICAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Products.py
48 lines (39 loc) · 1.42 KB
/
Products.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
# 产品参数类 关联模块Main,maskout和类Micaps3Data,Micaps4Data,Projection, HeadDesc
# Author: Liu xianyao
# Email: [email protected]
# Update: 2017-04-11
# Copyright: ©江西省气象台 2017
# Version: 2.0.20170411
import os
from datetime import datetime
from xml.etree import ElementTree
from Map import Map
from MicapsFile import MicapsFile
from Picture import Picture
class Products:
"""
画图参数的封装类
用法:
"""
def __init__(self, xmlfile):
self.xmlfile = xmlfile
if not os.path.exists(self.xmlfile):
return
try:
tree = ElementTree.parse(self.xmlfile)
p = tree.getroot()
# 地图
self.map = Map(p)
# get picture para class
self.picture = Picture(p, self.map.clipborders)
# Get the micaps files list
self.micapsfiles = []
# 3.9以上版本 .getchildren() 方法被清除
# micapsfiles = p.find("MicapsFiles").getchildren()
micapsfiles = list(p.find("MicapsFiles"))
for micapsfile in micapsfiles:
self.micapsfiles.append(MicapsFile(micapsfile))
except Exception as err:
print("【{0}】{1}-{2}".format(self.xmlfile, err, datetime.now()))
return None