forked from flashlxy/PyMICAPS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.py
54 lines (42 loc) · 1.18 KB
/
Main.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
49
50
51
52
53
54
# -*- coding: utf-8 -*-
#
# Author: Liu xianyao
# Email: [email protected]
# Update: 2017-04-06
# Copyright: ©江西省气象台 2017
# Version: 1.1.20170406
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from itertools import takewhile
import time as ttime
def parseInt(s):
"""
全局函数 字符串转整数
:param s: 字符串
:return: 整数
"""
assert isinstance(s, basestring)
return int(''.join(list(takewhile(lambda x: x.isdigit(), s)))) if s[0].isdigit() else None
def main(debug):
"""
主程序
:param debug:
:return:
"""
if debug:
xml = r'config.xml'
else:
if len(sys.argv) < 2:
print(u'参数不够,至少需要一个xml文件名参数')
sys.exit()
xml = sys.argv[1]
start = ttime.clock()
from Products import Products
products = Products(xml)
if products is not None:
products.micapsdata.Draw(products, debug)
print('Micaps data contour and save picture seconds:', ttime.clock() - start)
if __name__ == '__main__':
ISDEBUG = True
main(ISDEBUG)