Best Python code snippet using autotest_python
original_html.py
Source:original_html.py  
...39        for n in nodes:40        #n = nodes.pop(-1)41            #print txt42            #print "------";raw_input()43            if (n.getCategory()=="INTERNAL_CAROTID_NEUROVASCULARANATOMY"): predicateFlag=True44            elif (n.getCategory()=="COMMON_CAROTID_NEUROVASCULARANATOMY"): predicateFlag=True45            elif (n.getCategory()=="BULB_CAROTID_NEUROVASCULARANATOMY"): predicateFlag=True46            47#             if (n.getCategory()=="CAROTID_CRITICAL"):t="2"48#             elif (n.getCategory()=="CAROTID_NONCRITICAL"): t="1"49#             elif (n.getCategory()=="PROBABLE_NEGATED_EXISTENCE") or (n.getCategory()=="DEFINITE_NEGATED_EXISTENCE"): t="0"50#             else:  t="None"                51#           52#            #no significant stenosis cases53            if (n.getCategory()=="PROBABLE_NEGATED_EXISTENCE") or (n.getCategory()=="DEFINITE_NEGATED_EXISTENCE"): t="0"54            elif (n.getCategory()=="CAROTID_CRITICAL"):t="2"55            elif (n.getCategory()=="CAROTID_NONCRITICAL"): t="1"56            else:  t="None"57            nodesLst.append(t)58        nodesLst.sort()59        #print nodesLst;raw_input()60        if predicateFlag==True:61            62#             if "2" in nodesLst: cSent="severity2"63#             elif "1" in nodesLst: cSent="severity1"64#             elif "0" in nodesLst: cSent="severity0"65            if "0" in nodesLst: cSent="severity0"66            elif "2" in nodesLst: cSent="severity2"67            elif "1" in nodesLst: cSent="severity1"68            69            70            else: cSent="severityNone"71        else: cSent="severityNone"72        return  __insert_color(txt,n.getSpan(),colors.get(n.getCategory()[0],cSent))73                          74        75#         return mark_text(__insert_color(txt,76#                                         n.getSpan(),77#                                         colors.get(n.getCategory()[0],c)),78#                          nodes,79#                          colors=colors)80def mark_document_with_html(imageID,doc,colors = {"name":"red","pet":"blue"}):81    """takes a ConTextDocument object and returns an HTML paragraph with marked phrases in the 82    object highlighted with the colors coded in colors83    84    doc: ConTextDocument85    colors: dictionary keyed by ConText category with values valid HTML colors86    87    """88    findingsStr= """<p> %s </p>\n\n\n\n</body>\n</html>"""%" ".join([mark_text(m.graph['__txt'],89                                                 __sort_by_span(m.nodes()),90                                                 colors=colors) for m in get_document_markups(doc)])91    headerStr="""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n\n"""...BingoCard.py
Source:BingoCard.py  
...37        usablesize = size - bordersize * 238        tilesize = int(ceil(usablesize/5))39        fullsquare = Image.new('RGB', (size, size), (255, 255, 255))40       41        def getCategory(number):42            """Gets a category based on its number from 1 to 5"""43            return self.categories[categorymapping[number - 1]]44        print("Picking squares from categories")45        tiles = ((getCategory(2).PickEasy(), getCategory(1).PickEasy(), getCategory(4).PickMedium(), getCategory(3).PickHard(), getCategory(5).PickMedium()),46         (getCategory(1).PickMedium(), getCategory(3).PickMedium(), getCategory(5).PickEasy(), getCategory(4).PickEasy(), getCategory(2).PickHard()),47         (getCategory(5).PickMedium(), getCategory(4).PickEasy(), getCategory(1).PickHard(), getCategory(2).PickMedium(), getCategory(3).PickEasy()),48         (getCategory(4).PickHard(), getCategory(2).PickMedium(), getCategory(3).PickMedium(), getCategory(5).PickEasy(), getCategory(1).PickEasy()),49         (getCategory(3).PickEasy(), getCategory(5).PickHard(), getCategory(2).PickEasy(), getCategory(1).PickMedium(), getCategory(4).PickMedium()))50        for x in range(0, 5):51            for y in range(0, 5):52                print("Drawing square at (" + str(x) + "," + str(y) + ")")53                image = tiles[y][x].render(tilesize)54                fullsquare.paste(image, (bordersize + x * tilesize, bordersize + y * tilesize))55        print("Drawing border")56        drawer = ImageDraw.Draw(fullsquare)57        drawer.rectangle([0, 0, size-1, size-1], None, (0, 0, 0),58                         int(ceil(size * self.BORDER_SIZE * self.BORDER_FILL_PERCENTAGE)))59        if savelocation is None:60            pass61        else:62            print("Saving to", savelocation)63            fullsquare.save(savelocation)...MovieCategories.py
Source:MovieCategories.py  
...15            #grade.append(infos[3])16            #genre.append(infos[4])17            self.movieCategories[infos[0].replace('"','').replace('\xef\xbb\xbf','')] = infos[4];18        print 'Done.'19    def getCategory(self, movieTitle):20        if movieTitle in self.movieCategories:21            return self.movieCategories[movieTitle]22        else:23            return ''24if __name__ == '__main__':25    # THIS HOW TO USE THIS CLASS :26    cat = MovieCategories()27    fname = 'data4/data50.json'28    infos = readFile(fname)29    titles, words, matrix = extractArrays(infos)30    for t in titles:31        print t, cat.getCategory(t)32    #for x in cat.movieCategories:33    #    print x, cat.getCategory(x)34    #print 'Fever Pitch : ', cat.getCategory('Fever Pitch')35    #print 'Star Trek : ', cat.getCategory('Star Trek')36    #print 'Outlander : ', cat.getCategory('Outlander')37    #print 'The Emperor\'s New Groove : ', cat.getCategory('The Emperor\'s New Groove')...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!!
