forked from flashlxy/PyMICAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Title.py
36 lines (31 loc) · 1.31 KB
/
Title.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
# -*- coding: utf-8 -*-
#
# Author: Liu xianyao
# Email: [email protected]
# Update: 2017-04-06
# Copyright: ©江西省气象台 2017
# Version: 1.1.20170406
from __future__ import print_function
from __future__ import print_function
from HeadDesc import HeadDesc
from Main import parseInt
from Projection import Projection
class Title:
def __init__(self, root):
p = root.find("Title")
# 是否按Micaps数据的标题写产品描述
self.mtitleposition = Projection.leaf_to_list(p, "MTitlePosition", None)
# 产品图片文字描述(可能多个)
descs = p.find("Descs").getchildren()
self.descs = []
for desc in descs:
txt = Projection.leaf_to_string(desc, 'Text', u'测试数据')
pos = Projection.leaf_to_list(desc, "Position", [113.2, 30.5])
fonts = desc.find("Font").text.strip().split(',')
font = {'family': 'monospace', 'weight': 'bold', 'fontsize': 12, 'color': 'k'}
if len(fonts) == 4:
font['fontsize'] = parseInt(fonts[0].strip())
font['family'] = fonts[1]
font['weight'] = fonts[2]
font['color'] = fonts[3]
self.descs.append(HeadDesc(txt, pos, font))