Best Python code snippet using fMBT_python
ShuiPreview.py
Source:ShuiPreview.py
...36 "default_value": "shui"37 }38 }39 }"""40 def addScreenshot(self, img, width, height, img_type):41 result = ""42 b_image = img.scaled(width, height, Qt.KeepAspectRatio)43 img_size = b_image.size()44 result += img_type45 datasize = 046 for i in range(img_size.height()):47 for j in range(img_size.width()):48 pixel_color = b_image.pixelColor(j, i)49 r = pixel_color.red() >> 350 g = pixel_color.green() >> 251 b = pixel_color.blue() >> 352 rgb = (r << 11) | (g << 5) | b53 strHex = "%x" % rgb54 if len(strHex) == 3:55 strHex = '0' + strHex[0:3]56 elif len(strHex) == 2:57 strHex = '00' + strHex[0:2]58 elif len(strHex) == 1:59 strHex = '000' + strHex[0:1]60 if strHex[2:4] != '':61 result += strHex[2:4]62 datasize += 263 if strHex[0:2] != '':64 result += strHex[0:2]65 datasize += 266 if datasize >= 50:67 datasize = 068 result += '\rM10086 ;'69 if i == img_size.height() - 1:70 result += "\r"71 return result72 73 def generate_mks(self, sz, data):74 image = Snapshot.snapshot(width = 900, height = 900) 75 if sz == "50":76 pv = self.addScreenshot(image, 50, 50, ";simage:")77 else:78 pv = self.addScreenshot(image, 100, 100, ";simage:")79 pv = pv + self.addScreenshot(image, 200, 200, ";;gimage:")80 data.insert(0, pv)81 return data82 83 def generate_shui(self, sz, data):84 image = Snapshot.snapshot(width = 900, height = 900)85 pv=""86 if sz == "50":87 pv=pv+";SHUI PREVIEW 50x50\n" + self.generate(image, 50)88 else:89 pv=pv+";SHUI PREVIEW 100x100\n" + self.generate(image, 100)90 pv=pv+self.generate(image, 200)91 data.insert(0, pv)92 return data93 ...
urls.py
Source:urls.py
1from django.conf.urls import patterns, include, url2from django.contrib import admin3from django.conf import settings4from bcapp.views import main, user, trade, database, post_comment, display_meta, search, regform, a, login, me, logout, register, addcomment, edittext, addmonster, addtradepost, edittradepost, editmonster, deletetradepost, deletemonster, addlikeu, addliked, addlikep, screenshots, deletescreenshot, addscreenshot, removelikep, messages_mine, messages_other, accepttrade, addoffer, moremonsters, removelikeu, morecomments5urlpatterns = patterns('',6 # Examples:7 # url(r'^$', 'Mydjango.views.home', name='home'),8 # url(r'^blog/', include('blog.urls')),9 url(r'^user/(\d{1,10})/$', user),10 url(r'^main/(\d{1,10})/$', main),11 url(r'^trade/(\d{1,10})/$', trade),12 url(r'^database/(\d{1,10})/$', database),13 url(r'^post/(\d{1,10})/$', post_comment),14 url(r'^admin/', include(admin.site.urls)),15 url(r'^meta/$', display_meta),16 url(r'^search/$', search),17 url(r'^auth/$', regform),18 url(r'^a/$', a),19 url(r'^login/$', login),20 url(r'^logout/$', logout),21 url(r'^user/$', me),22 url(r'^register/$', register),23 url(r'^addcomment/(\d{1,10})/$', addcomment),24 url(r'^edittext/$', edittext),25 url(r'^addmonster/$', addmonster),26 url(r'^addtradepost/$', addtradepost),27 url(r'^edittradepost/$', edittradepost),28 url(r'^deletetradepost/$', deletetradepost),29 url(r'^editmonster/$', editmonster),30 url(r'^deletemonster/$', deletemonster),31 url(r'^deletescreenshot/$', deletescreenshot),32 url(r'^addscreenshot/$', addscreenshot),33 url(r'^addlikeu/$', addlikeu),34 url(r'^addliked/$', addliked),35 url(r'^addlikep/$', addlikep),36 url(r'^addoffer/$', addoffer),37 url(r'^accepttrade/$', accepttrade),38 url(r'^removelikep/$', removelikep),39 url(r'^removelikeu/$', removelikeu),40 url(r'^screenshots/(\d{1,10})/$', screenshots),41 url(r'^messages/(\d{1,10})/mine/$', messages_mine),42 url(r'^messages/(\d{1,10})/other/$', messages_other),43 url(r'^moremonsters/$', moremonsters),44 url(r'^morecomments/$', morecomments),45)46if settings.DEBUG:47 import debug_toolbar48 urlpatterns += patterns('',49 url(r'^__debug__/', include(debug_toolbar.urls)),50 )51if settings.DEBUG:52 # static files (images, css, javascript, etc.)53 urlpatterns += patterns('',54 (r'^media/(?P<path>.*)$', 'django.views.static.serve', {...
commonSteps.py
Source:commonSteps.py
1import pytest2def addMessage(message):3 pytest.globalDictionary['currentStepOutputs'].append(message)4# def addScreenshot():...
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!!