nooz/note.py

35 lines
1020 B
Python

from delorean import Delorean
from delorean import parse
class Note:
def __init__(self, datestring, author, subject, pages):
self.date = convert_datestring_to_date(datestring)
self.author = author
self.subject = subject
self.pages = pages
class Page:
def __init__(self, source, tags):
self.source = source
self.tags = tags
def convert_datestring_to_date(datestring):
day = ""
if datestring[0:2].isdigit():
day = datestring[0:2]
else:
day = "0" + datestring[0:1]
months = {"stycznia" : "01", "lutego" : "02", "luty" : "02", "marca" : "03", "kwietnia" : "04", "maja" : "05", "czerwca" : "06",
"lipca" : "07", "sierpnia" : "08", "wrzesnia" : "09", "padziernik": "10", "padziernika" : "10", "listopada" : "11", "grudnia" : "12"}
month = ""
for m in months.keys():
if m in datestring:
month = months[m]
if datestring[-4:].isdigit():
year = datestring[-4:]
else:
year = "2013"
if month == "":
month = "01"
date = parse("-".join([year, month, day]))
return date