Esempio n. 1
0
 def handle(self, bot, update, user_data):
     user = str(update.message.from_user.id)
     handle1 = update.message.text
     name1 = user_data['name']
     code1 = user_data['code']
     rating_obj = ratings.Rating()
     all_data = rating_obj.getAllData(code1, handle1)
     if all_data is None:
         update.message.reply_text('wrong id')
         user_data.clear()
         return ConversationHandler.END
     conn = sqlite3.connect(self.mount_point + 'coders1.db')
     c = conn.cursor()
     c.execute(
         "INSERT OR IGNORE INTO datas (id, name, " + code1 +
         ") VALUES (?, ?, ?)", (user, name1, all_data))
     c.execute(
         "INSERT OR IGNORE INTO handles (id, name, " + code1 +
         ") VALUES (?, ?, ?)", (user, name1, handle1))
     if c.rowcount == 0:
         c.execute(
             "UPDATE datas SET " + code1 +
             " = (?) , name= (?) WHERE id = (?) ", (all_data, name1, user))
         c.execute(
             "UPDATE handles SET " + code1 +
             " = (?) , name= (?) WHERE id = (?) ", (handle1, name1, user))
     if code1 == 'SP':
         c.execute("INSERT OR IGNORE INTO priority (id) VALUES(?)",
                   (user, ))
     else:
         rating = rating_obj.parse_rating(code1, all_data)
         c.execute(
             "INSERT OR IGNORE INTO priority (id," + code1 +
             ") VALUES(?, ?)", (user, rating))
         if c.rowcount == 0:
             c.execute(
                 "UPDATE  priority SET " + code1 + " = (?) WHERE id = (?) ",
                 (rating, user))
     conn.commit()
     # BELOW LINES ARE USED TO CREATE XLSX FILES OF ALL SORTS OF RANKLIST
     # SO WHEN USER ASKS FOR RANKLIST THERE IS NO DELAY
     mysel = c.execute(
         "SELECT datas.name, datas.HE, datas.HR, datas.SP, datas.CF, datas.CC FROM datas INNER JOIN priority ON datas.id=priority.id ORDER BY CAST(priority.CF AS FLOAT) DESC, CAST(priority.CC AS FLOAT) DESC, CAST(priority.HR AS FLOAT) DESC, CAST(priority.HE AS FLOAT) DESC"
     )
     Utility.xlsx_creator(mysel, self.mount_point + 'all.xlsx')
     if code1 == 'SP':
         mysel = c.execute("SELECT name, " + code1 + " FROM datas")
         Utility.xlsx_creator(mysel, self.mount_point + code1 + ".xlsx")
     else:
         mysel = c.execute(
             "SELECT datas.name, datas." + code1 +
             " FROM datas INNER JOIN priority ON datas.id=priority.id ORDER BY CAST(priority."
             + code1 + " AS FLOAT) DESC")
         Utility.xlsx_creator(mysel, self.mount_point + code1 + ".xlsx")
     conn.close()
     update.message.reply_text("Succesfully Registered")
     update.message.reply_text(name1 + "    \n" + all_data)
     user_data.clear()
     return ConversationHandler.END
Esempio n. 2
0
 def __init__(self, mount_point, fallback):
     self.mount_point = mount_point
     self.fallback = fallback
     self.rating_obj = ratings.Rating()
     self.utility = Utility(mount_point)
     self.conv_handler = ConversationHandler(
         entry_points=[CommandHandler('update', self.updatesel)],
         allow_reentry=True,
         states={
             UPDA:
             [CallbackQueryHandler(self.updasel, pattern=r'\w*upd5\b')]
         },
         fallbacks=[fallback])
Esempio n. 3
0
 def __init__(
     self,
     ident=None,
     name=None,
     cou=None,
     birth_date=None,
     lefty: Optional[bool] = None,
     disp_names=None,
 ):
     self.ident = ident
     self.name = co.to_ascii(name.strip()) if name is not None else None
     self.cou = co.to_ascii(cou.strip()) if cou else None
     self.rating = ratings.Rating()
     self.birth_date = birth_date
     self.lefty: Optional[bool] = lefty
     self.disp_names = disp_names
Esempio n. 4
0
 def player_load(prefix: str, player: tennis.Player):
     player.ident = dct.get(prefix + "_player_id")
     player.name = dct.get(prefix + "_player_name")
     player.rating = ratings.Rating(dct.get(prefix + "_player_rating"))
     ymd = dct.get(prefix + "_player_bdate")
     if ymd is not None:
         player.birth_date = datetime.date(ymd[0], ymd[1], ymd[2])
     setattr(
         self,
         "hist_" + prefix + "_srv_win",
         rl.SizedValue(*dct[prefix + "_hist_srv_win"]),
     )
     setattr(
         self,
         "hist_" + prefix + "_rcv_win",
         rl.SizedValue(*dct[prefix + "_hist_rcv_win"]),
     )
Esempio n. 5
0
 def update_function(self, c):
     rating_obj = ratings.Rating()
     for row in c.fetchall():
         a = ""
         he = ""
         hr = ""
         sp = ""
         cc = ""
         cf = ""
         for wo in range(0, 6):
             if wo == 0:
                 a = row[wo]
             elif wo == 1 and (row[wo] != '' and row[wo] is not None):
                 all_data = rating_obj.hackerearth(str(row[wo]))
                 if not all_data is None:
                     he = all_data
             elif wo == 2 and (row[wo] != '' and row[wo] is not None):
                 all_data = rating_obj.hackerrank(str(row[wo]))
                 if not all_data is None:
                     hr = all_data
             elif wo == 3 and (row[wo] != '' and row[wo] is not None):
                 count = 0
                 while count < 5:
                     all_data = rating_obj.codechef(row[wo])
                     if all_data is not None:
                         cc = all_data
                         break
                     else:
                         count = count + 1
                         continue
             elif wo == 4 and (row[wo] != '' and row[wo] is not None):
                 all_data = rating_obj.spoj(str(row[wo]))
                 if all_data is not None:
                     sp = all_data
             elif wo == 5 and (row[wo] != '' and row[wo] is not None):
                 all_data = rating_obj.codeforces(str(row[wo]))
                 if all_data is not None:
                     cf = all_data
         if not he == '' or (he == '' and (row[1] == '' or row[1] is None)):
             c.execute("UPDATE datas SET HE=(?) WHERE id=(?)", (he, str(a)))
             rating = rating_obj.rating_hackerearth(he)
             if not rating is None:
                 c.execute("UPDATE  priority SET HE = (?) WHERE id = (?) ", (rating, str(a)))
         if not hr == '' or (hr == '' and (row[2] == '' or row[2] is None)):
             c.execute("UPDATE datas SET HR=(?) WHERE id=(?)", (hr, str(a)))
             rating = rating_obj.rating_hackerrank(hr)
             if not rating is None:
                 c.execute("UPDATE  priority SET HR = (?) WHERE id = (?) ", (rating, str(a)))
         if not cf == '' or (cf == '' and (row[5] == '' or row[5] is None)):
             c.execute("UPDATE datas SET CF=(?) WHERE id=(?)", (cf, str(a)))
             rating = rating_obj.rating_codeforces(cf)
             if rating is not None:
                 c.execute("UPDATE  priority SET CF = (?) WHERE id = (?) ", (rating, str(a)))
         if not cc == '' or (cc == '' and (row[3] == '' or row[3] is None)):
             c.execute("UPDATE datas SET CC=(?) WHERE id=(?)", (cc, str(a)))
             rating = rating_obj.rating_codechef(cc)
             if rating is not None:
                 c.execute("UPDATE  priority SET CC = (?) WHERE id = (?) ", (rating, str(a)))
         if sp != '' or (sp == '' and (row[4] == '' or row[4] is None)):
             c.execute("UPDATE datas SET SP=(?) WHERE id=(?)", (sp, str(a)))
     # RECREATING ALL THE XLSX FILES
     self.recreate_xlsx(c)