def post(self): today = date.today() previous_day = today - timedelta(days = 1) today_data = db.GqlQuery("SELECT * FROM CitizenData WHERE date = :1", today) data_map = {} for data in today_data: data_map[data.citizen_id] = (data.citizen_mu_id, [data.rank]) previuos_data = db.GqlQuery("SELECT * FROM CitizenData WHERE date = :1", previous_day) for data in previuos_data: if data.citizen_id in data_map: data_map[data.citizen_id][1].append(data.rank) mu_data = {} for citizen_id in data_map.keys(): if len(data_map[citizen_id][1]) == 2: mu_id = data_map[citizen_id][0] if mu_id not in mu_data: mu_data[mu_id] = 0 mu_data[mu_id] += data_map[citizen_id][1][0] - data_map[citizen_id][1][1] for mu_id in mu_data.keys(): damage = MUDamage(mu_id = mu_id, date = previous_day, damage = mu_data[mu_id] * 10) damage.put() #clear citizen data clear_data = db.GqlQuery("SELECT * FROM CitizenData WHERE date < :1", previous_day) for data in clear_data: data.delete()
async def done(ctx, a: str): if data.delete(a, 'Users/' + str(ctx.message.author.id) + '.txt') == 1: await ctx.send(ctx.message.author.name + 'さんは ' + a + ' を完成しましたね。お疲れ様でした。') await ctx.send('目標を殲滅しました。') else: await ctx.send(a + 'という課題が見つかりませんでした。')
async def publicall(ctx, *args): data.read_data('data.txt') data.sort_kadai() tem = [] await ctx.send('皆様のすべての課題は以下になります。') if not data.kadai: await ctx.send('虚無です。') else: for i in data.kadai: now = datetime.now() difference = i.timestamp - now.timestamp() if difference < 0: tem.append(i.name) await ctx.send( str(i.name).ljust(12, ' ') + ' 締切:' + str(i.year) + '-' + str(i.month) + '-' + str(i.day) + ' ' + str(data.append_zero(i.hour)) + ':' + str(data.append_zero(i.minute))) elif difference <= 259200: await ctx.send( str(i.name).ljust(12, ' ') + ' 締切:' + str(i.year) + '-' + str(i.month) + '-' + str(i.day) + ' ' + str(data.append_zero(i.hour)) + ':' + str(data.append_zero(i.minute)) + ' ' + '締切まであと' + str(round(difference / 60 / 60, 1)) + '時間です。頑張ってください。') elif difference <= 604800: await ctx.send( str(i.name).ljust(12, ' ') + ' 締切:' + str(i.year) + '-' + str(i.month) + '-' + str(i.day) + ' ' + str(data.append_zero(i.hour)) + ':' + str(data.append_zero(i.minute))) else: await ctx.send( str(i.name).ljust(12, ' ') + ' 締切:' + str(i.year) + '-' + str(i.month) + '-' + str(i.day) + ' ' + str(data.append_zero(i.hour)) + ':' + str(data.append_zero(i.minute))) for i in tem: data.delete(i, 'data.txt') await ctx.send('ターゲット ' + i + ' が締切ました。目標を殲滅しました。')
def handle_delete(event, context): logging.info("**Received delete event") s3_uri = event["PhysicalResourceId"] if s3_uri.startswith("s3://"): s3_bucket_name, _, s3_prefix = s3_uri[len("s3://"):].partition("/") logger.info("**Deleting demo data") data.delete(s3_bucket_name, s3_prefix) else: logger.info("**Skipping - no S3 URI physical resource created") cfnresponse.send( event, context, cfnresponse.SUCCESS, {}, physicalResourceId=event["PhysicalResourceId"], )
def delete_student(): global students response = request.get_json(force=True) id = response["id"] delete_response = data.delete(students, id) if delete_response: return "Deleted" return ("id not found, no student deleted!", 400)
async def show(ctx): data.read_data('Users/' + str(ctx.message.author.id) + '.txt') data.sort_kadai() tem = [] await ctx.send(ctx.message.author.name + 'さんの最近の課題は以下になります。') if not data.kadai: await ctx.send('虚無です。') else: for i in data.kadai: now = datetime.now() difference = i.timestamp - now.timestamp() if difference < 0: tem.append(i.name) await ctx.send( str(i.name).ljust(12, ' ') + ' 締切:' + str(i.year) + '-' + str(i.month) + '-' + str(i.day) + ' ' + str(data.append_zero(i.hour)) + ':' + str(data.append_zero(i.minute))) elif difference <= 259200: await ctx.send( str(i.name).ljust(12, ' ') + ' 締切:' + str(i.year) + '-' + str(i.month) + '-' + str(i.day) + ' ' + str(data.append_zero(i.hour)) + ':' + str(data.append_zero(i.minute)) + ' ' + '締切まであと' + str(round(difference / 60 / 60, 1)) + '時間です。頑張ってください。') elif difference <= 604800: await ctx.send( str(i.name).ljust(12, ' ') + ' 締切:' + str(i.year) + '-' + str(i.month) + '-' + str(i.day) + ' ' + str(data.append_zero(i.hour)) + ':' + str(data.append_zero(i.minute))) else: pass for i in tem: data.delete(i, 'Users/' + str(ctx.message.author.id) + '.txt') await ctx.send('ターゲット ' + i + ' が締切ました。目標を殲滅しました。')
def delItem(self): if self.id.get(): a=data.delete(self.id.get()) if a: tkMessageBox.showinfo('Notice','Delete already.') self.clearItem() self.id.set('') self.get_first_page() self.status.focus_set() else: tkMessageBox.showinfo('Notice','Please try again.') self.status.focus_set() return else: tkMessageBox.showinfo('Notice','Please select the item.') self.status.focus_set() return
def remove_quote(quote_id): """Removes a specific quote from the database. Arguments: - quote_id (integer) the id of the quote to be removed Returns: - message (string) a message indicating whether or not the quote has been removed from the database """ success = data.delete(quote_id) if not success: QUOTE_REQUESTS.labels(command_type="deletequote", result="failure").inc() return "There was an error deleting quote {}".format(quote_id) QUOTE_REQUESTS.labels(command_type="deletequote", result="success").inc() return "Quote {} successfully removed".format(quote_id)
def test_valid_name(self): name = json.loads(home({}))[5]["name"] delete(name) self.assertEqual(get(name), "Contact does not exist")
def test_invalid_name(self): name = "Invalid Name Here" self.assertEqual(delete(name), "Contact does not exist")
def delete(name): return data.delete(name)
# string wav file path vs. string of keywords? all_keywords = dict() for item in all_texts: all_keywords[item] = keywords.key_phrase_extraction_example(keywords.client, all_texts[item]) for wav in all_keywords: print("Key Phrase - " + wav) for kword in all_keywords[wav]: print("\t" + kword) reversed_dict = dict() def reverse_key_val(all_keywords): for wav in all_keywords: for kword in all_keywords[wav]: if kword not in reversed_dict: reversed_dict[kword] = list() reversed_dict[kword].append(wav) reverse_key_val(all_keywords) #print(reversed_dict) def search_lecture(keyword): return reversed_dict[keyword] #print(search_lecture("Amazon")) data.delete()
async def delete(ctx, a: str): if data.delete(a, 'data.txt') == 1: await ctx.send('ターゲット ' + a + ' を確認しました。') await ctx.send('目標を殲滅しました。') else: await ctx.send('ターゲット ' + a + ' を見つかりませんでした。')
def test_delete_fails(self): expected_response = False data.connect = MagicMock(return_value=[self.conn, self.conn]) self.conn.commit = MagicMock(side_effect=psycopg2.Error) received_response = data.delete(1) self.assertEqual(expected_response, received_response)
def test_delete(self): expected_response = True data.connect = MagicMock(return_value=[self.conn, self.conn]) received_response = data.delete(1) self.assertEqual(expected_response, received_response)