Best Python code snippet using pandera_python
stp_header_parser.py
Source:stp_header_parser.py
1class stp_header_parser():2 def stp_header_parser(self, stp_filename='', is_debug=False):3 def line_extract(filehandle=None, str_startswith='', str_endswith=''):4 while True:5 line = filehandle.readline().strip()6 if line.startswith(str_startswith):7 line_extracted = ''8 while True:9 line_extracted += line10 if line.endswith(str_endswith):11 break12 else:13 line = filehandle.readline().strip()14 return line_extracted15 infos_name = [16 'ISO Standard',17 'Description',18 'Implementation Level',19 'Name',20 'Time_Stamp',21 'Author',22 'Organization',23 'Preprocessor Version',24 'Originating System',25 'Authorization',26 'Schema',27 ]28 infos_value = []29 len_infos_name = len(infos_name)30 with open(stp_filename, 'r') as f:31 line = line_extract(f, 'ISO-', ';')32 if line:33 ISO_Standard = line[:-1]34 infos_value.append(ISO_Standard)35 line = line_extract(f, 'HEADER', ';')36 if line:37 if is_debug:38 print('>>> Header Start Mark Found <<<')39 line = line_extract(f, 'FILE_DESCRIPTION', ';')40 File_Description = eval(line[16:-1])41 infos_value += File_Description42 line = line_extract(f, 'FILE_NAME', ';')43 File_Name = eval(line[9:-1])44 infos_value += File_Name45 line = line_extract(f, 'FILE_SCHEMA', ';')46 File_Schema = eval(line[11:-1])47 infos_value.append(File_Schema)48 if line_extract(f, 'ENDSEC', ';'):49 if is_debug:50 print('>>> Header End Mark Found <<<')51 infos_dict = {52 index: list(parameter) for (53 index, parameter) in zip(54 range(len_infos_name), zip(55 infos_name, infos_value))}56 if is_debug:57 for key in infos_dict:58 print('{:02}\t{}'.format(key, infos_dict[key]))...
str_startswith_tutorial.py
Source:str_startswith_tutorial.py
1def str_startswith():2 text = 'abcd'3 if text.startswith('ab'):4 print('yes')5def str_endswith():6 text = 'abcd'7 if text.endswith('cd'):8 print('yes')9if __name__ == "__main__":10 str_startswith()...
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!!