Best Python code snippet using avocado_python
normalizer.py
Source:normalizer.py
...21 self.__whitespace_regex = re.compile(r"\s+")22 23 def normalize(self, doc: Document):24 self.content = doc.content25 self.__unescape()26 self.__remove_scripts()27 self.__remove_styles()28 self.__remove_tags()29 self.__remove_useless_chars()30 self.content = self.hazm_normalizer(self.content)31 self.__remove_spaces()32 doc.content = self.content33 def __unescape(self):34 """35 Unescape the escaped characters36 """37 self.content = html.unescape(self.content)38 def __remove_scripts(self):39 """40 Remove <script> tags using regex because bleach somtimes does not remove them41 """42 self.content = self.__scripts_regex.sub("", self.content, 0)43 def __remove_styles(self):44 """45 Remove <style> tags using regex because bleach somtimes does not remove them46 """47 self.content = self.__styles_regex.sub("", self.content, 0)...
handle_jmeter_data.py
Source:handle_jmeter_data.py
2# @Time: 2022/1/5 11:123# @Author: shenyuming4# b = ''5# for i in range(1,20001):6# #a = "${table1},AGPOINTNAME=tag_F_${__intSum("+str(i)+r',${num1},)} F=${__Random(1,99999,)}.${__Random(1,9999999,)}${__unescape(\n)}'7# t = "${table1},AGPOINTNAME=tag_F_${__intSum("+str(i)+r',${num1},)} F=${__Random(1,99999,)}.${__Random(1,9999999,)},F1=${__Random(1,99999,)}.${__Random(1,9999999,)},L=${__Random(1,99999,)}${__unescape(\n)}'8# b=b+t9# # b = b.split('${__unescape(\n)}')[1]10# filename = r'E:\sym\performance\body.txt'11# with open(filename,'w')as f:12# f.write(b)13#14#15'''16 æ¹éçæä¸åç±»åçæ°æ®17'''18a = ''19for i in range(1,751):20 f = "${table1},AGPOINTNAME=tag_F_${__intSum("+str(i)+r',${num1},)} F=${__Random(1,99999,)}.${__Random(1,9999999,)}${__unescape(\n)}'21 a=a+f22filename = r'E:\sym\performance\F.txt'23with open(filename,'w')as f:24 f.write(a)25a=''26for i in range(1,751):27 l = "${table1},AGPOINTNAME=tag_L_${__intSum("+str(i)+r',${num1},)} L=${__Random(1,99999,)}${__unescape(\n)}'28 a=a+l29filename = r'E:\sym\performance\L.txt'30with open(filename,'w')as f:31 f.write(a)32a=''33for i in range(1,751):34 s = "${table1},AGPOINTNAME=tag_S_${__intSum("+str(i)+r',${num2},)} S="${__UUID}"${__unescape(\n)}'35 a=a+s36filename = r'E:\sym\performance\S.txt'37with open(filename,'w')as f:38 f.write(a)39a=''40for i in range(1,751):41 b = "${table1},AGPOINTNAME=tag_B_${__intSum("+str(i)+r',${num2},)} B=true${__unescape(\n)}'42 a=a+b43filename = r'E:\sym\performance\B.txt'44with open(filename,'w')as f:...
yacc.py
Source:yacc.py
...19 raise YaccDecodeError("Failed to parse yacc file: {}".format(yacc_file_path))20 except FileNotFoundError:21 raise ChildProcessError("bison executable not found. PATH: {}".format(environ.get("PATH", "")))22 return xml_file23def __unescape(keyword: str) -> str:24 if len(keyword) == 3 and keyword[0] == "'" and keyword[-1] == "'":25 return keyword.strip("'")26 return keyword27def __xml2rules(xml_file):28 rules = set()29 root = xml_parser.parse(xml_file.name).getroot()30 for rule in root.iter("rule"):31 lhs = __unescape(rule.find("lhs").text)32 rhs = [__unescape(symbol.text) for symbol in rule.find("rhs") if symbol.tag != "empty"]33 rules.add(Rule(lhs, rhs))34 return rules35def parse(file_path: str, custom_path: str = None):...
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!!