Best Python code snippet using ATX
urls.py
Source:urls.py
1"""ytmusicquiz URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/2.2/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: path('', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.urls import include, path13 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))14"""15from django.contrib import admin16from django.urls import path17from . import views18urlpatterns = [19 # Intro20 path('', views.intro, name='intro'),21 # New game (step 1/1)22 path('new', views.newgame, name='newgame'),23 # TV (DEPRECATED, use ytmusicquiz-dashboard project)24 path('dashboard', views.dashboard, name='dashboard'),25 # Game master26 # New game (Step 2/2)27 path('game/<int:game_id>/setup', views.game_master.setup, name='setup'),28 # Question29 path('game/<int:game_id>', views.game_master.game, name='game'),30 # Answer31 path('game/<int:game_id>/answered', views.game_master.game_answered,32 name='game_answered'),33 # Game over (Statistics)34 path('game/<int:game_id>/gameover', views.game_master.gameover,35 name='gameover'),36 # End game (Return to new game -page)37 path('game/<int:game_id>/finish', views.game_master.finish,38 name='finish'),39 # Game Master API40 path('api/game/<int:game_id>/control', views.game_master.api_control,41 name='api_control'),42 # Management43 path('list_unprocessed', views.management.list_unprocessed,44 name='list_unprocessed'),45 path('process_draft', views.management.process_draft,46 name='process_draft'),47 path('process_draft/<video_id>', views.management.process_draft,48 name='process_draft'),49 path('add', views.management.add, name='add'),50 path('import_playlist', views.management.import_playlist,51 name='import_playlist'),52 path('admin/', admin.site.urls),...
question_track.py
Source:question_track.py
...22 "can_reject": False,23 "submit_button_text": "Add"24 })25@staff_member_required26def process_draft(request, video_id=None):27 q = QuestionTrack.objects.filter(state="DRAFT")28 if video_id:29 q = q.filter(videoId=video_id)30 qt = q.first()31 if not qt:32 raise Exception("No question tracks in DRAFT state")33 form = Form(instance=qt)34 if request.method == 'POST':35 if 'reject' in request.POST:36 qt.state = "REJECTED"37 qt.save()38 return redirect('process_draft')39 form = Form(request.POST, instance=qt)40 if form.is_valid():...
favs.py
Source:favs.py
...3paths = os.listdir("draftlogs")4path = paths[0]5draftlog_path = os.path.join("draftlogs", path)6drafters = ["Jorbas", "RosyGraph", "Waluigi"]7def process_draft(drafter):8 colors = {"W": 0, "U": 0, "B": 0, "R": 0, "G": 0, "X": 0}9 total_cmc = 010 total_cards = 011 for path in [p for p in os.listdir("draftlogs") if drafter in p]:12 with open(os.path.join("draftlogs", path), "r") as f:13 for line in f.readlines():14 if line.startswith("--> "):15 cardname = line[4:-1]16 if cardname == drafter:17 continue18 matches = Card.where(name=cardname).all()19 if len(matches) == 0:20 print(f"card not found: {cardname}")21 continue22 card = matches[0]23 if card.color_identity:24 for cid in card.color_identity:25 colors[cid] += 126 else:27 colors["X"] += 128 total_cmc += card.cmc29 total_cards += 130 avg_cmc = total_cmc / total_cards31 print(f"drafter: {drafter}")32 print(f"\taverage cmc: {avg_cmc}")33 print(f"\tcolor preferences:")34 for k, v in colors.items():35 p = round(v / total_cards, 2)36 print(f"\t\t{k}: {p}")37for drafter in drafters:...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!