def parcels_street_finder(info_street_address, muni_id):
    from events import event
    from Levenshtein import ratio as lratio
    from parcels_in_muni_to_df import parcels_in_muni_to_df
    parcel_sel_df_for_matching = parcels_in_muni_to_df(muni_id)
    all_parcels_street = {}
    for item in parcel_sel_df_for_matching.transpose():
        e_parcel = event()
        raw_address = item[1]
        from all_address_parser import pars_street_name
        e_parcel.parcel_street_address = pars_street_name(raw_address)
        from all_address_parser import pars_house_number
        parcel_house_number = pars_house_number(raw_address)
        #from find_bad_strings import fix_range_house_numbers
        #house_number_range = fix_range_house_numbers(raw_address)
        #if house_number_range == parcel_house_number:
        #    e_parcel.parcel_house_number = parcel_house_number
        #else:
        #    e_parcel.parcel_house_number = house_number_range
        e_parcel.parcel_house_number = parcel_house_number
        e_parcel.parcel_mapcid = item[0]
        u_parcel_address = unicode(str(e_parcel.parcel_street_address).lower())
        u_info_street_address = unicode(str(info_street_address).lower())
        
        matcher = lratio(u_parcel_address, u_info_street_address)
         
        if matcher > 0.95:
            e_parcel.match_sn_lratio = matcher
            all_parcels_street.update({e_parcel.parcel_mapcid: e_parcel.parcel_house_number})
            print "levenstein ratio in making parcel street for ", u_info_street_address, " and ", u_parcel_address, ": ", matcher
        
    return all_parcels_street        
Exemple #2
0
def upcoming_events():
    page = event(dsn = app.config['dsn'])
    if request.method == 'GET':
        return page.open_page()
    elif 'initializeTable' in request.form:
        return page.init_table()
    elif 'addevent' in request.form:
        date = request.form['date']
        place = request.form['place']
        player1 = request.form['player1']
        player2 = request.form['player2']
        champ = request.form['champ']
        return page.addevent(date, place, player1, player2, champ)
    elif 'addtour' in request.form:
        cha = request.form['cha']
        year = request.form['year']
        players = request.form['players']
        games = request.form['games']
        return page.addtour(cha, year, players, games)
    elif 'deleteevent' in request.form:
        number = request.form['number']
        return page.deleteevent(number)
    elif 'deleteevent2' in request.form:
        champ = request.form['champ']
        return page.deleteevent_2(champ)
    elif 'deletetour' in request.form:
        number = request.form['number']
        return page.deletetour(number)
    elif 'deleteevent1' in request.form:
        date = request.form['date']
        place = request.form['place']
        return page.delete_event(date, place)
    elif 'deletetour1' in request.form:
        cha = request.form['cha']
        year = request.form['year']
        return page.delete_tour(cha, year)
    elif 'findevent' in request.form:
        number = request.form['number']
        return page.find_event(number)
    elif 'findevent2' in request.form:
        champ = request.form['champ']
        return page.find_event_2(champ)
    elif 'findtour' in request.form:
        number = request.form['number']
        return page.find_tour(number)
    elif 'findevent1' in request.form:
        date = request.form['date']
        place = request.form['place']
        return page.find_event_name(date, place)
    elif 'findtour1' in request.form:
        cha = request.form['cha']
        return page.find_tour_name(cha)
    else:
        return redirect(url_for('home_page'))
Exemple #3
0
def updatetour_page(key = None):
    page = event(dsn = app.config['dsn'])
    if request.method == 'GET':
        return page.open_updatetour(number = key)
    elif 'updatetour' in request.form:
        cha = request.form['cha']
        year = request.form['year']
        players = request.form['players']
        games = request.form['games']
        return page.tour_update(key, cha, year, players, games)
    else:
        return redirect(url_for('home_page'))
Exemple #4
0
 def build(self):
     self.main_widget = Builder.load_string(main_widget_kv)
     self.main_widget.ids.scr_mngr.transition = SwapTransition()
     self.main_widget.ids.scr_mngr.add_widget(home_screen())
     self.main_widget.ids.scr_mngr.add_widget(first_intro.kar())
     self.main_widget.ids.scr_mngr.add_widget(events.event())
     self.main_widget.ids.scr_mngr.add_widget(prof.profser())
     self.main_widget.ids.scr_mngr.add_widget(events.sponsers())
     self.main_widget.ids.scr_mngr.add_widget(feed.fed())
     self.main_widget.ids.scr_mngr.add_widget(Example())
     self.main_widget.ids.scr_mngr.add_widget(exmple())
     return self.main_widget
Exemple #5
0
def update_event_page(key = None):
    page = event(dsn = app.config['dsn'])
    if request.method == 'GET':
        return page.open_updateevent(number = key)
    elif 'updateevent' in request.form:
        date = request.form['date']
        place = request.form['place']
        player1 = request.form['player1']
        player2 = request.form['player2']
        champ = request.form['champ']
        return page.update_event(key, date, place, player1, player2, champ)
    else:
        return redirect(url_for('home_page'))
Exemple #6
0
def timeEventDispatch(man):
    # Time event
    week = int(time.strftime("%w", time.localtime(man.getCurrentTime())))
    if week <= 5:
        # 工作日计划事件
        if (weekdayEventTimeList.get(
                time.strftime("%H:%M:%S", time.localtime(
                    man.getCurrentTime()))) != None):
            eventType = weekdayEventTimeList.get(
                time.strftime("%H:%M:%S",
                              time.localtime(man.getCurrentTime())))
            newEvent = event(man.getCurrentTime(), eventType)
            eventQueue.append(newEvent)
    else:
        # 周末计划事件
        if (weekendEventTimeList.get(
                time.strftime("%H:%M:%S", time.localtime(
                    man.getCurrentTime()))) != None):
            eventType = weekendEventTimeList.get(
                time.strftime("%H:%M:%S",
                              time.localtime(man.getCurrentTime())))
            newEvent = event(man.getCurrentTime(), eventType)
            eventQueue.append(newEvent)
Exemple #7
0
import pygame
pygame.init()
import events as ev

import world as w
world = w.World()
#world.makeGrid(3,2)
world.worldGen()

import render as r
r.world = world
r.renderInit()
r.renderFirst()

while ev.running:
    for event in pygame.event.get():
        ev.event(event)
    world.tick()
    r.renderTick()
Exemple #8
0
def enviromentEventDispatch(man):
    # 不在家时不分配事件
    if (not person.isInHome()):
        return

    # 温度不适宜时开启空调调整温度
    if ((not man.getSimT().isTemperatureBeenSet())
            and (man.getSimT().getCurrentTemperature() < 18
                 or man.getSimT().getCurrentTemperature() > 28)):
        percent = timeSlot * 1.0 / (100 * 60) * man.getVigour()
        if (man.isSleeping()):
            percent *= 0.001
        if (random.uniform(0, 100) < percent):
            newEvent = event(man.getCurrentTime(), "adjustTemprature")
            eventQueue.append(newEvent)

    # 随机关闭空调
    if (man.isInHome() and (not man.isSleeping())
            and man.getSimT().isTemperatureBeenSet()):
        deltaTime = man.getCurrentTime() - man.getSimT().getTimeSetTemperature(
        )
        if (deltaTime > 20 * 60):
            currentTemperature = man.getSimT().getCurrentTemperature()
            if (currentTemperature > 24 and currentTemperature < 26):
                # 依概率关闭空调
                percent = timeSlot * 1.0 / (400 * 60) * man.getVigour()
                # fp.write( time.strftime("%H:%M:%S", time.localtime(person.getCurrentTime())) + '	 %f\n' %percent)
                if (random.uniform(0, 100) < percent):
                    newEvent = event(man.getCurrentTime(),
                                     "turnOffAirCondition")
                    eventQueue.append(newEvent)

    # 湿度不适宜时开启加湿器

    # 光照过暗时开灯
    if (man.isInHome() and not man.isSleeping()):
        tempRoom = man.getNowRoom()
        if (tempRoom.isDarkness(man.getCurrentTime())):
            if (random.randint(0, 100) < 98):
                newEvent = event(man.getCurrentTime(), "turnOnLampInRoom")
                eventQueue.appendleft(newEvent)

    # 关掉不在的房间的灯
    if (man.isInHome() and not man.isSleeping()):
        percent = timeSlot * 1.0 / (3 * 60) * man.getVigour()
        if (random.uniform(0, 100) < percent):
            newEvent = event(man.getCurrentTime(), "turnOffOtherRoomLamp")
            eventQueue.appendleft(newEvent)

    # 如果当前没有事情,随机找事情做
    if (man.isInHome() and not man.isSleeping()):
        if (len(eventQueue) == 0):
            percent = timeSlot * 1.0 / (random.randint(20, 50) *
                                        60) * man.getVigour()
            if (random.uniform(0, 100) < percent):
                randomEventList = [
                    'readBook', 'watchTV', 'playVideoGame', 'defaultEvent'
                ]
                eventNum = random.randint(0, len(randomEventList) - 1)
                newEvent = event(man.getCurrentTime(),
                                 randomEventList[eventNum])
                eventQueue.append(newEvent)

    # 事件队列为空时,随机去卫生间
    if (man.isInHome() and not man.isSleeping()):
        if (len(eventQueue) == 0):
            percent = timeSlot * 1.0 / (random.randint(30, 700) *
                                        60) * man.getVigour()
            if (random.uniform(0, 100) < percent):
                newEvent = event(man.getCurrentTime(), "toiletStart")
                eventQueue.append(newEvent)