コード例 #1
0
ファイル: main.py プロジェクト: Olczix/DataGenerator
def generate_offers_data_t2(file_name):
    with open(file_name, 'w', encoding='utf-8') as file:
        for i in range(0, number_of_offers):
            if i % 10 == 0:
                offers[i].set_participants(offers[i].get_participants() +
                                           random.randint(1, 10))
            file.write(offers[i].csv_format() + '\n')

        for i in range(0, int(number_of_offers / 10)):
            offer_id = number_of_offers + i + 1
            hotel_id = random.choice(hotels).get_id()
            flight_id = random.choice(flights).get_id()
            attraction_pack_id = random.choice(attraction_packs).get_id()
            max_participants_number = random.randint(50, 150)
            participants = random.randint(1, max_participants_number)
            hotel_price = random.choice(prices)
            hotel_rating = round(random.uniform(1.0, 5.0), 2)
            flight_price = random.choice(prices)
            flight_rating = round(random.uniform(1.0, 5.0), 2)
            attraction_pack_price = random.choice(prices)
            attraction_pack_rating = round(random.uniform(1.0, 5.0), 2)
            overall_rating = round(
                (hotel_rating + flight_rating + attraction_pack_rating) / 3.0,
                2)

            offer = Offer(offer_id, hotel_id, flight_id, attraction_pack_id,
                          max_participants_number, participants,
                          overall_rating, hotel_price, hotel_rating,
                          flight_price, flight_rating, attraction_pack_price,
                          attraction_pack_rating)
            offers.append(offer)

            file.write(offer.csv_format())
            if i != int(number_of_offers / 10) - 1:
                file.write('\n')
コード例 #2
0
ファイル: main.py プロジェクト: Szynal/PWR-W4-INF
def addOffer():
    name = request.args.get("name")
    nick = request.args.get("nick")

    offers.append(Offer(name,nick))

    for user in users:
        if user.getNick() == nick:
            save()
            return 'Dodano oferte'

    newUser = User(nick)
    users.append(newUser)
    save()
    return 'Dodano oferte'
コード例 #3
0
ファイル: DDSP.py プロジェクト: CharKwayTeow/ddsp
 def handleDiscoveryAndQueryMessage(incomeMessage, ip_addr):
     # check the resource table, if find the record, send an offer
     for fid in incomeMessage.records:
         for record in self.resourceTable.records:
             if record.status == 0 and record.fid == fid:
                 # send an offer
                 offer = Offer()
                 offer.addRecord(record.fid)
                 offer.send(ip_addr, self.port, self.interface)
                 break
コード例 #4
0
ファイル: Franchise.py プロジェクト: Torminator/NBAOffseason
    def evaluateBestTeam(self, freeAgents):
        workingTeam = []
        # add our players to the array
        for p in self.__players:
            tmp = []
            tmp.append(p)
            workingTeam.append(tmp)

        # add all free agents who play a position which is not fulfilled right now
        for pos in self.getFreePosition():
            tmp = []
            for p in freeAgents:
                if p.getPos() == pos:
                    tmp.append(p)
            workingTeam.append(tmp)
        maxvalue = 0.0
        team = []
        for p1 in workingTeam[0]:
            for p2 in workingTeam[1]:
                for p3 in workingTeam[2]:
                    for p4 in workingTeam[3]:
                        for p5 in workingTeam[4]:
                            if p1.getWage() + p2.getWage() + p3.getWage(
                            ) + p4.getWage() + p5.getWage() <= Franchise.__cap:
                                offr = math.sqrt(
                                    1 / 5 *
                                    (p1.getOffRating() * p1.getOffRating() +
                                     p2.getOffRating() * p2.getOffRating() +
                                     p3.getOffRating() * p3.getOffRating() +
                                     p4.getOffRating() * p4.getOffRating() +
                                     p5.getOffRating() * p5.getOffRating()))
                                defr = math.sqrt(
                                    1 / 5 *
                                    (p1.getDefRating() * p1.getDefRating() +
                                     p2.getDefRating() * p2.getDefRating() +
                                     p3.getDefRating() * p3.getDefRating() +
                                     p4.getDefRating() * p4.getDefRating() +
                                     p5.getDefRating() * p5.getDefRating()))
                                teamvalue = math.sqrt(defr * offr)
                                if teamvalue > maxvalue:
                                    maxvalue = teamvalue
                                    team = [p1, p2, p3, p4, p5]
        offer = Offer(self)
        for p in team:
            if p not in self.__players:
                p.addOffer(offer)
        return team
コード例 #5
0
import logging
import matcher

##############################################################################################################################################################################
# Start command
##############################################################################################################################################################################

# This is the Start command (/start).
# In the Start Command, the bot will ask the user about his basic information which include:
# firstname, lastname, birthdate, phonenumber, address, location
# these info will be stored in a Class User and then they will be stored in the database

# Class User
u1 = User()
c1 = Campaign()
offer = Offer()
request = []

# These are the states  of the Start command
CHOOSING, PHONE_NUMBER, PHONE_NUMBER_YN, BIRTHDATE, BIRTHDATE_YN, ADDRESS, ADDRESS_YN, LOCATION, CONCLUDE , MENU, WELCOME, ACTIONS, \
OFFER_TYPE, OFFER_DESCRIPTION, OFFER_QUANTITY, OFFER_done, REQUEST_TYPE, REQUEST_DESCRIPTION, REQUEST_QUANTITY, REQCASH_ESTIMATE, \
REQUEST_NOTED, NEW_VOLUNTEER, CHOOSE_VALUES_TO_UPDATE, U_ADDRESS, U_LOCATION, START_DELIVERY, DELIVERY_SUCCESS, DELIVERY_FAILURE, CHOOSE_DONATION, \
CHOOSE_OFFER, SAVE_OFFER, ASK_OFFER_ID, DELIVER_NEEDS, UPDATE_NEED, ASK_NEED_ID,NEW_DONATION_TYPE, ESTIMATING_NEW_DONATION_VALUE, NEW_REQUEST_TYPE, \
ESTIMATING_NEW_NEED_VALUE, GO_MENU, CHOOSE_CONFIRM, RECEIVED_NEED, NOT_RECEIVED_NEED, START_CAMP, CAMP_NAME, CAMP_D, CAMP_L, CONCLUDE_CAMP = \
    range(48)


def actions(update: Update, context: CallbackContext) -> int:
    reply_keyboard = [['Donate'], ['Volunteer'], ['Request'], ['Nothing'],
                      ['Show Offers'], ['Updates on pickups'], ['Show Needs'],
                      ['Update on Delivered Needs'], ['Create Campaign']]
コード例 #6
0
def createOffer():
    '''
    Create the offer
    '''

    offerId = str(ObjectId())
    userId = request.get_json().get("userId", None)

    if offerId == None or userId == None:
        logging.error(
            "The offer ID, the user ID or the project title is undefined")
        abort(make_response("The offer ID, the user ID is undefined", 500))

    offer = Offer(offerId, userId)

    # minimal requierements

    projectTitle = request.get_json().get("projectTitle", None)
    fieldActivity = request.get_json().get('fieldActivity', None)
    place = request.get_json().get('place', None)
    enterpriseLogo = request.get_json().get('entrepriseLogo', None)
    networking = request.get_json().get('networking', None)
    projectDate = request.get_json().get('projectDate', None)
    contact = request.get_json().get('contact', None)

    # Data

    if projectTitle is not None:
        offer.projectTitle = projectTitle
    if fieldActivity is not None:
        offer.fieldActivity = fieldActivity
    if place is not None:
        offer.place = place
    if networking is not None:
        offer.networking = networking
    if projectDate is not None:
        offer.projectDate['begin'] = projectDate['begin']
        offer.projectDate['end'] = projectDate['end']
    if contact is not None:
        offer.contact['name'] = contact['name']
        offer.contact['phone'] = contact['phone']
        offer.contact['mail'] = contact['mail']

    config.offerTable.insert(offer.__dict__)
    requestResult = config.offerTable.find_one({"offerId": offerId})
    return mongodoc_jsonify(requestResult)