Example #1
0
def getdatefromwareki(wareki_text):
    wareki_text = wareki_text.replace(u"元年", u"1年")
    wareki_text = utils.numzentohan(wareki_text)
    wareki_text = utils.erasewhitespace(wareki_text)
    if 0 < wareki_text.find(u"("):
        m = warekiex_text_r.search(wareki_text)
    else:
        m = wareki_text_r.search(wareki_text)
    if m != None and m.lastindex == 4:
        name = m.string[m.start(1):m.end(1)]
        wanen = int(m.string[m.start(2):m.end(2)])
        mon = int(m.string[m.start(3):m.end(3)])
        day = int(m.string[m.start(4):m.end(4)])
        nengo = Nengo.get_by_key_name(name)
        return datetime.date(nengo.first + wanen - 1, mon, day)
    else:
        return None
Example #2
0
def getdatefromwareki(wareki_text):
    wareki_text = wareki_text.replace(u"元年", u"1年")
    wareki_text = utils.numzentohan(wareki_text)
    wareki_text = utils.erasewhitespace(wareki_text)
    if 0 < wareki_text.find(u"("):
        m = warekiex_text_r.search(wareki_text)
    else:
        m = wareki_text_r.search(wareki_text)
    if m != None and m.lastindex == 4:
        name  = m.string[m.start(1):m.end(1)]
        wanen = int(m.string[m.start(2):m.end(2)])
        mon = int(m.string[m.start(3):m.end(3)])
        day = int(m.string[m.start(4):m.end(4)])
        nengo = Nengo.get_by_key_name(name)
        return datetime.date(nengo.first + wanen -1, mon, day)
    else:
        return None
Example #3
0
def setnengo(nengo_year_text):
    nengo_year_text = nengo_year_text.replace(u"元年", u"1年")
    nengo_year_text = utils.numzentohan(nengo_year_text)
    nengo_year_text = utils.erasewhitespace(nengo_year_text)
    nengo_year_text = nengo_year_text.replace(u"(", u"")
    nengo_year_text = nengo_year_text.replace(u")", u"")
    m = set_nengo_r.search(nengo_year_text)
    if m != None and m.lastindex == 3:
        name = m.string[m.start(1):m.end(1)]
        wanen = int(m.string[m.start(2):m.end(2)])
        year = int(m.string[m.start(3):m.end(3)])
        first = year - wanen + 1
        nengo = Nengo.get_by_key_name(name)
        if nengo == None:
            nengo = Nengo(key_name=name, first=first)
            db.put(nengo)
            logging.info("Nengo:" + nengo.key().name() + str(nengo.first))
Example #4
0
def setnengo(nengo_year_text):
    nengo_year_text = nengo_year_text.replace(u"元年", u"1年")
    nengo_year_text = utils.numzentohan(nengo_year_text)
    nengo_year_text = utils.erasewhitespace(nengo_year_text)
    nengo_year_text = nengo_year_text.replace(u"(", u"")
    nengo_year_text = nengo_year_text.replace(u")", u"")
    m = set_nengo_r.search(nengo_year_text)
    if m != None and m.lastindex == 3:
        name  = m.string[m.start(1):m.end(1)]
        wanen = int(m.string[m.start(2):m.end(2)])
        year  = int(m.string[m.start(3):m.end(3)])
        first = year - wanen + 1
        nengo = Nengo.get_by_key_name(name)
        if nengo == None:
            nengo = Nengo(key_name=name, first=first)
            db.put(nengo)
            logging.info("Nengo:" + nengo.key().name() + str(nengo.first))