コード例 #1
0
ファイル: city.py プロジェクト: mor1s99/mor1s
    def populate(self, *args, **kwargs):
        """
        """

        for key in [
                'city_entities', 'blocked_areas', 'tilesets', '__class__',
                'unlocked_areas'
        ]:
            kwargs.pop(key, None)

        buildings = kwargs.pop('entities')

        # Buildings

        for raw_building in buildings:

            if raw_building['type'] in ['production', 'residential', 'goods']:

                building = self.session.query(Building).get(raw_building['id'])
                if not building:
                    building = Building(city=self)

                building.update(**raw_building)

        return super(City, self).populate(*args, **kwargs)
コード例 #2
0
ファイル: building_test.py プロジェクト: rachillesf/terminus
 def test_accept(self):
     vertices = [Point(0, 0, 0), Point(0, 1, 0), Point(1, 0, 0)]
     building = Building(Point(0, 0, 0), vertices)
     generator_mock = mock.Mock()
     calls = [mock.call.start_building(building), mock.call.end_building(building)]
     building.accept(generator_mock)
     generator_mock.assert_has_calls(calls)
コード例 #3
0
    def __build_model_objs(self, course) -> set():
        """Use building-related fields to construct a Building Object"""

        room_capacity = course['maximumEnrollment']
        school_name = 'Northeastern University'
        for elem in course['meetingsFaculty']:
            meeting_time = elem['meetingTime']

            # Skip any course slots that are for Final Exams
            if meeting_time[
                    'meetingTypeDescription'] == 'Final Exam' or not meeting_time[
                        'beginTime']:
                continue

            # Buildings can just be created and added to the set
            building = Building(name=meeting_time['buildingDescription'],
                                slug=meeting_time['building'],
                                school_name=school_name,
                                school_id=1)
            self.buildings.add(building)

            # same for Classrooms
            classroom = Classroom(room_number=meeting_time['room'],
                                  building_name=meeting_time['building'],
                                  school_name=school_name,
                                  school_id=1,
                                  capacity=room_capacity)
            self.classrooms.add(classroom)

            # CourseSlots are based on both time of day and day of week
            # i.e. a `meeting_time` object can have multiple CourseSlots in it
            # Helper method to create the individual slots
            self.__create_course_slots(meeting_time)

        return self.__convert_to_csvs()
コード例 #4
0
ファイル: server.py プロジェクト: mehmetaltuner/sispp
def bu_cr():
    if not session["logged_in"] or not session.get("person")["admin"]:
        return redirect(url_for("bu_page"))
    db = Database()
    data = request.form
    building = Building(data["name"], data["code"], data["campus"])
    db.add_building(building)

    return redirect(url_for("bu_page"))
コード例 #5
0
 def setUp(self):
     self.dojo = Building(office_names, living_space_names, input_file)
     self.allocated_offices, self.office_unallocated \
         = self.dojo.allocate_room(self.dojo.all_employees,
             self.dojo.offices)
     self.allocated_living_spaces, self.ls_unallocated \
         = self.dojo.allocate_room(self.dojo.fellows,
             self.dojo.living_spaces)
     self.dojo.print_office_allocation()
     self.dojo.print_living_space_allocation()
コード例 #6
0
 def test_can_access_employees_from_input(self):
     """
     Tests if employee details in input file are accessed and objects created
     """
     self.assertIsNotNone(self.dojo.all_employees)
     self.assertIsInstance(self.dojo.all_employees[0], Person)
     self.assertEquals('<type \'str\'>',
                       str(type(self.dojo.all_employees[0].name)))
     self.assertEquals(
         '<type \'bool\'>',
         str(type(self.dojo.all_employees[0].is_allocated_office)))
     self.dojo = Building(office_names, living_space_names, empty_file)
     self.assertEquals(False, self.dojo.access_employees()[0])
コード例 #7
0
    def crawl_building(self):
        """
        Building class를 생성할 data crawling
        """
        driver = self.client.driver
        # Building Class의 속성
        building_name = driver.find_elements_by_class_name("heading")[7].text
        deal_count = driver.find_elements_by_class_name("txt_price")[0].text
        tnant_count = driver.find_elements_by_class_name("txt_price")[1].text
        rent_count = driver.find_elements_by_class_name("txt_price")[2].text
        land_address = driver.find_element_by_class_name(
            "p_address_place._addr").text
        road_address = driver.find_element_by_class_name(
            "p_address_road._road_addr").text[8:]
        category = driver.find_element_by_class_name(
            "label_detail.label_detail--positive").text[:-3]

        if category == "아파트":
            category = "APT"
        elif category == "오피스텔":
            category = "OPT"

        try:
            # 최근에 매매된 기록이 있는지 판단 (class name이 data인 배열에 '최근 거래가'요소 추가로 인덱스 밀림)
            whether_deal_recently = driver.find_element_by_class_name("date")

            # 최근에 매매된 기록이 있을 때
            household_info = driver.find_elements_by_class_name("data")[3].text
            built_year = driver.find_elements_by_class_name("data")[6].text
        except:
            # 최근에 매매된 기록이 없을 때
            household_info = driver.find_elements_by_class_name("data")[2].text
            built_year = driver.find_elements_by_class_name("data")[5].text

        # 크롤링 된 내용 가공
        total_dong, total_household = self.split_household_info(household_info)

        building = Building(
            name=building_name,
            category=category,
            deal_count=deal_count,
            tnant_count=tnant_count,
            rent_count=rent_count,
            built_year=built_year,
            total_dong=total_dong,
            total_household=total_household,
            land_address=land_address,
            road_address=road_address,
        )

        return building
コード例 #8
0
ファイル: index.py プロジェクト: mixartemev/yarealty
def main():
    current_page = args.page_number
    try:
        print("Processing page {}...".format(current_page))
        result = make_request(args, current_page)

        if 'error' in result:
            exit()

        res = result['response']['search']['offers']['entities']
        # res = list(filter(lambda r: r['building'].get('buildingId'), res))
        for e in convert(res):
            session.merge(Author(*e['author']))
            if e['site']:
                session.merge(Site(*e['site']))
            if e['building']:
                session.merge(Building(*e['building']))
                nbid = None
            else:
                nb = session.merge(NewBuilding(*e['new_building']))
                session.commit(
                )  # todo it's working now only for new buildings autoinc IDs
                nbid = nb.id
            o = (nbid, ) + e['offer']
            session.merge(Offer(*o))
            # session.merge(Photo(*e['photo']))
        # for ent in res:
        #     session.merge(Offer(
        #         ent['offerId'],
        #         ent['active'],
        #         ent['area']['value'],
        #         ent['building'].get('houseId')
        #     ))

        session.commit()
        current_page += 1
        print("Waiting {0} seconds".format(args.delay))
        time.sleep(args.delay)
    except Exception as e:
        print(e)
        print("Unknown exception, waiting 60 seconds.")
        time.sleep(60)
    except KeyboardInterrupt:
        print("Finishing...")
        exit()
    print("Done")
コード例 #9
0
 def _create_buildings(self, city):
     '''
     Iterate the ways to find the buildings data and create model buildings
     with it.
     '''
     for key, value in self.osm_ways.iteritems():
         tags = value['tags']
         if 'building' in tags:
             vertices = []
             for ref in value['refs']:
                 ref_lat = self.osm_coords[ref]['lat']
                 ref_lon = self.osm_coords[ref]['lon']
                 ref_pair = LatLon(ref_lat, ref_lon)
                 vertex = self._translate_coords(ref_pair)
                 vertices.append(vertex)
             if 'height' in value:
                 height = value['height']
             else:
                 height = 20
             building = Building(Point(0, 0, 0), vertices, height=height)
             city.add_building(building)
コード例 #10
0
 def create_building(self, location):
     building = Building(location=location)
     return self.db.put_building(building)
コード例 #11
0
ファイル: play.py プロジェクト: salvamoyafernandez/elevators
 def __init__(self, floors, elevators, requests):
     self.floors = floors
     self.elevators = elevators
     self.requests = requests
     self.building = Building(self.floors, self.elevators)
コード例 #12
0
 def setUp(self):
     self.building = Building(5, 3)
コード例 #13
0
ファイル: building_test.py プロジェクト: rachillesf/terminus
 def test_bounding_box_with_not_convex_base_building(self):
     building = Building(Point(0, 0),
                         [Point(-15, 0), Point(10, -40), Point(0, 0), Point(15, 30)])
     self.assertEqual(building.bounding_box(), BoundingBox(Point(-15, -40), Point(15, 30, 10)))
コード例 #14
0
ファイル: building_test.py プロジェクト: rachillesf/terminus
 def test_bounding_box_with_pentagonal_base_building(self):
     building = Building(Point(10, 20), [Point(-10, -20), Point(10, -30),
                         Point(20, 10), Point(-5, 30), Point(-20, 5)])
     self.assertEqual(building.bounding_box(),
                      BoundingBox(Point(-10, -10), Point(30, 50) + Point(0, 0, 10)))
コード例 #15
0
ファイル: building_test.py プロジェクト: rachillesf/terminus
 def test_bounding_box(self):
     building = Building(Point(10, 20), [Point(15, 30), Point(15, -5),
                                         Point(40, 30), Point(40, -5)], 15)
     self.assertEqual(building.bounding_box(),
                      BoundingBox(Point(25, 15), Point(50, 50, 15)))
コード例 #16
0
# description    :Allocates persons to rooms in a building
# author         :Stanley Ndagi
# email          :[email protected]
# date           :20160108
# version        :0.0.1
# python_version :2.7.10
# =====================================================================
import os
import sys

from models.building import Building

living_space_names = ['Rm1', 'Rm2', 'Rm3', 'Rm4', 'Rm5', 'Rm6', 'Rm7', 'Rm8',
    'Rm9', 'Rm10']
office_names = ['Hogwarts', 'Valhalla', 'Oculus', 'Krypton', 'Shire', 'Narnia',
    'Camelot', 'Mordor', 'Round Table', 'Midgar']

if len(sys.argv) > 1:
    file_name = sys.argv[1]

else:
    file_name = "files/employees.txt"

if __name__ == '__main__':
    dojo = Building(office_names, living_space_names, file_name)
    dojo.print_office_allocation()
    dojo.print_living_space_allocation()
    dojo.print_unallocated_employees()
    dojo.print_allocation_for_one_room('Shire')
    dojo.print_allocation_for_one_room('Rm1')
コード例 #17
0
 def get_building(self, location):
     building_data = self.db.get_building(location)
     if not building_data:
         return None
     return Building(**building_data)