Best Python code snippet using pandera_python
crystal.js
Source:crystal.js
1/*2Language: Crystal3Author: TSUYUSATO Kitsune <make.just.on@gmail.com>4*/5function(hljs) {6 var NUM_SUFFIX = '(_[uif](8|16|32|64))?';7 var CRYSTAL_IDENT_RE = '[a-zA-Z_]\\w*[!?=]?';8 var RE_STARTER = '!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|' +9 '>>|>|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';10 var CRYSTAL_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\][=?]?';11 var CRYSTAL_KEYWORDS = {12 keyword:13 'abstract alias as as? asm begin break case class def do else elsif end ensure enum extend for fun if ' +14 'include instance_sizeof is_a? lib macro module next nil? of out pointerof private protected rescue responds_to? ' +15 'return require select self sizeof struct super then type typeof union uninitialized unless until when while with yield ' +16 '__DIR__ __END_LINE__ __FILE__ __LINE__',17 literal: 'false nil true'18 };19 var SUBST = {20 className: 'subst',21 begin: '#{', end: '}',22 keywords: CRYSTAL_KEYWORDS23 };24 var EXPANSION = {25 className: 'template-variable',26 variants: [27 {begin: '\\{\\{', end: '\\}\\}'},28 {begin: '\\{%', end: '%\\}'}29 ],30 keywords: CRYSTAL_KEYWORDS31 };32 function recursiveParen(begin, end) {33 var34 contains = [{begin: begin, end: end}];35 contains[0].contains = contains;36 return contains;37 }38 var STRING = {39 className: 'string',40 contains: [hljs.BACKSLASH_ESCAPE, SUBST],41 variants: [42 {begin: /'/, end: /'/},43 {begin: /"/, end: /"/},44 {begin: /`/, end: /`/},45 {begin: '%w?\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},46 {begin: '%w?\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},47 {begin: '%w?{', end: '}', contains: recursiveParen('{', '}')},48 {begin: '%w?<', end: '>', contains: recursiveParen('<', '>')},49 {begin: '%w?/', end: '/'},50 {begin: '%w?%', end: '%'},51 {begin: '%w?-', end: '-'},52 {begin: '%w?\\|', end: '\\|'},53 {begin: /<<-\w+$/, end: /^\s*\w+$/},54 ],55 relevance: 0,56 };57 var Q_STRING = {58 className: 'string',59 variants: [60 {begin: '%q\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},61 {begin: '%q\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},62 {begin: '%q{', end: '}', contains: recursiveParen('{', '}')},63 {begin: '%q<', end: '>', contains: recursiveParen('<', '>')},64 {begin: '%q/', end: '/'},65 {begin: '%q%', end: '%'},66 {begin: '%q-', end: '-'},67 {begin: '%q\\|', end: '\\|'},68 {begin: /<<-'\w+'$/, end: /^\s*\w+$/},69 ],70 relevance: 0,71 };72 var REGEXP = {73 begin: '(' + RE_STARTER + ')\\s*',74 contains: [75 {76 className: 'regexp',77 contains: [hljs.BACKSLASH_ESCAPE, SUBST],78 variants: [79 {begin: '//[a-z]*', relevance: 0},80 {begin: '/', end: '/[a-z]*'},81 {begin: '%r\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},82 {begin: '%r\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},83 {begin: '%r{', end: '}', contains: recursiveParen('{', '}')},84 {begin: '%r<', end: '>', contains: recursiveParen('<', '>')},85 {begin: '%r/', end: '/'},86 {begin: '%r%', end: '%'},87 {begin: '%r-', end: '-'},88 {begin: '%r\\|', end: '\\|'},89 ]90 }91 ],92 relevance: 093 };94 var REGEXP2 = {95 className: 'regexp',96 contains: [hljs.BACKSLASH_ESCAPE, SUBST],97 variants: [98 {begin: '%r\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},99 {begin: '%r\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},100 {begin: '%r{', end: '}', contains: recursiveParen('{', '}')},101 {begin: '%r<', end: '>', contains: recursiveParen('<', '>')},102 {begin: '%r/', end: '/'},103 {begin: '%r%', end: '%'},104 {begin: '%r-', end: '-'},105 {begin: '%r\\|', end: '\\|'},106 ],107 relevance: 0108 };109 var ATTRIBUTE = {110 className: 'meta',111 begin: '@\\[', end: '\\]',112 contains: [113 hljs.inherit(hljs.QUOTE_STRING_MODE, {className: 'meta-string'})114 ]115 };116 var CRYSTAL_DEFAULT_CONTAINS = [117 EXPANSION,118 STRING,119 Q_STRING,120 REGEXP,121 REGEXP2,122 ATTRIBUTE,123 hljs.HASH_COMMENT_MODE,124 {125 className: 'class',126 beginKeywords: 'class module struct', end: '$|;',127 illegal: /=/,128 contains: [129 hljs.HASH_COMMENT_MODE,130 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),131 {begin: '<'} // relevance booster for inheritance132 ]133 },134 {135 className: 'class',136 beginKeywords: 'lib enum union', end: '$|;',137 illegal: /=/,138 contains: [139 hljs.HASH_COMMENT_MODE,140 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),141 ],142 relevance: 10143 },144 {145 className: 'function',146 beginKeywords: 'def', end: /\B\b/,147 contains: [148 hljs.inherit(hljs.TITLE_MODE, {149 begin: CRYSTAL_METHOD_RE,150 endsParent: true151 })152 ]153 },154 {155 className: 'function',156 beginKeywords: 'fun macro', end: /\B\b/,157 contains: [158 hljs.inherit(hljs.TITLE_MODE, {159 begin: CRYSTAL_METHOD_RE,160 endsParent: true161 })162 ],163 relevance: 5164 },165 {166 className: 'symbol',167 begin: hljs.UNDERSCORE_IDENT_RE + '(\\!|\\?)?:',168 relevance: 0169 },170 {171 className: 'symbol',172 begin: ':',173 contains: [STRING, {begin: CRYSTAL_METHOD_RE}],174 relevance: 0175 },176 {177 className: 'number',178 variants: [179 { begin: '\\b0b([01_]*[01])' + NUM_SUFFIX },180 { begin: '\\b0o([0-7_]*[0-7])' + NUM_SUFFIX },181 { begin: '\\b0x([A-Fa-f0-9_]*[A-Fa-f0-9])' + NUM_SUFFIX },182 { begin: '\\b(([0-9][0-9_]*[0-9]|[0-9])(\\.[0-9_]*[0-9])?([eE][+-]?[0-9_]*[0-9])?)' + NUM_SUFFIX}183 ],184 relevance: 0185 }186 ];187 SUBST.contains = CRYSTAL_DEFAULT_CONTAINS;188 EXPANSION.contains = CRYSTAL_DEFAULT_CONTAINS.slice(1); // without EXPANSION189 return {190 aliases: ['cr'],191 lexemes: CRYSTAL_IDENT_RE,192 keywords: CRYSTAL_KEYWORDS,193 contains: CRYSTAL_DEFAULT_CONTAINS194 };...
ScrapeData.js
Source:ScrapeData.js
...24 var phone = {};25 phone.id = agent.url.split(/\//).pop();26 phone.name = body.find('h2').text().trim();27 phone.description = body.find('.description').text().trim();28 phone.availability = c1.find('table:nth-child(1) th:contains("Availability")+td').text().trim().split(/\s*\n\s*/),29 phone.battery = {30 type: c1.find('table:nth-child(2) th:contains("Type")+td').text(),31 talkTime: c1.find('table:nth-child(2) th:contains("Talk time")+td').text(),32 standbyTime: c1.find('table:nth-child(2) th:contains("Standby time")+td').text()33 };34 phone.storage = {35 ram: c1.find('table:nth-child(3) th:contains("RAM")+td').text(),36 flash: c1.find('table:nth-child(3) th:contains("Internal storage")+td').text()37 };38 phone.connectivity = {39 cell: c1.find('table:nth-child(4) th:contains("Network support")+td').text(),40 wifi: c1.find('table:nth-child(4) th:contains("WiFi")+td').text(),41 bluetooth: c1.find('table:nth-child(4) th:contains("Bluetooth")+td').text(),42 infrared: boolean(c1.find('table:nth-child(4) th:contains("Infrared")+td img').attr('src')),43 gps: boolean(c1.find('table:nth-child(4) th:contains("GPS")+td img').attr('src'))44 };45 phone.android = {46 os: c2.find('table:nth-child(1) th:contains("OS Version")+td').text(),47 ui: c2.find('table:nth-child(1) th:contains("UI")+td').text()48 };49 phone.sizeAndWeight = {50 dimensions: c2.find('table:nth-child(2) th:contains("Dimensions")+td').text().trim().split(/\s*\n\s*/),51 weight: c2.find('table:nth-child(2) th:contains("Weight")+td').text().trim()52 };53 phone.display = {54 screenSize: c2.find('table:nth-child(3) th:contains("Screen size")+td').text(),55 screenResolution: c2.find('table:nth-child(3) th:contains("Screen resolution")+td').text(),56 touchScreen: boolean(c2.find('table:nth-child(3) th:contains("Touch screen")+td img').attr('src'))57 };58 phone.hardware = {59 fmRadio: boolean(c2.find('table:nth-child(4) th:contains("FM Radio")+td img').attr('src')),60 physicalKeyboard: c2.find('table:nth-child(4) th:contains("Physical keyboard")+td img').attr('src'),61 accelerometer: boolean(c2.find('table:nth-child(4) th:contains("Accelerometer")+td img').attr('src')),62 cpu: c2.find('table:nth-child(4) th:contains("CPU")+td').text(),63 usb: c2.find('table:nth-child(4) th:contains("USB")+td').text(),64 audioJack: c2.find('table:nth-child(4) th:contains("Audio / headphone jack")+td').text()65 };66 phone.camera= {67 primary: c2.find('table:nth-child(5) th:contains("Primary")+td').text(),68 features: c2.find('table:nth-child(5) th:contains("Features")+td').text().trim().split(/\s*\n\s*/)69 };70 phone.additionalFeatures = c2.find('table:nth-child(6) td').text();71 phone.images = [];72 body.find('#thumbs img').each(function(){73 var imgUrl = 'http://www.google.com' + jquery(this).attr('src');74 phone.images.push({75 small: imgUrl,76 large: imgUrl.replace(/\/small$/, '/large')77 });78 });79 fs.writeSync(fs.openSync(baseDir + phone.id + '.json', 'w'), JSON.stringify(phone));80 } else {81 var age = 0;82 body.find('ul.phonelist li.list').each(function(a){...
ruby.js
Source:ruby.js
1/*2Language: Ruby3Author: Anton Kovalyov <anton@kovalyov.net>4Contributors: Peter Leonov <gojpeg@yandex.ru>, Vasily Polovnyov <vast@whiteants.net>, Loren Segal <lsegal@soen.ca>, Pascal Hurni <phi@ruby-reactive.org>, Cedric Sohrauer <sohrauer@googlemail.com>5Category: common6*/7function(hljs) {8 var RUBY_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?';9 var RUBY_KEYWORDS =10 'and false then defined module in return redo if BEGIN retry end for true self when ' +11 'next until do begin unless END rescue nil else break undef not super class case ' +12 'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor';13 var YARDOCTAG = {14 className: 'doctag',15 begin: '@[A-Za-z]+'16 };17 var IRB_OBJECT = {18 className: 'value',19 begin: '#<', end: '>'20 };21 var COMMENT_MODES = [22 hljs.COMMENT(23 '#',24 '$',25 {26 contains: [YARDOCTAG]27 }28 ),29 hljs.COMMENT(30 '^\\=begin',31 '^\\=end',32 {33 contains: [YARDOCTAG],34 relevance: 1035 }36 ),37 hljs.COMMENT('^__END__', '\\n$')38 ];39 var SUBST = {40 className: 'subst',41 begin: '#\\{', end: '}',42 keywords: RUBY_KEYWORDS43 };44 var STRING = {45 className: 'string',46 contains: [hljs.BACKSLASH_ESCAPE, SUBST],47 variants: [48 {begin: /'/, end: /'/},49 {begin: /"/, end: /"/},50 {begin: /`/, end: /`/},51 {begin: '%[qQwWx]?\\(', end: '\\)'},52 {begin: '%[qQwWx]?\\[', end: '\\]'},53 {begin: '%[qQwWx]?{', end: '}'},54 {begin: '%[qQwWx]?<', end: '>'},55 {begin: '%[qQwWx]?/', end: '/'},56 {begin: '%[qQwWx]?%', end: '%'},57 {begin: '%[qQwWx]?-', end: '-'},58 {begin: '%[qQwWx]?\\|', end: '\\|'},59 {60 // \B in the beginning suppresses recognition of ?-sequences where ?61 // is the last character of a preceding identifier, as in: `func?4`62 begin: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/63 }64 ]65 };66 var PARAMS = {67 className: 'params',68 begin: '\\(', end: '\\)',69 keywords: RUBY_KEYWORDS70 };71 var RUBY_DEFAULT_CONTAINS = [72 STRING,73 IRB_OBJECT,74 {75 className: 'class',76 beginKeywords: 'class module', end: '$|;',77 illegal: /=/,78 contains: [79 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),80 {81 className: 'inheritance',82 begin: '<\\s*',83 contains: [{84 className: 'parent',85 begin: '(' + hljs.IDENT_RE + '::)?' + hljs.IDENT_RE86 }]87 }88 ].concat(COMMENT_MODES)89 },90 {91 className: 'function',92 beginKeywords: 'def', end: '$|;',93 contains: [94 hljs.inherit(hljs.TITLE_MODE, {begin: RUBY_METHOD_RE}),95 PARAMS96 ].concat(COMMENT_MODES)97 },98 {99 className: 'constant',100 begin: '(::)?(\\b[A-Z]\\w*(::)?)+',101 relevance: 0102 },103 {104 className: 'symbol',105 begin: hljs.UNDERSCORE_IDENT_RE + '(\\!|\\?)?:',106 relevance: 0107 },108 {109 className: 'symbol',110 begin: ':',111 contains: [STRING, {begin: RUBY_METHOD_RE}],112 relevance: 0113 },114 {115 className: 'number',116 begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',117 relevance: 0118 },119 {120 className: 'variable',121 begin: '(\\$\\W)|((\\$|\\@\\@?)(\\w+))'122 },123 { // regexp container124 begin: '(' + hljs.RE_STARTERS_RE + ')\\s*',125 contains: [126 IRB_OBJECT,127 {128 className: 'regexp',129 contains: [hljs.BACKSLASH_ESCAPE, SUBST],130 illegal: /\n/,131 variants: [132 {begin: '/', end: '/[a-z]*'},133 {begin: '%r{', end: '}[a-z]*'},134 {begin: '%r\\(', end: '\\)[a-z]*'},135 {begin: '%r!', end: '![a-z]*'},136 {begin: '%r\\[', end: '\\][a-z]*'}137 ]138 }139 ].concat(COMMENT_MODES),140 relevance: 0141 }142 ].concat(COMMENT_MODES);143 SUBST.contains = RUBY_DEFAULT_CONTAINS;144 PARAMS.contains = RUBY_DEFAULT_CONTAINS;145 var SIMPLE_PROMPT = "[>?]>";146 var DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+>";147 var RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>";148 var IRB_DEFAULT = [149 {150 begin: /^\s*=>/,151 className: 'status',152 starts: {153 end: '$', contains: RUBY_DEFAULT_CONTAINS154 }155 },156 {157 className: 'prompt',158 begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')',159 starts: {160 end: '$', contains: RUBY_DEFAULT_CONTAINS161 }162 }163 ];164 return {165 aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'],166 keywords: RUBY_KEYWORDS,167 contains: COMMENT_MODES.concat(IRB_DEFAULT).concat(RUBY_DEFAULT_CONTAINS)168 };...
website.tour.event_sale.js
Source:website.tour.event_sale.js
...9},10 [11 {12 content: "Go to the `Events` page",13 trigger: 'a[href*="/event"]:contains("Conference on Business Apps"):first',14 },15 {16 content: "Select 1 unit of `Standard` ticket type",17 extra_trigger: '#wrap:not(:has(a[href*="/event"]:contains("Conference on Business Apps")))',18 trigger: 'select:eq(0)',19 run: 'text 1',20 },21 {22 content: "Select 2 units of `VIP` ticket type",23 extra_trigger: 'select:eq(0):has(option:contains(1):propSelected)',24 trigger: 'select:eq(1)',25 run: 'text 2',26 },27 {28 content: "Click on `Order Now` button",29 extra_trigger: 'select:eq(1):has(option:contains(2):propSelected)',30 trigger: '.btn-primary:contains("Register Now")',31 },32 {33 content: "Fill attendees details",34 trigger: 'form[id="attendee_registration"] .btn:contains("Continue")',35 run: function () {36 $("input[name='1-name']").val("Att1");37 $("input[name='1-phone']").val("111 111");38 $("input[name='1-email']").val("att1@example.com");39 $("input[name='2-name']").val("Att2");40 $("input[name='2-phone']").val("222 222");41 $("input[name='2-email']").val("att2@example.com");42 $("input[name='3-name']").val("Att3");43 $("input[name='3-phone']").val("333 333");44 $("input[name='3-email']").val("att3@example.com");45 },46 },47 {48 content: "Validate attendees details",49 extra_trigger: "input[name='1-name'], input[name='2-name'], input[name='3-name']",50 trigger: 'button:contains("Continue")',51 },52 {53 content: "Check that the cart contains exactly 3 triggers",54 trigger: 'a:has(.my_cart_quantity:containsExact(3))',55 run: function () {}, // it's a check56 },57 {58 content: "go to cart",59 trigger: 'a:contains(Return to Cart)',60 },61 {62 content: "Modify the cart to add 1 unit of `VIP` ticket type",63 extra_trigger: "#cart_products:contains(Standard):contains(VIP)",64 trigger: "#cart_products tr:contains(VIP) .fa-plus",65 },66 {67 content: "Now click on `Process Checkout`",68 extra_trigger: 'a:has(.my_cart_quantity):contains(4)',69 trigger: '.btn-primary:contains("Process Checkout")'70 },71 {72 content: "Complete the checkout",73 trigger: 'a[href="/shop/confirm_order"]:contains("Confirm")',74 },75 {76 content: "Check that the subtotal is 5,500.00 USD", // this test will fail if the currency of the main company is not USD77 trigger: '#order_total_untaxed .oe_currency_value:contains("5,500.00")',78 run: function () {}, // it's a check79 },80 {81 content: "Select `Wire Transfer` payment method",82 trigger: '#payment_method label:contains("Wire Transfer")',83 },84 {85 content: "Pay",86 //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs87 extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))',88 trigger: 'button[id="o_payment_form_pay"]:visible',89 },90 {91 content: "Last step",92 trigger: '.oe_website_sale:contains("Thank you for your order")',93 timeout: 30000,94 }95 ]96);...
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!!