Best Python code snippet using pandera_python
interface.py
Source:interface.py  
...36    global websites, odds37    if type == "oddschecker":38        websites, odds = ws.oddschecker(url)39class MyServer(BaseHTTPRequestHandler):40    def _format_index(self):41        with open("html/interface.html") as file:42            interface_html = file.read()43        list_html = ""44        for i in range(len(odds)):45            row = odds[i]46            website = websites[i]47            list_html += "<tr>"48            list_html += "<td>"+website+"</td>"49            for cell in row:50                list_html += "<td>"+str(cell)+"</td>"51        return interface_html.replace("[TABLE_ROWS]", list_html)52    def _format_find(self, budget):53        with open("html/find.html") as file:54            interface_html = file.read()55        list_html = ""56        website_list, bets, odds, arbitrage = find_bets(budget)57        for i in range(len(bets)):58            bet = round(bets[i]*100)/10059            win_ret = round(bet*odds[i]*100)/10060            row = "<tr>"61            row += "<td>"+str(i)+"</td>"62            row += "<td>"+website_list[i]+"</td>"63            row += "<td>"+str(odds[i])+"</td>"64            row += "<td>"+str(bet)+"</td>"65            row += "<td>"+str(win_ret)+"</td>"66            row += "</tr>"67            list_html += row68        ret_html = interface_html.replace("[TABLE_ROWS]", list_html)69        ret_html = ret_html.replace("[ARBITRAGE]", str(round(arbitrage*100)/100))70        return ret_html71    def _format_find_direct(self, bookmakers, budget, odds):72        with open("html/find_direct.html") as file:73            interface_html = file.read()74        bets, arbitrage = find_bets_direct(budget, odds)75        list_html = ""76        for i in range(len(bets)):77            bet = round(bets[i]*100)/10078            win_ret = round(bet*odds[i]*100)/10079            row = "<tr>"80            row += "<td>"+str(i)+"</td>"81            row += "<td>"+bookmakers[i].replace("+", " ")+"</td>"82            row += "<td>"+str(odds[i])+"</td>"83            row += "<td>"+str(bet)+"</td>"84            row += "<td>"+str(win_ret)+"</td>"85            row += "</tr>"86            list_html += row87        ret_html = interface_html.replace("[TABLE_ROWS]", list_html)88        ret_html = ret_html.replace("[ARBITRAGE]", str(round(arbitrage*100)/100))89        return ret_html90    def _format_find_direct_empty(self):91        with open("html/find_direct.html") as file:92            interface_html = file.read()93        ret_html = interface_html.replace("[TABLE_ROWS]", "")94        ret_html = ret_html.replace("[ARBITRAGE]", "0")95        return ret_html96    def _send_headers(self):97        self.send_response(200)98        self.send_header('Content-type', 'text/html')99        self.end_headers()100    def do_GET(self):101        global odds, websites102        self._send_headers()103        if self.path == "/reset":104            odds = []105            websites = []106        if self.path == "/find_direct":107            self.wfile.write(bytes(self._format_find_direct_empty(), "utf-8"))108        elif self.path == "/favicon.ico":109            pass110        elif self.path == "/shutdown":111            self.wfile.write(bytes("Shutting Down", "utf-8"))112            exit()113        else:114            self.wfile.write(bytes(self._format_index(), "utf-8"))115    def do_POST(self):116        global odds, websites117        self._send_headers()118        content_length = int(self.headers['Content-Length'])119        body = self.rfile.read(content_length).decode("utf8")120        if self.path == "/submit":121            data = body.split("&")122            website = data.pop(0)123            website = website[website.find("=")+1:]124            website = website.replace("+", " ")125            websites.append(website)126            for i in range(len(data)):127                data[i] = data[i].replace("%2C", ".")128                cut_pos = data[i].find("=")129                data[i] = data[i][cut_pos+1:]130                if data[i] != "":131                    data[i] = float(data[i])132                else:133                    del data[i]134            odds.append(data)135            self.wfile.write(bytes(self._format_index(), "utf-8"))136            #response = BytesIO()137            #response.write(b'This is POST request. ')138            #response.wite(body)139        elif self.path == "/find":140            data = body.split("&")141            index = data[0].find("=")+1142            budget = int(data[0][index:])143            self.wfile.write(bytes(self._format_find(budget), "utf-8"))144        elif self.path == "/autofill":145            data = body.split("&")146            index = data[0].find("=")+1147            type = data[0][index:]148            index = data[1].find("=")+1149            url = unquote(data[1][index:])150            autofind(type, url)151            self.wfile.write(bytes(self._format_index(), "utf-8"))152        elif self.path == "/find_direct":153            print("Find Firect")154            data = body.split("&")155            raw_data = []156            for point in data:157                index = point.find("=")+1158                raw_data.append(unquote(point[index:]))159            bookies = raw_data[0:3]160            best_odds = raw_data[3:6]161            budget = int(raw_data[6])162            for i in range(len(best_odds)):163                if best_odds[i] == "":164                    del best_odds[i]165                    continue...numbers.py
Source:numbers.py  
1from __future__ import absolute_import2# Copyright (c) 2010-2014 openpyxl3#4# Permission is hereby granted, free of charge, to any person obtaining a copy5# of this software and associated documentation files (the "Software"), to deal6# in the Software without restriction, including without limitation the rights7# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell8# copies of the Software, and to permit persons to whom the Software is9# furnished to do so, subject to the following conditions:10#11# The above copyright notice and this permission notice shall be included in12# all copies or substantial portions of the Software.13#14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN20# THE SOFTWARE.21#22# @license: http://www.opensource.org/licenses/mit-license.php23# @author: see AUTHORS file24import re25from .hashable import HashableObject26class NumberFormat(HashableObject):27    """Numer formatting for use in styles."""28    FORMAT_GENERAL = 'General'29    FORMAT_TEXT = '@'30    FORMAT_NUMBER = '0'31    FORMAT_NUMBER_00 = '0.00'32    FORMAT_NUMBER_COMMA_SEPARATED1 = '#,##0.00'33    FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-'34    FORMAT_PERCENTAGE = '0%'35    FORMAT_PERCENTAGE_00 = '0.00%'36    FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd'37    FORMAT_DATE_YYYYMMDD = 'yy-mm-dd'38    FORMAT_DATE_DDMMYYYY = 'dd/mm/yy'39    FORMAT_DATE_DMYSLASH = 'd/m/y'40    FORMAT_DATE_DMYMINUS = 'd-m-y'41    FORMAT_DATE_DMMINUS = 'd-m'42    FORMAT_DATE_MYMINUS = 'm-y'43    FORMAT_DATE_XLSX14 = 'mm-dd-yy'44    FORMAT_DATE_XLSX15 = 'd-mmm-yy'45    FORMAT_DATE_XLSX16 = 'd-mmm'46    FORMAT_DATE_XLSX17 = 'mmm-yy'47    FORMAT_DATE_XLSX22 = 'm/d/yy h:mm'48    FORMAT_DATE_DATETIME = 'd/m/y h:mm'49    FORMAT_DATE_TIME1 = 'h:mm AM/PM'50    FORMAT_DATE_TIME2 = 'h:mm:ss AM/PM'51    FORMAT_DATE_TIME3 = 'h:mm'52    FORMAT_DATE_TIME4 = 'h:mm:ss'53    FORMAT_DATE_TIME5 = 'mm:ss'54    FORMAT_DATE_TIME6 = 'h:mm:ss'55    FORMAT_DATE_TIME7 = 'i:s.S'56    FORMAT_DATE_TIME8 = 'h:mm:ss@'57    FORMAT_DATE_TIMEDELTA = '[hh]:mm:ss'58    FORMAT_DATE_YYYYMMDDSLASH = 'yy/mm/dd@'59    FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0.00_-'60    FORMAT_CURRENCY_USD = '$#,##0_-'61    FORMAT_CURRENCY_EUR_SIMPLE = '[$EUR ]#,##0.00_-'62    _BUILTIN_FORMATS = {63        0: 'General',64        1: '0',65        2: '0.00',66        3: '#,##0',67        4: '#,##0.00',68        5: '"$"#,##0_);("$"#,##0)',69        6: '"$"#,##0_);[Red]("$"#,##0)',70        7: '"$"#,##0.00_);("$"#,##0.00)',71        8: '"$"#,##0.00_);[Red]("$"#,##0.00)',72        9: '0%',73        10: '0.00%',74        11: '0.00E+00',75        12: '# ?/?',76        13: '# ??/??',77        14: 'mm-dd-yy',78        15: 'd-mmm-yy',79        16: 'd-mmm',80        17: 'mmm-yy',81        18: 'h:mm AM/PM',82        19: 'h:mm:ss AM/PM',83        20: 'h:mm',84        21: 'h:mm:ss',85        22: 'm/d/yy h:mm',86        37: '#,##0_);(#,##0)',87        38: '#,##0_);[Red](#,##0)',88        39: '#,##0.00_);(#,##0.00)',89        40: '#,##0.00_);[Red](#,##0.00)',90        41: '_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)',91        42: '_("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_)',92        43: '_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)',93        44: '_("$"* #,##0.00_)_("$"* \(#,##0.00\)_("$"* "-"??_)_(@_)',94        45: 'mm:ss',95        46: '[h]:mm:ss',96        47: 'mmss.0',97        48: '##0.0E+0',98        49: '@', }99    _BUILTIN_FORMATS_REVERSE = dict(100            [(value, key) for key, value in _BUILTIN_FORMATS.items()])101    __fields__ = ('_format_code',102                  '_format_index')103    __slots__ = __fields__104    __leaf__ = True105    DATE_INDICATORS = 'dmyhs'106    BAD_DATE_RE = re.compile(r'(\[|").*[dmhys].*(\]|")')107    def __eq__(self, other):108        if isinstance(other, NumberFormat):109            return self.format_code == other.format_code110        return self.format_code == other111    def __hash__(self):112        return super(NumberFormat, self).__hash__()113    def __init__(self):114        self._format_code = self.FORMAT_GENERAL115        self._format_index = 0116    @property117    def format_code(self):118        """Getter for the format_code property."""119        return self._format_code120    @format_code.setter121    def format_code(self, format_code = FORMAT_GENERAL):122        """Setter for the format_code property."""123        self._format_code = format_code124        self._format_index = self.builtin_format_id(format_code)125    def builtin_format_code(self, index):126        """Return one of the standard format codes by index."""127        return self._BUILTIN_FORMATS[index]128    def is_builtin(self):129        """Check if a format code is a standard format code."""130        return is_builtin(self.format_code)131    def builtin_format_id(self, fmt):132        """Return the id of a standard style."""133        return self._BUILTIN_FORMATS_REVERSE.get(fmt, None)134    def is_date_format(self):135        """Check if the number format is actually representing a date."""136        return is_date_format(self.format_code)137def is_date_format(fmt):138    if fmt is None:139        return False140    if any([x in fmt for x in NumberFormat.DATE_INDICATORS]):141        return not NumberFormat.BAD_DATE_RE.search(fmt)142    return False143def is_builtin(fmt):...print_utils.py
Source:print_utils.py  
...6    """Convert a list of indices into a pretty string for printing."""7    if (type(indices) == int or len(indices) == 0):8        return ""9    else:10        return "(" + ",".join([_format_index(index) for index in indices]) + ")"11# ------------------------------------------------------------------------12# Private functions13# ------------------------------------------------------------------------14def _format_index(index):15    """Return a string version of the given array index"""...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!!
