File: README.md

package info (click to toggle)
metkit 1.15.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,380 kB
  • sloc: cpp: 16,089; sh: 2,532; python: 1,757; ansic: 71; makefile: 18
file content (28 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download | duplicates (2)
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
# pymetkit

This repository contains an Python interface to the MetKit library for parsing MARS requests. 

## Example

The function for parsing a MARS request is `metkit.parse_mars_request` which accepts a string or file-like object 
as inputs. A list of `metkit.mars.Request` instances are returned, which is a dictionary containing the keys and 
values in the MARS request and the attribute `verb` for the verb in the MARS request.

### From String
```
from metkit import parse_mars_request

request_str = "retrieve,class=od,date=20240124,time=12,param=129,step=12,target=test.grib"
requests = parse_mars_request(requests)

print(requests[0])
# verb: retrieve, request: {'class': ['od'], 'date': ['20240124'], 'time': ['1200'], 'param': ['129'], 'step': ['12'], 'target': ['test.grib'], 'domain': ['g'], 'expver': ['0001'], 'levelist': ['1000', '850', '700', '500', '400', '300'], 'levtype': ['pl'], 'stream': ['oper'], 'type': ['an']}
```

### From File 
If the MARS request is contained inside a file, e.g. test_requests.txt:
```
from metkit import parse_mars_request 

requests = parse_mars_request(open("test_requests.txt", "r"))
```