How to use convert_line method in localstack

Best Python code snippet using localstack_python

format2format.py

Source:format2format.py Github

copy

Full Screen

...24 "*":"**",25 "/":"_"}26#--- unsymetrical rule27RULE_LINK = {"[[|]]":"!(|)"}28def convert_line(stri):29 newstr = ""30 cursor = 031 for key in RULE_HEAD:32 if stri.startswith(key):33 newstr = stri.replace(key, RULE_HEAD[key])34 return newstr35 newstr = stri36 for key in RULE_LINE:37 le = len(key)38 inds = newstr.find(key)39 inde = newstr.find(key, inds+le)40 if inds != -1 \41 and inde !=-1 \42 and newstr[inds+le] != " " \43 and newstr[inde-le] != " " \44 and (inds == 0 or newstr[inds-1] == " ") \45 and (inde == len(newstr)-1 or newstr[inde+le]==" "):46 rep = RULE_LINE[key]47 newstr = newstr.replace(key, rep, 2)48 for key in RULE_LINK:49 bkey = key.split("|")[0]50 leb = len(bkey)51 ekey = key.split("|")[1]52 lee = len(ekey)53 inds = newstr.find(bkey)54 inde = newstr.find(ekey, inds+1)55 if inds != -1 and inde !=-1 \56 and newstr[inds+leb] != " " \57 and newstr[inde-1] != " " \58 and (inds == 0 or newstr[inds-1] == " ") \59 and (inde == len(newstr)-lee or newstr[inde+lee]==" "):60 newstr = newstr.replace(bkey, RULE_LINK[key].split("|")[0])61 newstr = newstr.replace(ekey, RULE_LINK[key].split("|")[1])62 return newstr63def convert(sourcefile, targetfile):64 """ Convert """65 input = codecs.open(sourcefile, mode="r", encoding="utf-8", errors='ignore')66 output = codecs.open(targetfile, mode="w", encoding="utf-8")67 content = input.readlines()68 for line in content:69 output.write(convert_line(line))70 input.close()71 output.close()72def test():73 print(convert_line("** Titre2"))74 print(convert_line("* Titre 1"))75 print(convert_line("*** Titre 3 et oula"))76 print(convert_line("**** Titre 4Test et olé"))77 print(convert_line("***** Titre 5"))78 print(convert_line("*C'est en bold*"))79 print(convert_line("* C'est pas du bold c'est un titre*"))80 print(convert_line(" * C'est pas du bold 1*"))81 print(convert_line(" *C'est pas du bold 2 *"))82 print(convert_line("Du *bold avec du texte* dans un autre texte"))83 print(convert_line("Blah blah _underligned here_"))84 print(convert_line("Blah blah _underligned here_ ggsgsg"))85 print(convert_line("[[/un/lien/vers/le/paradis.png]]"))86 print(convert_line("[[ /un/lien/vers/le/paradis.png]]"))87 print(convert_line("[[/un/lien/vers/le/paradis.png ]]"))88 print(convert_line("du texte [[/un/lien/vers/le/paradis.png]] encore du texte"))89 print(convert_line("du texte avec un lien fichier file:../toto/titi.txt "))90 print(convert_line("du texte avec un lien fichier file:../toto/titi.txt"))91 92def ask_for_input_dir(rootdir, msg):93 dirname = input(msg)94 fulldirname = os.path.join(rootdir, dirname)95 while True:96 if os.path.isdir(fulldirname):97 return fulldirname98 else:99 print(fulldirname + " is not a valid directory. Try again...")100 101def ask_for_input_file(rootdir, msg):102 while True:103 filename = input(msg)104 fullfilename = os.path.join(rootdir, filename)...

Full Screen

Full Screen

zim2md.py

Source:zim2md.py Github

copy

Full Screen

...19RULE_LINE = {"__":"_",20 "/":"_"}21#--- unsymetrical rule22RULE_LINK = {"[[|]]":"[Lien](|)"}23def convert_line(stri):24 newstr = ""25 cursor = 026 for key in RULE_HEAD:27 if stri.startswith(key):28 newstr = stri.replace(key, RULE_HEAD[key])29 return newstr30 newstr = stri31 for key in RULE_LINE:32 le = len(key)33 inds = newstr.find(key)34 inde = newstr.find(key, inds+le)35 if inds != -1 \36 and inde !=-1 \37 and newstr[inds+le] != " " \38 and newstr[inde-le] != " " \39 and (inds == 0 or newstr[inds-1] == " ") \40 and (inde == len(newstr)-1 or newstr[inde+le]==" "):41 rep = RULE_LINE[key]42 newstr = newstr.replace(key, rep, 2)43 for key in RULE_LINK:44 bkey = key.split("|")[0]45 leb = len(bkey)46 ekey = key.split("|")[1]47 lee = len(ekey)48 inds = newstr.find(bkey)49 inde = newstr.find(ekey, inds+1)50 if inds != -1 and inde !=-1 \51 and newstr[inds+leb] != " " \52 and newstr[inde-1] != " " \53 and (inds == 0 or newstr[inds-1] == " ") \54 and (inde == len(newstr)-lee or newstr[inde+lee]==" "):55 newstr = newstr.replace(bkey, RULE_LINK[key].split("|")[0])56 newstr = newstr.replace(ekey, RULE_LINK[key].split("|")[1])57 return newstr58def convert(sourcefile, targetfile):59 """ Convert """60 input = codecs.open(sourcefile, mode="r", encoding="utf-8", errors='ignore')61 output = codecs.open(targetfile, mode="w", encoding="utf-8")62 content = input.readlines()63 for line in content:64 output.write(convert_line(line))65 input.close()66 output.close()67def test():68 print(convert_line("** Titre2"))69 print(convert_line("* Titre 1"))70 print(convert_line("*** Titre 3 et oula"))71 print(convert_line("**** Titre 4Test et olé"))72 print(convert_line("***** Titre 5"))73 print(convert_line("*C'est en bold*"))74 print(convert_line("* C'est pas du bold c'est un titre*"))75 print(convert_line(" * C'est pas du bold 1*"))76 print(convert_line(" *C'est pas du bold 2 *"))77 print(convert_line("Du *bold avec du texte* dans un autre texte"))78 print(convert_line("Blah blah _underligned here_"))79 print(convert_line("Blah blah _underligned here_ ggsgsg"))80 print(convert_line("[[/un/lien/vers/le/paradis.png]]"))81 print(convert_line("[[ /un/lien/vers/le/paradis.png]]"))82 print(convert_line("[[/un/lien/vers/le/paradis.png ]]"))83 print(convert_line("du texte [[/un/lien/vers/le/paradis.png]] encore du texte"))84 print(convert_line("du texte avec un lien fichier file:../toto/titi.txt "))85 print(convert_line("du texte avec un lien fichier file:../toto/titi.txt"))86 87def ask_for_input_dir(rootdir, msg):88 dirname = input(msg)89 fulldirname = os.path.join(rootdir, dirname)90 while True:91 if os.path.isdir(fulldirname):92 return fulldirname93 else:94 print(fulldirname + " is not a valid directory. Try again...")95 96def ask_for_input_file(rootdir, msg):97 while True:98 filename = input(msg)99 fullfilename = os.path.join(rootdir, filename)...

Full Screen

Full Screen

org2md.py

Source:org2md.py Github

copy

Full Screen

...19 "*":"**",20 "/":"_"}21#--- unsymetrical rule22RULE_LINK = {"[[|]]":"!(|)"}23def convert_line(stri):24 newstr = ""25 cursor = 026 for key in RULE_HEAD:27 if stri.startswith(key):28 newstr = stri.replace(key, RULE_HEAD[key])29 return newstr30 newstr = stri31 for key in RULE_LINE:32 le = len(key)33 inds = newstr.find(key)34 inde = newstr.find(key, inds+le)35 if inds != -1 \36 and inde !=-1 \37 and newstr[inds+le] != " " \38 and newstr[inde-le] != " " \39 and (inds == 0 or newstr[inds-1] == " ") \40 and (inde == len(newstr)-1 or newstr[inde+le]==" "):41 rep = RULE_LINE[key]42 newstr = newstr.replace(key, rep, 2)43 for key in RULE_LINK:44 bkey = key.split("|")[0]45 leb = len(bkey)46 ekey = key.split("|")[1]47 lee = len(ekey)48 inds = newstr.find(bkey)49 inde = newstr.find(ekey, inds+1)50 if inds != -1 and inde !=-1 \51 and newstr[inds+leb] != " " \52 and newstr[inde-1] != " " \53 and (inds == 0 or newstr[inds-1] == " ") \54 and (inde == len(newstr)-lee or newstr[inde+lee]==" "):55 newstr = newstr.replace(bkey, RULE_LINK[key].split("|")[0])56 newstr = newstr.replace(ekey, RULE_LINK[key].split("|")[1])57 return newstr58def convert(sourcefile, targetfile):59 """ Convert """60 input = codecs.open(sourcefile, mode="r", encoding="utf-8", errors='ignore')61 output = codecs.open(targetfile, mode="w", encoding="utf-8")62 content = input.readlines()63 for line in content:64 output.write(convert_line(line))65 input.close()66 output.close()67def test():68 print(convert_line("** Titre2"))69 print(convert_line("* Titre 1"))70 print(convert_line("*** Titre 3 et oula"))71 print(convert_line("**** Titre 4Test et olé"))72 print(convert_line("***** Titre 5"))73 print(convert_line("*C'est en bold*"))74 print(convert_line("* C'est pas du bold c'est un titre*"))75 print(convert_line(" * C'est pas du bold 1*"))76 print(convert_line(" *C'est pas du bold 2 *"))77 print(convert_line("Du *bold avec du texte* dans un autre texte"))78 print(convert_line("Blah blah _underligned here_"))79 print(convert_line("Blah blah _underligned here_ ggsgsg"))80 print(convert_line("[[/un/lien/vers/le/paradis.png]]"))81 print(convert_line("[[ /un/lien/vers/le/paradis.png]]"))82 print(convert_line("[[/un/lien/vers/le/paradis.png ]]"))83 print(convert_line("du texte [[/un/lien/vers/le/paradis.png]] encore du texte"))84 print(convert_line("du texte avec un lien fichier file:../toto/titi.txt "))85 print(convert_line("du texte avec un lien fichier file:../toto/titi.txt"))86 87def ask_for_input_dir(rootdir, msg):88 dirname = input(msg)89 fulldirname = os.path.join(rootdir, dirname)90 while True:91 if os.path.isdir(fulldirname):92 return fulldirname93 else:94 print(fulldirname + " is not a valid directory. Try again...")95 96def ask_for_input_file(rootdir, msg):97 while True:98 filename = input(msg)99 fullfilename = os.path.join(rootdir, filename)...

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 localstack 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