Patches: parseOvpn.py

File parseOvpn.py, 627 bytes (added by plaisthos, 5 years ago)
Line 
1#! /usr/bin/python
2
3import email
4import email.utils
5import sys
6import time
7
8gmane='http://news.gmane.org/find-root.php?message_id=%s'
9
10lineformat='|| %(date)s ||[[%(url)s| %(title)s ]] || %(author)s || || ||'
11
12def main():
13    msg = email.message_from_file(sys.stdin)
14
15    d= {}
16
17    d['url'] = gmane % msg['Message-Id']
18    d['title'] = msg['Subject'].replace( '\t',"").replace('\n',"")
19    d['title'] = d['title'].replace('[Openvpn-devel] ',"")
20
21    t = email.utils.parsedate(msg['Date'])
22    d['date'] = time.strftime("%Y-%m-%d",t)
23    d['author'] = msg['From']
24
25    print lineformat % d
26
27if __name__=='__main__':
28    main()