metradar 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cfg/config.py ADDED
@@ -0,0 +1,90 @@
1
+ # _*_ coding: utf-8 _*_
2
+
3
+ # Copyright (c) 2019 NMC Developers.
4
+ # Distributed under the terms of the GPL V3 License.
5
+
6
+ """
7
+ Read configure file.
8
+ """
9
+
10
+ import os
11
+ import datetime
12
+ import shutil
13
+ import configparser
14
+ from pathlib import Path
15
+
16
+
17
+ def _get_config_dir():
18
+ """
19
+ Get default configuration directory.
20
+ """
21
+ config_dir = Path.home() / ".nmcdev"
22
+ config_dir.mkdir(parents=True, exist_ok=True)
23
+ return config_dir
24
+
25
+ # Global Variables
26
+ CONFIG_DIR = _get_config_dir()
27
+
28
+
29
+ def _ConfigFetchError(BaseException):
30
+ pass
31
+
32
+
33
+ def _get_config_from_rcfile(rc='config_cassandra.ini'):
34
+ """
35
+ Get configure information from config_dk_met_io.ini file.
36
+ """
37
+ # rc = CONFIG_DIR / "config.ini"
38
+ # rc = 'config_met_io.ini'
39
+ if not os.path.exists(rc):
40
+ print(rc + ' not exists!')
41
+ return None
42
+ # if not rc.is_file():
43
+ # rc = Path("~/config_met_io.ini").expanduser()
44
+ try:
45
+ config = configparser.ConfigParser()
46
+ config.read(rc,encoding='utf-8')
47
+ except IOError as e:
48
+ raise _ConfigFetchError(str(e))
49
+ except BaseException as e:
50
+ raise _ConfigFetchError(str(e))
51
+
52
+ return config
53
+
54
+ # Global Variables
55
+ CONFIG = _get_config_from_rcfile()
56
+
57
+
58
+ def get_cache_file(sub_dir, filename, name=None, cache_clear=True):
59
+ """
60
+ Get the cache file pathname.
61
+
62
+ :param sub_dir: sub directory string.
63
+ :param filename: cache filename
64
+ :param name: cache name, like "MICAPS_DATA"
65
+ :param cache_clear: if True, clear old cache folder
66
+ """
67
+ # get cache file directory
68
+ if CONFIG.has_option('CACHE', 'CACHE_DIR'):
69
+ cache_dir = Path(CONFIG['CACHE']['CACHE_DIR']).expanduser() / "cache"
70
+ else:
71
+ cache_dir = CONFIG_DIR / "cache"
72
+
73
+ # Add cache name, if neccessary
74
+ if name is not None:
75
+ cache_dir = cache_dir / name
76
+
77
+ # Use the week number of year as subdir
78
+ cache_subdir1 = cache_dir / datetime.date.today().strftime("%Y%U")
79
+ cache_subdir2 = cache_subdir1 / sub_dir
80
+ cache_subdir2.mkdir(parents=True, exist_ok=True)
81
+
82
+ # clear old cache folders
83
+ if cache_clear:
84
+ for f in cache_dir.iterdir():
85
+ if f != cache_subdir1:
86
+ shutil.rmtree(f)
87
+
88
+ # return cache file pathname
89
+ cache_file = cache_subdir2 / filename
90
+ return cache_file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: metradar
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: radar data processing
5
5
  Author-email: Wenjian Zhu <kevin2075@163.com>
6
6
  Keywords: Weather,Radar
@@ -1,3 +1,4 @@
1
+ cfg/config.py,sha256=4Xu87Jlif1PgJ2TDE9yXtOfTZHPNNhU6FaY8fKlF9xw,2379
1
2
  metradar/__init__.py,sha256=ZVCYWH_GLhi0vIbCFFMJTzmReIpKmKMWLy0K-dreAF0,183
2
3
  metradar/cnrad_level2.py,sha256=vy4d-CCAigJGZrm-Dr3_NsmzSs1Tg_ufQvVSZSH57ic,44916
3
4
  metradar/comm_func.py,sha256=SByR9y5y9qdEcoDooSbEAN0Mxcw8QnPFN78n-s-INbg,4170
@@ -27,7 +28,7 @@ metradar/retrieve_micaps_server.py,sha256=cb-a_OKM1zCSw0tZ_Gk7RofE16RiRX6qq3oTUQ
27
28
  metradar/rose_structer.py,sha256=3EAZ18OXg0FXR4U1DNEvwU4gxP8mSRGkGUKjAW85IPs,25293
28
29
  metradar/trans_nc_pgmb.py,sha256=EfjaswKix4f8G-T1O6UKJ8lX9F_8z_IILucX_R2xdSk,1738
29
30
  metradar/trans_new_mosaic_nc.py,sha256=dZPr625hV7msFOgUVPwFgjTrTgQOEsIywMABzansPYA,9705
30
- metradar-0.1.4.dist-info/METADATA,sha256=dKxSj6JuCz3XDkYKNmusu6sb4cGYDdb0JOmJmbdx0lA,1274
31
- metradar-0.1.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
32
- metradar-0.1.4.dist-info/top_level.txt,sha256=vwxtTxux8rWm6wgfnwf0YWYrWjN16TZQCOy4h_OVwoE,9
33
- metradar-0.1.4.dist-info/RECORD,,
31
+ metradar-0.1.6.dist-info/METADATA,sha256=TiSeP9e4fz946YWiJwqeM0XJaORct6k-56-WCftiMTI,1274
32
+ metradar-0.1.6.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
33
+ metradar-0.1.6.dist-info/top_level.txt,sha256=Q9aint8WIIwNsgFnsl7Kmxj2y-gCth8uNliEFznjd-c,13
34
+ metradar-0.1.6.dist-info/RECORD,,