예제 #1
0
 def get_houses_for_user(self, user_id):
     houses = self.collection.find({'user_id': user_id})
     target_houses = []
     logging.debug("Found {} houses".format(houses.count()))
     for house in houses:
         target_houses.append(House(house['_id'], house['user_id'], house['name']))
     return target_houses
예제 #2
0
def main():
    """ Main function to play continuously."""
    name = input("Please enter your name: ")
    cardDeck = createDeck()
    if not name.isalpha():
        player = RegularPlayer([cardDeck.pop(), cardDeck.pop()])
    else:
        player = RegularPlayer([cardDeck.pop(), cardDeck.pop()], name + "'s")
    house = House([cardDeck.pop(), cardDeck.pop()])
    play(player, house, cardDeck)
    while (True):
        if not player.isBroke():
            action = input("Do you want to play another time?(y/n):\n>")
            if action.upper() == 'Y':
                cardDeck = createDeck()
                player.play([cardDeck.pop(), cardDeck.pop()])
                house.play([cardDeck.pop(), cardDeck.pop()])
                play(player, house, cardDeck)
            else:
                print("See you soon again!")
                return
        else:
            print("You're out of money! Maybe next time!")
            return
예제 #3
0
 def get_all_houses(self):
     houses = self.collection.find()
     target_houses = []
     for house in houses:
         target_houses.append(House(house))
     return target_houses
예제 #4
0
 def get_houses_for_user(self, user_id):
     houses = self.collection.find({'user_id': user_id})
     target_houses = []
     for house in houses:
         target_houses.append(House(house))
     return target_houses
예제 #5
0
 def get_house_by_id(self, house_id):
     house = self.collection.find_one({'_id': house_id})
     if house is None:
         return None
     target_house = House(house)
     return target_house
예제 #6
0
 def get_all_houses(self):
     houses = self.collection.find()
     target_houses = []
     for house in houses:
         target_houses.append(House(house['_id'], house['user_id'], house['name']))
     return target_houses
예제 #7
0
 def get_house_by_id(self, house_id):
     house = self.collection.find_one({'_id': house_id})
     target_house = House(house['_id'], house['user_id'], house['name'])
     return target_house
예제 #8
0
	def getattr_other(self):
		disposals_dom = self.dom.find('ul',{'class':'house-disposal'}).find_all('li')
		self.data['disposals'] = []
		for disposal_dom in disposals_dom:
			self.data['disposals'].append(disposal_dom.get_text())
		

	def getattr_desc(self):
		self.data['title'] = self.dom.find('div',{'class':'house-title'}).find('h1').get_text()
		self.data['address'] = self.dom.find('span',{'class':'dz'}).get_text()
		self.data['rent_type'] = self.dom.find('ul',{'class':'f14'}).find_all('li')[0].find_all('span')[1].get_text()
		self.data['huxing'] = self.dom.find('ul',{'class':'f14'}).find_all('li')[1].find_all('span')[1].get_text()
		self.data['orientation'] = self.dom.find('ul',{'class':'f14'}).find_all('li')[2].find_all('span')[1].get_text()
		self.data['village'] = self.dom.find('ul',{'class':'f14'}).find_all('li')[2].find_all('span')[1].get_text()
		self.data['content'] = self.dom.find('span',{'class':'a2'}).get_text()


class SerializeMogo(Serialize):
	model = House

	def getattr_info(self,bsdom):
		self.data['title'] = bsdom.find('span',{'class':'spacer-m-r10 room-info-tit'}).get_text()

	def getattr_area(self,bsdom):
		self.data['room_area'] = bsdom.find('div',{'class':'room-rs'}).find('ul').get_text()

if __name__ == '__main__':
	h = House()
	s = HouseSerialize('sdf')
	d = s.get()
	print(d)