Best Python code snippet using localstack_python
template_finder.py
Source:template_finder.py
...25 self._scale_factor = 1.026 self.last_res = None27 self._templates = {28 # Templates for node in A5 Town29 "A5_TOWN_0": [load_template(f"assets/templates/a5_town/a5_town_0.png", self._scale_factor), self._scale_factor],30 "A5_TOWN_0.5": [load_template(f"assets/templates/a5_town/a5_town_0.5.png", self._scale_factor), self._scale_factor],31 "A5_TOWN_1": [load_template(f"assets/templates/a5_town/a5_town_1.png", self._scale_factor), self._scale_factor],32 "A5_TOWN_2": [load_template(f"assets/templates/a5_town/a5_town_2.png", self._scale_factor), self._scale_factor],33 "A5_TOWN_3": [load_template(f"assets/templates/a5_town/a5_town_3.png", self._scale_factor), self._scale_factor],34 "A5_TOWN_4": [load_template(f"assets/templates/a5_town/a5_town_4.png", self._scale_factor), self._scale_factor],35 "A5_TOWN_5": [load_template(f"assets/templates/a5_town/a5_town_5.png", self._scale_factor), self._scale_factor],36 "A5_TOWN_6": [load_template(f"assets/templates/a5_town/a5_town_6.png", self._scale_factor), self._scale_factor],37 "A5_TOWN_7": [load_template(f"assets/templates/a5_town/a5_town_7.png", self._scale_factor), self._scale_factor],38 "A5_TOWN_8": [load_template(f"assets/templates/a5_town/a5_town_8.png", self._scale_factor), self._scale_factor],39 "A5_TOWN_9": [load_template(f"assets/templates/a5_town/a5_town_9.png", self._scale_factor), self._scale_factor],40 "A5_TOWN_10": [load_template(f"assets/templates/a5_town/a5_town_10.png", self._scale_factor), self._scale_factor],41 # Templates for nod at Pindle42 "PINDLE_0": [load_template(f"assets/templates/pindle/pindle_0.png", self._scale_factor), self._scale_factor],43 "PINDLE_1": [load_template(f"assets/templates/pindle/pindle_1.png", self._scale_factor), self._scale_factor],44 "PINDLE_2": [load_template(f"assets/templates/pindle/pindle_2.png", self._scale_factor), self._scale_factor],45 "PINDLE_3": [load_template(f"assets/templates/pindle/pindle_3.png", self._scale_factor), self._scale_factor],46 "PINDLE_4": [load_template(f"assets/templates/pindle/pindle_4.png", self._scale_factor), self._scale_factor],47 "PINDLE_5": [load_template(f"assets/templates/pindle/pindle_5.png", self._scale_factor), self._scale_factor],48 "PINDLE_6": [load_template(f"assets/templates/pindle/pindle_6.png", self._scale_factor), self._scale_factor],49 "PINDLE_7": [load_template(f"assets/templates/pindle/pindle_7.png", self._scale_factor), self._scale_factor],50 # Templates for nodes to Eldritch51 "ELDRITCH_START": [load_template(f"assets/templates/eldritch/eldritch_start.png", self._scale_factor), self._scale_factor],52 "ELDRITCH_0": [load_template(f"assets/templates/eldritch/eldritch_0.png", self._scale_factor), self._scale_factor],53 "ELDRITCH_1": [load_template(f"assets/templates/eldritch/eldritch_1.png", self._scale_factor), self._scale_factor],54 "ELDRITCH_2": [load_template(f"assets/templates/eldritch/eldritch_2.png", self._scale_factor), self._scale_factor],55 "ELDRITCH_3": [load_template(f"assets/templates/eldritch/eldritch_3.png", self._scale_factor), self._scale_factor],56 "ELDRITCH_4": [load_template(f"assets/templates/eldritch/eldritch_4.png", self._scale_factor), self._scale_factor],57 # Templates for nodes to Shenk (from Eldritch)58 "SHENK_0": [load_template(f"assets/templates/shenk/shenk_0.png", self._scale_factor), self._scale_factor],59 "SHENK_1": [load_template(f"assets/templates/shenk/shenk_1.png", self._scale_factor), self._scale_factor],60 "SHENK_2": [load_template(f"assets/templates/shenk/shenk_2.png", self._scale_factor), self._scale_factor],61 "SHENK_3": [load_template(f"assets/templates/shenk/shenk_3.png", self._scale_factor), self._scale_factor],62 "SHENK_4": [load_template(f"assets/templates/shenk/shenk_4.png", self._scale_factor), self._scale_factor],63 "SHENK_6": [load_template(f"assets/templates/shenk/shenk_6.png", self._scale_factor), self._scale_factor],64 "SHENK_7": [load_template(f"assets/templates/shenk/shenk_7.png", self._scale_factor), self._scale_factor],65 "SHENK_8": [load_template(f"assets/templates/shenk/shenk_8.png", self._scale_factor), self._scale_factor],66 "SHENK_9": [load_template(f"assets/templates/shenk/shenk_9.png", self._scale_factor), self._scale_factor],67 "SHENK_10": [load_template(f"assets/templates/shenk/shenk_10.png", self._scale_factor), self._scale_factor],68 "SHENK_11": [load_template(f"assets/templates/shenk/shenk_11.png", self._scale_factor), self._scale_factor],69 "SHENK_12": [load_template(f"assets/templates/shenk/shenk_12.png", self._scale_factor), self._scale_factor],70 "SHENK_13": [load_template(f"assets/templates/shenk/shenk_13.png", self._scale_factor), self._scale_factor],71 "SHENK_15": [load_template(f"assets/templates/shenk/shenk_15.png", self._scale_factor), self._scale_factor],72 "SHENK_16": [load_template(f"assets/templates/shenk/shenk_16.png", self._scale_factor), self._scale_factor],73 "SHENK_17": [load_template(f"assets/templates/shenk/shenk_17.png", self._scale_factor), self._scale_factor],74 # Template Selectables75 "A5_STASH": [load_template(f"assets/templates/a5_stash.png", self._scale_factor), self._scale_factor],76 "A5_WP": [load_template(f"assets/templates/a5_wp.png", self._scale_factor), self._scale_factor],77 "A5_RED_PORTAL": [load_template(f"assets/templates/a5_red_portal.png", self._scale_factor), self._scale_factor],78 "A5_RED_PORTAL_TEXT": [load_template(f"assets/templates/a5_red_portal_with_text.png", self._scale_factor), self._scale_factor],79 "BLUE_PORTAL": [load_template(f"assets/templates/blue_portal.png", self._scale_factor), self._scale_factor],80 "BLUE_PORTAL_2": [load_template(f"assets/templates/blue_portal_2.png", self._scale_factor), self._scale_factor],81 # Template Inventory / UI82 "INVENTORY_GOLD_BTN": [load_template(f"assets/templates/inventory_gold_btn.png", 1.0), 1.0],83 "D2_LOGO_HS": [load_template(f"assets/templates/d2_logo_hs.png", 1.0), 1.0],84 "LOADING": [load_template(f"assets/templates/loading.png", 1.0), 1.0],85 "PLAY_BTN": [load_template(f"assets/templates/play_btn.png", 1.0), 1.0],86 "PLAY_BTN_GRAY": [load_template(f"assets/templates/play_btn_gray.png", 1.0), 1.0],87 "NORMAL_BTN": [load_template(f"assets/templates/normal_btn.png", 1.0), 1.0],88 "NIGHTMARE_BTN": [load_template(f"assets/templates/nightmare_btn.png", 1.0), 1.0],89 "HELL_BTN": [load_template(f"assets/templates/hell_btn.png", 1.0), 1.0],90 "SAVE_AND_EXIT_NO_HIGHLIGHT": [load_template(f"assets/templates/save_and_exit_no_highlight.png", 1.0), 1.0],91 "SAVE_AND_EXIT_HIGHLIGHT": [load_template(f"assets/templates/save_and_exit_highlight.png", 1.0), 1.0],92 "SERVER_ISSUES": [load_template(f"assets/templates/server_issues.png", 1.0), 1.0],93 "WAYPOINT_MENU": [load_template(f"assets/templates/waypoint_menu.png", 1.0), 1.0],94 "MERC": [load_template(f"assets/templates/merc.png", 1.0), 1.0],95 "TELE_ACTIVE": [load_template(f"assets/templates/tele_active.png", 1.0), 1.0],96 "TELE_INACTIVE": [load_template(f"assets/templates/tele_inactive.png", 1.0), 1.0],97 "VIGOR": [load_template(f"assets/templates/vigor.png", 1.0), 1.0],98 "REPAIR_BTN": [load_template(f"assets/templates/repair_btn.png", 1.0), 1.0],99 "TP_TOME": [load_template(f"assets/templates/tp_tome.png", 1.0), 1.0],100 "SUPER_HEALING_POTION": [load_template(f"assets/templates/super_healing_potion.png", 1.0), 1.0],101 "SUPER_MANA_POTION": [load_template(f"assets/templates/super_mana_potion.png", 1.0), 1.0],102 "FULL_REJUV_POTION": [load_template(f"assets/templates/full_rejuv_potion.png", 1.0), 1.0],103 "REJUV_POTION": [load_template(f"assets/templates/rejuv_potion.png", 1.0), 1.0],104 # NPC: Qual-Kehk105 "QUAL_FRONT": [load_template(f"assets/npc/qual_kehk/qual_front.png", 1.0), 1.0],106 "QUAL_SIDE": [load_template(f"assets/npc/qual_kehk/qual_side.png", 1.0), 1.0],107 "QUAL_BACK": [load_template(f"assets/npc/qual_kehk/qual_back.png", 1.0), 1.0],108 "QUAL_45": [load_template(f"assets/npc/qual_kehk/qual_45.png", 1.0), 1.0],109 "QUAL_45_2": [load_template(f"assets/npc/qual_kehk/qual_45_2.png", 1.0), 1.0],110 "QUAL_45_3": [load_template(f"assets/npc/qual_kehk/qual_45_3.png", 1.0), 1.0],111 "QUAL_NAME_TAG_WHITE": [load_template(f"assets/npc/qual_kehk/qual_kehk_white.png", 1.0), 1.0],112 "QUAL_NAME_TAG_GOLD": [load_template(f"assets/npc/qual_kehk/qual_kehk_gold.png", 1.0), 1.0],113 "QUAL_RESURRECT_BTN": [load_template(f"assets/npc/qual_kehk/resurrect_btn.png", 1.0), 1.0],114 # NPC: Malah115 "MALAH_FRONT": [load_template(f"assets/npc/malah/malah_front.png", 1.0), 1.0],116 "MALAH_BACK": [load_template(f"assets/npc/malah/malah_BACK.png", 1.0), 1.0],117 "MALAH_45": [load_template(f"assets/npc/malah/malah_45.png", 1.0), 1.0],118 "MALAH_SIDE": [load_template(f"assets/npc/malah/malah_side.png", 1.0), 1.0],119 "MALAH_SIDE_2": [load_template(f"assets/npc/malah/malah_side_2.png", 1.0), 1.0],120 "MALAH_NAME_TAG_WHITE": [load_template(f"assets/npc/malah/malah_white.png", 1.0), 1.0],121 "MALAH_NAME_TAG_GOLD": [load_template(f"assets/npc/malah/malah_gold.png", 1.0), 1.0],122 "MALAH_TRADE_BTN": [load_template(f"assets/npc/malah/trade_btn.png", 1.0), 1.0],123 # NPC: Larzuk124 "LARZUK_FRONT": [load_template(f"assets/npc/larzuk/larzuk_front.png", 1.0), 1.0],125 "LARZUK_BACK": [load_template(f"assets/npc/larzuk/larzuk_back.png", 1.0), 1.0],126 "LARZUK_SIDE": [load_template(f"assets/npc/larzuk/larzuk_side.png", 1.0), 1.0],127 "LARZUK_SIDE_2": [load_template(f"assets/npc/larzuk/larzuk_side_2.png", 1.0), 1.0],128 "LARZUK_SIDE_3": [load_template(f"assets/npc/larzuk/larzuk_side_3.png", 1.0), 1.0],129 "LARZUK_NAME_TAG_WHITE": [load_template(f"assets/npc/larzuk/larzuk_white.png", 1.0), 1.0],130 "LARZUK_NAME_TAG_GOLD": [load_template(f"assets/npc/larzuk/larzuk_gold.png", 1.0), 1.0],131 "LARZUK_TRADE_REPAIR_BTN": [load_template(f"assets/npc/larzuk/trade_repair_btn.png", 1.0), 1.0],132 # NPC: Anya133 "ANYA_FRONT": [load_template(f"assets/npc/anya/anya_front.png", 1.0), 1.0],134 "ANYA_BACK": [load_template(f"assets/npc/anya/anya_back.png", 1.0), 1.0],135 "ANYA_SIDE": [load_template(f"assets/npc/anya/anya_side.png", 1.0), 1.0],136 "ANYA_NAME_TAG_GOLD": [load_template(f"assets/npc/anya/anya_gold.png", 1.0), 1.0],137 "ANYA_NAME_TAG_WHITE": [load_template(f"assets/npc/anya/anya_white.png", 1.0), 1.0],138 "ANYA_TRADE_BTN": [load_template(f"assets/npc/anya/trade_btn.png", 1.0), 1.0],139 }140 def get_template(self, key):141 return self._templates[key][0]142 def search(143 self,144 ref: Union[str, np.ndarray, List[str]],145 inp_img: np.ndarray,146 threshold: float = None,147 roi: List[float] = None,148 normalize_monitor: bool = False,149 best_match: bool = False150 ) -> TemplateMatch:151 """152 Search for a template in an image...
views.py
Source:views.py
1# -*- encoding: utf-8 -*-2"""3Copyright (c) 2019 - present AppSeed.us4"""5from django import template6from django.contrib.auth.decorators import login_required7from django.http import HttpResponse, HttpResponseRedirect8from django.template import loader9from django.urls import reverse10from django.shortcuts import render11import feedparser12from datetime import date13import webbrowser14import json15from django.template.defaulttags import register16from matplotlib.font_manager import json_dump17from .yahoo_api import get_quotes18from django.shortcuts import render19from .models import My_Transaction20from .models import Configuration21from .trade import main_lstm22import matplotlib.pyplot as plt23import numpy as np24from matplotlib.backends.backend_agg import FigureCanvasAgg25from django.http import HttpResponse26from .macd import main_macd27from .bbands import main_bbands28from .sma import main_sma29from .ewma import main_ewma30from .list_stock import main_list31# The feedparser that will get the application from the web 32feed = feedparser.parse("https://www.cnbc.com/id/20409666/device/rss/rss.html?x=1")33@login_required(login_url="/login/")34def index(request):35 context = {'segment': 'index'}36 html_template = loader.get_template('home/index.html')37 return HttpResponse(html_template.render(context, request))38@login_required(login_url="/login/")39def pages(request):40 context = {}41 # All resource paths end in .html.42 # Pick out the html file name from the url. And load that template.43 try:44 45 load_template = request.path.split('/')[-1]46 # Remove the if statment to get back at the orginal code47 if load_template == 'news.html':48 context = {}49 if load_template == 'admin':50 return HttpResponseRedirect(reverse('admin:index'))51 #context['segment'] = load_template52 context = feedparser()53 html_template = loader.get_template('home/' + load_template)54 55 return HttpResponse(html_template.render(context, request))56 57 elif load_template == 'configuration.html':58 context = {}59 if load_template == 'admin':60 return HttpResponseRedirect(reverse('admin:index'))61 #context['segment'] = load_template62 html_template = loader.get_template('home/' + load_template)63 if request.method == 'POST':64 mode_ = request.POST['mode']65 industry_ = request.POST['industry']66 algorithm_ = request.POST['algorithm']67 risk_percentage_ = request.POST['risk_percentage']68 diversity_ = request.POST['diversity']69 max_buy_ = request.POST['max_buy']70 min_traded_ = request.POST['min_traded']71 max_traded_ = request.POST['max_traded']72 username_ = request.POST['username']73 username_ = request.user.username74 rows = Configuration.objects.filter(username=username_) 75 for r in rows: 76 r.delete() 77 new_config = Configuration(mode=mode_, industry=industry_, algorithm=algorithm_, risk_percentage=risk_percentage_, diversity=diversity_, max_buy=max_buy_, min_traded=min_traded_, max_traded=max_traded_, username=username_)78 new_config.save()79 stock = []80 inds = []81 rows_alg = Configuration.objects.all()82 for i in range(len(rows_alg)):83 if rows_alg[i].username == request.user.username:84 industry_test = rows_alg[i].industry85 algorithm_test = rows_alg[i].algorithm86 risk_percentage_test = rows_alg[i].risk_percentage87 diversity_test = rows_alg[i].diversity88 max_buy_test = rows_alg[i].max_buy89 min_traded_test = rows_alg[i].min_traded90 max_traded_test = rows_alg[i].max_traded91 inds.append(industry_test)92 93 print(inds, " test 1")94 stock = main_list(inds, risk_percentage_test, max_buy_test)95 print(stock)96 Buy, Sell, stock_info, signal = [0], [0], "", "Sell"97 for i in stock:98 try:99 if algorithm_test == "SMA":100 Buy, Sell, stock_info, signal = main_sma(i)101 elif algorithm_test == "EWMA":102 Buy, Sell, stock_info, signal = main_ewma(i)103 elif algorithm_test == "BBANDS":104 Buy, Sell, stock_info, signal = main_bbands(i)105 elif algorithm_test == "MACD":106 Buy, Sell, stock_info, signal = main_macd(i)107 elif algorithm_test == "LSTM":108 array_per, array_org, accuracy, X_train, X_test, len_time, Next5Days, stock_info, signal= main_lstm(i)109 print(signal, "test #######")110 My_Transaction.objects.create(mode = algorithm_test, company = i, industry = 'TECH', history = signal, profit_loss = stock_info['Close'].iloc[-1], username = request.user.username)111 except:112 pass113 114 return HttpResponse(html_template.render(context, request))115 elif load_template == 'myTransaction.html': # My Transaction ADD POST----------------------------------------------------------116 context = {117 }118 if load_template == 'admin':119 return HttpResponseRedirect(reverse('admin:index'))120 #context['segment'] = load_template121 html_template = loader.get_template('home/' + load_template)122 all_data = My_Transaction.objects.all()123 usernames = request.user.username124 modes = []125 companys = []126 industries = []127 signals = []128 prices = []129 nums = []130 print(len(all_data))131 count = 1132 for i in range(len(all_data)):133 if all_data[i].username == usernames:134 nums.append(count)135 print("----",all_data[i].mode)136 modes.append(all_data[i].mode)137 companys.append(all_data[i].company)138 industries.append(all_data[i].industry)139 signals.append(all_data[i].history)140 prices.append(all_data[i].profit_loss)141 count = count + 1142 modes.reverse()143 companys.reverse()144 industries.reverse()145 signals.reverse()146 prices.reverse()147 mylist = zip(nums, modes, companys, signals, prices)148 print(modes)149 #print(modes)150 context = {151 "filename": "tables-data.html",152 "collapse": "",153 "mylist": mylist,154 "num": nums,155 "mode": modes,156 "company": companys,157 "industry": industries,158 "signal": signals,159 "price": prices,160 }161 return HttpResponse(html_template.render(context, request))162 163 elif load_template == 'aiChart.html': # My Transaction ADD POST----------------------------------------------------------164 165 array_info = [0, 0, 0, 0]166 array = list(range(1, 201))167 array2 = list(range(1, 201))168 Next5Daysls = [0,0,0,0,0]169 if request.method == 'POST':170 search = request.POST['search']171 array = []172 array2 = []173 array_info = []174 Next5Daysls = []175 array_per, array_org, accuracy, X_train, X_test, len_time, Next5Days, df, signal = main_lstm(search)176 array_per.tolist()177 array_info = [X_train, X_test, len_time, accuracy]178 for i in range(5):179 Next5Daysls.append(Next5Days[0][i])180 for i in range(200):181 array.append(array_per[i]) 182 array2.append(array_org[i])183 List = list(range(1, 201))184 for i in range(len(List)):185 List[i] = str(List[i])186 labels = List187 data = array188 data1 = array2189 context = {190 "filename": "charts-chartjs.html",191 "collapse": "",192 "labels": json.dumps(labels),193 "data1": json.dumps(data1),194 "data": json.dumps(data),195 "info": array_info,196 "next": Next5Daysls,197 }198 if load_template == 'admin':199 return HttpResponseRedirect(reverse('admin:index'))200 #context['segment'] = load_template201 html_template = loader.get_template('home/' + load_template)202 all_data = My_Transaction.objects.all()203 #for i in all_data:204 # print(i.mode)205 return HttpResponse(html_template.render(context, request))206 elif load_template == 'stockInfo.html':207 search = 'AAPL'208 today = date.today()209 if request.method == 'POST':210 search = request.POST['search']211 data = get_quotes(search)212 context = {213 "data": [data['quoteResponse']['result'][0]['regularMarketPrice'], data['quoteResponse']['result'][0]['regularMarketChangePercent'], data['quoteResponse']['result'][0]['marketCap'], 33.1, data['quoteResponse']['result'][0]['trailingPE'], 12, 15, data['quoteResponse']['result'][0]['priceToSales'], 0.5, 28.2, data['quoteResponse']['result'][0]['revenue'], 3, 1199, data['quoteResponse']['result'][0]['pegRatio'], 63, 352, data['quoteResponse']['result'][0]['sharesOutstanding'], data['quoteResponse']['result'][0]['dividendRate'], data['quoteResponse']['result'][0]['regularMarketVolume'], search, today],214 }215 if load_template == 'admin':216 return HttpResponseRedirect(reverse('admin:index'))217 #context['segment'] = load_template218 html_template = loader.get_template('home/' + load_template)219 return HttpResponse(html_template.render(context, request))220 elif load_template == 'index.html': # My Transaction ADD POST----------------------------------------------------------221 context = {222 }223 if load_template == 'admin':224 return HttpResponseRedirect(reverse('admin:index'))225 #context['segment'] = load_template226 html_template = loader.get_template('home/' + load_template)227 all_data = My_Transaction.objects.all()228 count = 0229 usernames = request.user.username230 companys = []231 signals = []232 for i in range(len(all_data)):233 if all_data[i].username == usernames:234 if count < 5:235 companys.append(all_data[i].company)236 signals.append(all_data[i].history)237 238 context = {239 "filename": "index.html",240 "collapse": "",241 "company": companys,242 "signal": signals,243 }244 return HttpResponse(html_template.render(context, request))245 246 else:247 if load_template == 'admin':248 return HttpResponseRedirect(reverse('admin:index'))249 context['segment'] = load_template250 html_template = loader.get_template('home/' + load_template)251 return HttpResponse(html_template.render(context, request))252 except template.TemplateDoesNotExist:253 html_template = loader.get_template('home/page-404.html')254 return HttpResponse(html_template.render(context, request))255 except:256 html_template = loader.get_template('home/page-500.html')257 return HttpResponse(html_template.render(context, request))258def feedparser():259 260 feed_entries = feed.entries261 count = 0262 arr =output = [[0 for i in range(4)] for j in range(10)]263 for entry in feed.entries:264 count = count + 1265 article_title = entry.title266 article_link = entry.link267 article_published_at = entry.published 268 article_description = entry.description269 arr[count-1][0]=article_title 270 arr[count-1][1]=article_published_at271 arr[count-1][2]=article_link272 arr[count-1][3]=article_description273 if count == 10:274 break275 data = {"title": arr}276 return data277@register.filter278def get_value(dictionary, key):279 return dictionary.get(key)280# Assuming the data to be entered is presnet in these lists281tran_mode = ['Automatic', 'Manual']282tran_company = ['Apple', 'Amazon']283tran_industry = ['Tech', 'Books']284tran_history = ['Trending Algorithm', 'Mean Algorithm']285tran_profit_loss = [20, 15]286def my_view(request, *args, **kwargs):287 288 # Iterate through all the data items289 for i in range(len(tran_mode)):290 # Insert in the database291 My_Transaction.objects.create(Mode = tran_mode[i], Company = tran_company[i], Industry = tran_industry[i], History = tran_history[i], Profit_Loss = tran_profit_loss[i])292 # Getting all the stuff from database293 query_results = My_Transaction.objects.all()294 # Creating a dictionary to pass as an argument295 context = { 'query_results' : query_results }296 # Returning the rendered html...
templates.py
Source:templates.py
...20 `idpattern` more narrow (`a-z`, `_`, and `0-9`).21 '''22 delimiter = '¶'23 idpattern = r'[a-z][_a-z0-9]*'24def load_template(filepath: str) -> EduTemplate:25 """26 Read a file into a `string.Template` Python built-in class.27 Args:28 - filepath: The path to a template29 Returns: A loaded template.30 """31 t = None32 # TODO ASSERT FILEPATH IS LEGIT FILE33 #assert os.path.isfile(filepath), `Provided template '34 filepath = fix_filepath(__file__, filepath)35 with open(filepath, 'r', encoding='utf-8') as f:36 t = EduTemplate('\n'.join(f.readlines()))37 return t38# import all templates39TEMPLATES = {40 "admin": {41 "book_manager": load_template("templates/admin/book_manager.html"),42 "edit_book": load_template("templates/admin/edit_book.html"),43 "index": load_template("templates/admin/index.html"),44 "study_manager": load_template("templates/admin/study_manager.html"),45 "upload_book": load_template("templates/admin/upload_book.html"),46 "book": load_template("templates/admin/book.html"),47 "book_card": load_template("templates/admin/book_card.html"),48 "study_list": load_template("templates/admin/study_list.html"),49 "add_study": load_template("templates/admin/add_to_study.html"),50 "user_list": load_template("templates/admin/user_list.html"),51 "add_book": load_template("templates/admin/add_to_book.html"),52 "add_user": load_template("templates/admin/add_to_user.html"),53 "school_options": load_template("templates/admin/school_id_option.html"),54 "school_list": load_template("templates/admin/school_list.html")55 },56 "navbar": {57 "logged_admin": load_template("templates/navbar/logged_admin.html"),58 "logged_out": load_template("templates/navbar/logged_out.html"),59 "logged_user": load_template("templates/navbar/logged_user.html")60 },61 "password": {62 "forgot": load_template("templates/password/forgot.html"),63 "reset": load_template("templates/password/reset.html")64 },65 "story_selection": {66 "book": load_template("templates/story_selection/book.html"),67 "index": load_template("templates/story_selection/index.html")68 },69 "storyboard": {70 "quiz": {71 "fr": load_template("templates/storyboard/quiz_fr.html"),72 "mc_item": load_template("templates/storyboard/quiz_mc_item.html"),73 "mc": load_template("templates/storyboard/quiz_mc.html")74 },75 "viewer": load_template("templates/storyboard/viewer.html")76 },77 "errors": {78 "400": load_template("templates/errors/400.html"),79 "401": load_template("templates/errors/401.html"),80 "403": load_template("templates/errors/403.html"),81 "404": load_template("templates/errors/404.html"),82 "405": load_template("templates/errors/405.html"),83 "500": load_template("templates/errors/500.html"),84 "502": load_template("templates/errors/502.html")85 },86 "_base": load_template("templates/_base.html"),87 "index": load_template("templates/index.html"),88 "login": load_template("templates/login.html"),89 "register": {90 "reg": load_template("templates/register.html"),91 "school_option": load_template("templates/school_list.html")92 }93}94class Templates:95 '''96 This Templates class just holds references to `TEMPLATES` where the97 templates are actually loaded and initialized.98 This class will help type safety, and make it easier for our contributors.99 '''100 admin_book: Template = TEMPLATES['admin']['book']101 '''102 Admin Book Index template.103 '''104 admin_book_card: Template = TEMPLATES['admin']['book_card']105 '''...
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!!