How to use to_script method in pandera

Best Python code snippet using pandera_python

main.py

Source:main.py Github

copy

Full Screen

...20 def add_form(self, form):21 self.forms.append(form)2223 def __str__(self):24 return ''.join([x.to_script() for x in self.forms])2526 def to_script(self):27 return self.__str__()2829 def to_file(self):30 with codecs.open('%s/grub.cfg' % (OUTDIR), 'w', encoding='utf-8') as out:31 for f in self.forms:32 out.write('''33menuentry "%s >>" {34 configfile $prefix/%s.cfg35}36 ''' % (f.title.replace('"', '\\"'), f.id))373839class Form:40 pass4142 def __init__(self, id, title):43 self.id = id44 self.title = title45 self.subforms = []46 self.items = []47 #print('[ %s ]' % (self.title))4849 def __str__(self):50 return '''51submenu "%s >>" {52 %s53 %s54 sleep 055}56 ''' % (self.title.replace('"', '\\"'), ''.join([x.to_script() for x in self.subforms]), ''.join([x.to_script() for x in self.items]))5758 def to_script(self):59 return self.__str__()60 61 def to_file(self):62 with codecs.open('%s/%s.cfg' % (OUTDIR, self.id), 'w', encoding='utf-8') as out:63 for f in self.subforms:64 f.to_file()65 out.write('''66submenu "%s >>" {67 configfile $prefix/%s.cfg68}69 ''' % (f.title.replace('"', '\\"'), f.id))70 for i in self.items:71 out.write(i.to_script())7273 def add_item(self, item):74 self.items.append(item)7576 def add_subforms(self, form):77 self.subforms.append(form)787980class Item:81 pass8283 def __init__(self, name, addr):84 self.name = name85 self.addr = addr86 self.options = []87 #print('\t >> %s' % (self.name))8889 def __str__(self):90 return '''91submenu "%s" {92 set option=%s93 setup_var $option94 echo95 echo Press [enter] key to continue...96 read97 %s98 sleep 099}100 ''' % (self.name.replace('"', '\\"'), self.addr, ''.join([x.to_script() for x in self.options]))101102 def to_script(self):103 return self.__str__()104105 def add_option(self, option):106 self.options.append(option)107108109class Option:110 pass111112 def __init__(self, name, value, default=False):113 self.name = name114 self.value = value115 self.default = default116 #print('\t\t -- %s = %s (%s)' % (self.name, self.value, self.default))117118 def __str__(self):119 return '''120submenu "%s%s" {121 setup_var $option %s122 echo123 echo Press [enter] key to continue...124 read125}126 ''' % (self.name.replace('"', '\\"'), ' (default)' if self.default else '', self.value)127128 def to_script(self):129 return self.__str__()130131132if __name__ == '__main__':133 with codecs.open('./_Setup/setup_extr.txt', 'r', encoding='cp437') as txt:134 contents = []135 contents = txt.readlines()136 # for idx1 in range(0, len(contents)):137 # contents[idx1] = contents[idx1].decode('cp437')138 # print(contents[idx1])139 formset = {}140 refs = {}141 stacks = []142 for idx1 in range(0, len(contents)):143 if contents[idx1][8:].strip().startswith('Form Set:'):144 stacks.append(idx1)145 elif contents[idx1][8:].strip().startswith('Form:'):146 stacks.append(idx1)147 elif contents[idx1][8:].strip().startswith('End Form Set'):148 idx0 = stacks.pop()149 print('Form Set ', idx0, idx1)150 elif contents[idx1][8:].strip().startswith('End Form'):151 idx0 = stacks.pop()152 print('Form ', idx0, idx1)153 form = None154 try:155 regx = re.compile('^Form: (.+?), FormId: (.+?) \{.+\}$')156 vals = regx.findall(contents[idx0][8:].strip())[0]157 form = Form(id=vals[1], title=vals[0])158 if refs.has_key(vals[1]):159 refs[vals[1]].add_subforms(form)160 else:161 formset[vals[1]] = form162 except:163 continue164 if form is None:165 continue166 if idx1 - idx0 > 1:167 item = None168 for line in contents[idx0+1:idx1]:169 if line[8:].strip().startswith('One Of:'):170 item = None171 option = None172 try:173 regx = re.compile(174 '^One Of: (.+?), VarStoreInfo \(VarOffset/VarName\): (.+?), VarStore: (.+?), QuestionId: (.+?), Size: (.+?), Min: (.+?), Max (.+?), Step: (.+?) \{.+\}$')175 vals = regx.findall(line[8:].strip())[0]176 item = Item(name=vals[0], addr=vals[1])177 form.add_item(item)178 except:179 continue180 elif line[8:].strip().startswith('One Of Option:'):181 option = None182 if item is None:183 continue184 try:185 regx = re.compile(186 '^One Of Option: (.+?), Value \((.+?) bit\): (.+?) (\(default.*?\))?[ ]?\{.+\}$')187 vals = regx.findall(line[8:].strip())[0]188 option = Option(name=vals[0], value=vals[2], default=(len(vals[3]) > 0))189 item.add_option(option)190 except:191 continue192 elif line[8:].strip().startswith('End One Of'):193 item = None194 option = None195 elif line[8:].strip().startswith('Ref:'):196 item = None197 option = None198 try:199 regx = re.compile(200 '^Ref: (.+?), VarStoreInfo \(VarOffset/VarName\): (.+?), VarStore: (.+?), QuestionId: (.+?), FormId: (.+?) \{.+\}')201 vals = regx.findall(line[8:].strip())[0]202 if formset.has_key(vals[4]):203 form.add_subforms(formset.pop(vals[4]))204 else:205 refs[vals[4]] = form206 except:207 continue208209 # with codecs.open('%s/grub.cfg' % (OUTDIR), 'w', encoding='utf-8') as out:210 # fs = FormSet()211 # for form in formset.values():212 # fs.add_form(form)213 # out.write(fs.to_script())214215 for form in formset.values():216 form.to_file()217 fs = FormSet()218 for form in formset.values():219 fs.add_form(form) ...

Full Screen

Full Screen

unicodefuckery

Source:unicodefuckery Github

copy

Full Screen

1#!/usr/bin/env python32import sys3import unicodedata4import functools5import random6import collections7# http://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms8to_fullwidth = dict()9to_fullwidth.update((i, i + 0xfee0) for i in range(0x21, 0x7f))10to_fullwidth.update({0x20: 0x3000, 0x2D: 0x2212}) # space and minus11# http://en.wikipedia.org/wiki/Enclosed_Alphanumerics12to_circles = dict()13to_circles.update(zip(range(ord('a'), ord('z')+1),range(0x249c, 0x24b5+1)))14to_circles.update(zip(range(ord('A'), ord('Z')+1),range(0x24b6, 0x24cf+1)))15to_circles.update(zip(range(ord('1'), ord('9')+1),range(0x2460, 0x2468+1)))16to_circles.update({ord('0'): 0x24ea})17# http://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols18to_bold = dict() #19to_bold.update(zip(range(ord('a'), ord('z')+1),range(0x1d41a, 0x1d433+1)))20to_bold.update(zip(range(ord('A'), ord('Z')+1),range(0x1d400, 0x1d419+1)))21to_italic = dict() #22to_italic.update(zip(range(ord('a'), ord('z')+1),range(0x1d44e, 0x1d467+1)))23to_italic.update(zip(range(ord('A'), ord('Z')+1),range(0x1d434, 0x1d44d+1)))24to_italic[ord('h')] = 0x210e25to_bold_italic = dict() # 26to_bold_italic.update(zip(range(ord('a'), ord('z')+1),range(0x1d482, 0x1d49b+1)))27to_bold_italic.update(zip(range(ord('A'), ord('Z')+1),range(0x1d468, 0x1d481+1)))28to_script = dict() #29to_script.update(zip(range(ord('a'), ord('z')+1),range(0x1d4b6, 0x1d4cf+1)))30to_script.update(zip(range(ord('A'), ord('Z')+1),range(0x1d49c, 0x1d4b5+1)))31to_script[ord('B')] = 0x212c32to_script[ord('E')] = 0x213033to_script[ord('F')] = 0x213134to_script[ord('H')] = 0x210b35to_script[ord('I')] = 0x211036to_script[ord('L')] = 0x211237to_script[ord('M')] = 0x213338to_script[ord('R')] = 0x211b39to_script[ord('e')] = 0x212f40to_script[ord('g')] = 0x210a41to_script[ord('o')] = 0x213442to_script_bold = dict() # 43to_script_bold.update(zip(range(ord('a'), ord('z')+1),range(0x1d4ea, 0x1d503+1)))44to_script_bold.update(zip(range(ord('A'), ord('Z')+1),range(0x1d4d0, 0x1d4e9+1)))45# todo + missing46to_fraktur = dict()47to_fraktur.update(zip(range(ord('a'), ord('z')+1),range(0x1d51e, 0x1d537+1)))48to_fraktur.update(zip(range(ord('A'), ord('Z')+1),range(0x1d504, 0x1d51d+1)))49to_fraktur[ord('C')] = 0x212d50to_fraktur[ord('H')] = 0x210c51to_fraktur[ord('I')] = 0x211152to_fraktur[ord('R')] = 0x211c53to_fraktur[ord('Z')] = 0x212854# todo + missing55to_doublestruck = dict()56to_doublestruck.update(zip(range(ord('a'), ord('z')+1),range(0x1d552, 0x1d56b+1)))57to_doublestruck.update(zip(range(ord('A'), ord('Z')+1),range(0x1d538, 0x1d551+1)))58to_doublestruck[ord('C')] = 0x210259to_doublestruck[ord('H')] = 0x210d60to_doublestruck[ord('N')] = 0x211561to_doublestruck[ord('P')] = 0x211962to_doublestruck[ord('Q')] = 0x211a63to_doublestruck[ord('R')] = 0x211d64to_doublestruck[ord('Z')] = 0x212465to_fraktur_bold = dict()66to_fraktur_bold.update(zip(range(ord('a'), ord('z')+1),range(0x1d586, 0x1d59f+1)))67to_fraktur_bold.update(zip(range(ord('A'), ord('Z')+1),range(0x1d56c, 0x1d585+1)))68to_sans = dict()69to_sans.update(zip(range(ord('a'), ord('z')+1),range(0x1d5ba, 0x1d5d3+1)))70to_sans.update(zip(range(ord('A'), ord('Z')+1),range(0x1d5a0, 0x1d5b9+1)))71to_sans_bold = dict()72to_sans_bold.update(zip(range(ord('a'), ord('z')+1),range(0x1d5ee, 0x1d607+1)))73to_sans_bold.update(zip(range(ord('A'), ord('Z')+1),range(0x1d5d4, 0x1d5ed+1)))74to_sans_italic = dict()75to_sans_italic.update(zip(range(ord('a'), ord('z')+1),range(0x1d622, 0x1d63b+1)))76to_sans_italic.update(zip(range(ord('A'), ord('Z')+1),range(0x1d608, 0x1d621+1)))77to_sans_bold_italic = dict()78to_sans_bold_italic.update(zip(range(ord('a'), ord('z')+1),range(0x1d656, 0x1d66f+1)))79to_sans_bold_italic.update(zip(range(ord('A'), ord('Z')+1),range(0x1d63c, 0x1d655+1)))80to_monospace = dict()81to_monospace.update(zip(range(ord('a'), ord('z')+1),range(0x1d68a, 0x1d6a4+1)))82to_monospace.update(zip(range(ord('A'), ord('Z')+1),range(0x1d670, 0x1d689+1)))83# http://en.wikipedia.org/wiki/Combining_character84combining = []85combining.extend(range(0x300, 0x36f+1)) # Combining Diacritical Marks86combining.extend(range(0x1dc0, 0x1de6+1)) # Combining Diacritical Marks Supplement87combining.extend(range(0x1dfc, 0x1dff+1)) 88combining.extend(range(0x20d0, 0x20f0+1)) # Combining Diacritical Marks for Symbols89combining = [chr(x) for x in combining]90def make_combining(combine_chars):91 def _combine(line):92 out = []93 for char in line:94 out.append(char)95 if unicodedata.category(char).startswith(('L', 'N')):96 out.extend(combine_chars())97 return "".join(out)98 return _combine99fuckery = collections.OrderedDict([100 ('fullwidth', lambda line: line.translate(to_fullwidth)),101 ('circles', lambda line: line.translate(to_circles)),102 ('bold', lambda line: line.translate(to_bold)),103 ('italic', lambda line: line.translate(to_italic)),104 ('bold_italic', lambda line: line.translate(to_bold_italic)),105 ('script', lambda line: line.translate(to_script)),106 ('script_bold', lambda line: line.translate(to_script_bold)),107 ('fraktur', lambda line: line.translate(to_fraktur)),108 ('doublestruck', lambda line: line.translate(to_doublestruck)),109 ('fraktur_bold', lambda line: line.translate(to_fraktur_bold)),110 ('sans', lambda line: line.translate(to_sans)),111 ('sans_bold', lambda line: line.translate(to_sans_bold)),112 ('sans_italic', lambda line: line.translate(to_sans_italic)),113 ('sans_bold_italic', lambda line: line.translate(to_sans_bold_italic)),114 ('monospace', lambda line: line.translate(to_monospace)),115 ('umlaut', make_combining(lambda:["\u0308"])),116 ('combine1', make_combining(lambda: random.sample(combining,1))),117 ('combine2', make_combining(lambda: random.sample(combining,2))),118 ('combiner', make_combining(lambda: random.sample(combining,random.randint(0,4)))),119 ('upper', lambda line: line.upper()),120 ('lower', lambda line: line.lower()),121])122if __name__ == '__main__':123 if sys.argv[1:]:124 fns = [fuckery[name] for name in sys.argv[1:]]125 while True:126 line = sys.stdin.readline()127 for fn in fns:128 line = fn(line)129 sys.stdout.write(line) 130 if not line:131 break132 else:133 print("usage: {} <filter> <filter> <filter>".format(sys.argv[0]))...

Full Screen

Full Screen

IO3.py

Source:IO3.py Github

copy

Full Screen

1from sys import argv2from os.path import exists3script, from_script, to_script=argv4print(f"Copying from {from_script} to {to_script}")5in_script=open(from_script)6in_data=in_script.read()7print(f"The input file is {len(in_data)} bytes long")8print(f"Does the output file exist? {exists(to_script)}")9print("Ready, hit RETURN to continue, CTRL-C to abort.")10input()11out_file = open(to_script, 'w')12out_file.write(in_data)13print("Alright, all done.")14in_script.close()...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful