How to use remove_tag method in Kiwi

Best Python code snippet using Kiwi_python

settlement.py

Source: settlement.py Github

copy

Full Screen

...11 if guarded.role == Role.KILLER:12 for shot in self.filter_players_by_tag(players, Tag.SHOT):13 if shot.role != Role.GUARDIAN_ANGEL:14 result.log_private('%s was guarded and failed to shoot.' % guarded)15 shot.remove_tag(Tag.SHOT)16 else:17 result.log_private('%s was guarded and shot %s.' % (guarded, shot))18 # If doctor is guarded, nobody can be cured.19 if guarded.role == Role.DOCTOR:20 result.log_private('%s was guarded and failed to cure.' % guarded)21 for cured in self.filter_players_by_tag(players, Tag.CURED):22 cured.remove_tag(Tag.CURED)23 # If a player is guarded, he cannot be cured.24 if guarded.has_tag(Tag.CURED):25 result.log_private('%s was guarded and could not be cured.' % guarded)26 guarded.remove_tag(Tag.CURED)27 # If a player is guarded, he cannot be shot unless he is guardian angel.28 if guarded.has_tag(Tag.SHOT) and guarded.role != Role.GUARDIAN_ANGEL:29 result.log_private('%s was guarded and could not be shot.' % guarded)30 guarded.remove_tag(Tag.SHOT)31 # If a player is guarded twice continuously, he becomes unguardable.32 if guarded.has_tag(Tag.PREVIOUSLY_GUARDED):33 result.log_private('%s was guarded twice and became unguardable.' % guarded)34 guarded.add_tag(Tag.UNGUARDABLE)35class SettleShot(SettlementRule):36 tag = Tag.SHOT37 def settle_tagged_player(self, tagged_player, players, result):38 shot = tagged_player39 # If a player is shot, he's killed unless he's cured.40 if shot.has_tag(Tag.CURED):41 result.log_private('%s was shot but cured.' % shot)42 shot.remove_tag(Tag.SHOT)43 shot.remove_tag(Tag.CURED)44 else:45 result.log_private('%s was shot and killed.' % shot)46 shot.mark_out(self.tag)47 result.add_out_player(shot)48 # If guardian angel is killed, the player he guarded is also killed.49 if shot.role == Role.GUARDIAN_ANGEL:50 for guarded in self.filter_players_by_tag(players, Tag.GUARDED):51 result.log_private('%s was guarded and was dead with guardian angel.' % guarded)52 guarded.mark_out(Tag.GUARDED)53 result.add_out_player(guarded)54class SettleCured(SettlementRule):55 tag = Tag.CURED56 def settle_tagged_player(self, tagged_player, players, result):57 cured = tagged_player58 if cured.has_tag(Tag.SHOT):59 result.log_private('%s was shot and cured.' % cured)60 cured.remove_tag(Tag.CURED)61 cured.remove_tag(Tag.SHOT)62 elif cured.has_tag(Tag.MISDIAGNOSED):63 result.log_private('%s was misdiagnosed twice and killed.' % cured)64 cured.mark_out(Tag.MISDIAGNOSED)65 result.add_out_player(cured)66 else:67 result.log_private('%s was misdiagnosed.' % cured)68 cured.remove_tag(Tag.CURED)69 cured.add_tag(Tag.MISDIAGNOSED)70class ClearPreviouslyGuarded(SettlementRule):71 tag = Tag.PREVIOUSLY_GUARDED72 def settle_tagged_player(self, tagged_player, players, result):73 previously_guarded = tagged_player74 previously_guarded.remove_tag(self.tag)75class UpdateGuardedToPreviouslyGuarded(SettlementRule):76 tag = Tag.GUARDED77 def settle_tagged_player(self, tagged_player, players, result):78 guarded = tagged_player79 guarded.remove_tag(self.tag)80 guarded.add_tag(Tag.PREVIOUSLY_GUARDED)81RULES = (82 SettleGuarded(),83 SettleShot(),84 SettleCured(),85 ClearPreviouslyGuarded(),86 UpdateGuardedToPreviouslyGuarded(),...

Full Screen

Full Screen

tag.py

Source: tag.py Github

copy

Full Screen

1import logging.config2import uuid3from typing import List4from sqlalchemy.orm import Session5from src import models, schemas, crud6from src.core.const import string, status7from src.core.error_handler import WebException8logger = logging.getLogger(__name__)9class TagController:10 @staticmethod11 def read_all_tags(db: Session) -> schemas.Response:12 tags = crud.tag.get_multi(db)13 return schemas.Response(data=tags)14 @staticmethod15 def tag_post(db: Session, post: models.Post, tags_list: List[str]):16 post_tags = [post_tag.tag.id for post_tag in post.tags]17 if not tags_list:18 for tag_id in post_tags:19 remove_tag = crud.post_tag.get_by_multi_attribute(db, [tag_id, post.id], ["tag_id", "post_id"])20 crud.post_tag.remove(db, remove_tag)21 else:22 all_tags = crud.tag.get_multi(db)23 all_tags_dict = {tag.type: tag.id for tag in all_tags}24 for tag_type in tags_list:25 if tag_type not in all_tags_dict.keys():26 raise WebException(err=tag_type + ": " + string.TAG_NOT_FOUND, err_status=status.ERR0003)27 list_tag_ids = [all_tags_dict.get(tag_type) for tag_type in tags_list]28 for tag_id in list_tag_ids:29 if tag_id not in post_tags:30 crud.post_tag.create(db, schemas.PostTag(31 id=str(uuid.uuid4()), post_id=post.id, tag_id=tag_id))32 else:33 post_tags.remove(tag_id)34 if post_tags:35 for tag_id in post_tags:36 remove_tag = crud.post_tag.get_by_multi_attribute(db, [tag_id, post.id], ["tag_id", "post_id"])37 crud.post_tag.remove(db, remove_tag)38 return schemas.Response(data=post.tags)39 @staticmethod40 def tag_instructor(db: Session, instructor: models.Instructor, tags_list: List[str]):41 instructor_tags = [instructor_tag.tag.id for instructor_tag in instructor.tags]42 if not tags_list:43 for tag_id in instructor_tags:44 remove_tag = crud.instructor_tag.get_by_multi_attribute(db, [tag_id, instructor.id], ["tag_id", "instructor_id"])45 crud.instructor_tag.remove(db, remove_tag)46 else:47 all_tags = crud.tag.get_multi(db)48 all_tags_dict = {tag.type: tag.id for tag in all_tags}49 for tag_type in tags_list:50 if tag_type not in all_tags_dict.keys():51 raise WebException(err=tag_type + ": " + string.TAG_NOT_FOUND, err_status=status.ERR0003)52 list_tag_ids = [all_tags_dict.get(tag_type) for tag_type in tags_list]53 for tag_id in list_tag_ids:54 if tag_id not in instructor_tags:55 crud.instructor_tag.create(db, schemas.InstructorTag(56 id=str(uuid.uuid4()), instructor_id=instructor.id, tag_id=tag_id))57 else:58 instructor_tags.remove(tag_id)59 if instructor_tags:60 for tag_id in instructor_tags:61 remove_tag = crud.instructor_tag.get_by_multi_attribute(db, [tag_id, instructor.id],62 ["tag_id", "instructor_id"])63 crud.instructor_tag.remove(db, remove_tag)64 return schemas.Response(data=instructor.tags)...

Full Screen

Full Screen

gen_contest_problem_relation.py

Source: gen_contest_problem_relation.py Github

copy

Full Screen

...40 p = compile('<tr>[\d\D]*?</​tr>')41 trs = p.findall(tables[1])42 div = []43 level = []44 l = remove_tag(trs[2]).split('\n')45 for ll in l:46 if ll.strip().startswith('D'):47 t_l = ll.split()48 if t_l[1] == 'I':49 div.append(1)50 else:51 div.append(2)52 if t_l[3].lower() == 'one':53 level.append(1)54 elif t_l[3].lower() == 'two':55 level.append(2)56 else: 57 level.append(3)58 categary = ' '.join(remove_tag(trs[3]).split()[1:])59 writer = ' '.join(remove_tag(trs[4]).split()[1:])60 tester = ' '.join(remove_tag(trs[5]).split()[1:])61 trs = p.findall(tables[2])62 value = remove_tag(trs[1]).split()[2:]63 competitor = remove_tag(trs[2]).split()[1:]64 opens = remove_tag(trs[3]).split()[1:]65 percent_open = remove_tag(trs[4]).split()[2:]66 percent_submit = remove_tag(trs[5]).split()[2:]67 overall_accuracy = remove_tag(trs[6]).split()[2:]68 69 try:70 for i in xrange(len(div)):71 cur.execute(insert_template1 % (c_id, p_id, div[i], level[i], value[i], competitor[i], opens[i], percent_open[i], percent_submit[i], overall_accuracy[i]))72 print c_id, p_id, div[i], level[i], value[i], competitor[i], opens[i], percent_open[i], percent_submit[i], overall_accuracy[i]73 except:74 print c_id, p_id, ' not found details!'75 cur.execute(insert_template2 % (categary, writer, tester, p_id))76 print categary, writer, tester, p_id77if __name__ == '__main__':78 topcoder = Topcoder()79 topcoder.login()80 conn, cur = init()81 gen_relation(cur, topcoder)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Stop Losing Money. Invest in Software Testing

I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.

Testing in Production: A Detailed Guide

When most firms employed a waterfall development model, it was widely joked about in the industry that Google kept its products in beta forever. Google has been a pioneer in making the case for in-production testing. Traditionally, before a build could go live, a tester was responsible for testing all scenarios, both defined and extempore, in a testing environment. However, this concept is evolving on multiple fronts today. For example, the tester is no longer testing alone. Developers, designers, build engineers, other stakeholders, and end users, both inside and outside the product team, are testing the product and providing feedback.

Starting &#038; growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

Getting Rid of Technical Debt in Agile Projects

Technical debt was originally defined as code restructuring, but in today’s fast-paced software delivery environment, it has evolved. Technical debt may be anything that the software development team puts off for later, such as ineffective code, unfixed defects, lacking unit tests, excessive manual tests, or missing automated tests. And, like financial debt, it is challenging to pay back.

A Comprehensive Guide On JUnit 5 Extensions

JUnit is one of the most popular unit testing frameworks in the Java ecosystem. The JUnit 5 version (also known as Jupiter) contains many exciting innovations, including support for new features in Java 8 and above. However, many developers still prefer to use the JUnit 4 framework since certain features like parallel execution with JUnit 5 are still in the experimental phase.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful