#!/usr/bin/python

'''
crude script to decode VNOTE *.vnt files produced by Android's stock Memo app.
this code is public domain.
'''

import sys
import re

filename = sys.argv[1]
f = open(filename,"r")

note_text = ''
for line in f:
	blocks = line.split("=")
	for block in blocks:
		if re.search('^[0-9A-F][0-9A-F]\s*$',block):
			note_text += chr(eval('0x'+block))
	if re.search('^DCREATED:',line):
		date = line[9:]
		creation_date = '%s-%s-%s %s:%s' % (date[0:4],date[4:6],date[6:8],date[9:11],date[11:13])
	if re.search('^LAST-MODIFIED:',line):
		date = line[14:]
		modified_date = '%s-%s-%s %s:%s' % (date[0:4],date[4:6],date[6:8],date[9:11],date[11:13])

print "\n==========================="
print "Created: "+creation_date
print "Modified: "+modified_date
print "==========================="
print note_text
print "===========================\n"
