Best Python code snippet using ATX
morning_star.py
Source:morning_star.py
...33 writer = pd.ExcelWriter(file_path, engine = 'xlsxwriter',)34 df_tab1.to_excel(writer, startrow=0,sheet_name='Active Employees List', index=False)35 writer.save()36 37def process_casefile(df_case,src_name):38 file_gen_date = date.today().strftime("%m%d%y")39 file_path = "Processed Reports Folder/{}_StatusReport_{}.xlsx".format(src_name, file_gen_date)40 41 source_excel_headers_niv = ['Case No',"Petitioner","Beneficiary Name","Current Status","Current Status Expires","I-797 Expires","NIV Max Out Date","Petition Expiration Date PED","EAD Expiration","Management Info Business Partner Name","Management Info Employee ID","Management Info Job Title","Process Case No","Case Opened","Process Type","Process Reference","Application Filed","Final Action Status","Final Action Date","Summary Case Disposition"]42 result_excel_headers_niv = ['Unique Record Id (BT)',"Petitioner","Beneficiary Name","Current Status","Current Status Expiration Date","I-797 Expiration Date","NIV Max Out Date","PED ","EAD Expiration Date","HRBP","Employee Id","Job Title","Case Id","Case Opened Date","Case Type","Case Reference","Case Filed Date ","Final Action Status","Final Action Date","Summary Case Disposition"]43 44 df_tab2 = pd.DataFrame()45 for x,y in zip(source_excel_headers_niv,result_excel_headers_niv): 46 df_tab2[y] = df_case[x]47 # df_tab2 = df_tab2.sort_values(by=['Beneficiary Name'],ascending=True)48 # df_tab2.head()49 df_tab2 = df_tab2[(df_tab2['Case Type'] == 'H-1B Professional') | 50 (df_tab2['Case Type'] == 'L-1A Intracompany Transfer') | 51 (df_tab2['Case Type'] == 'L-1B Intracompany Transfer') |52 (df_tab2['Case Type'] == 'E-3 Treaty Professional') |53 (df_tab2['Case Type'] == 'L-1A/B Intracompany Transfer') | 54 (df_tab2['Case Type'] == 'TN Extension') |55 (df_tab2['Case Type'] == 'L Blanket') |56 (df_tab2['Case Type'] == 'H-4 Derivative') ]57 source_excel_headers_perm = ['Case No',"Petitioner","Beneficiary Name","Current Status","Current Status Expires","I-797 Expires","NIV Max Out Date","Petition Expiration Date PED","EAD Expiration","Management Info Business Partner Name","Management Info Employee ID","Management Info Job Title","Process Case No","Case Opened","Process Type","Process Reference","Application Filed","Final Action Status","Final Action Date","Summary Case Disposition"] 58 result_excel_headers_perm = ['Unique Record Id (BT)',"Petitioner","Beneficiary Name","Current Status","Current Status Expiration Date","I-797 Expiration Date","NIV Max Out Date","PED ","EAD Expiration Date","HRBP","Employee Id","Job Title","Case Id","Case Opened Date","Case Type","Case Reference","Case Filed Date ","Final Action Status","Final Action Date","Summary Case Disposition"]59 df_tab3 = pd.DataFrame()60 for x,y in zip(source_excel_headers_perm,result_excel_headers_perm): 61 df_tab3[y] = df_case[x]62 df_tab3 = df_tab3[(df_tab3['Case Type'] == 'Labor Cert PERM')]63 source_excel_headers_pr = ['Case No',"Petitioner","Beneficiary Name","Current Status","Current Status Expires","I-797 Expires","NIV Max Out Date","Petition Expiration Date PED","EAD Expiration","Management Info Business Partner Name","Management Info Employee ID","Management Info Job Title","Process Case No","Case Opened","Process Type","Process Reference","Application Filed","Final Action Status","Final Action Date","Summary Case Disposition"] 64 result_excel_headers_pr = ['Unique Record Id (BT)',"Petitioner","Beneficiary Name","Current Status","Current Status Expiration Date","I-797 Expiration Date","NIV Max Out Date","PED ","EAD Expiration Date","HRBP","Employee Id","Job Title","Case Id","Case Opened Date","Case Type","Case Reference","Case Filed Date ","Final Action Status","Final Action Date","Summary Case Disposition"]65 df_tab4 = pd.DataFrame()66 for x,y in zip(source_excel_headers_pr,result_excel_headers_pr): 67 df_tab4[y] = df_case[x]68 df_tab4 = df_tab4[(df_tab4['Case Type'] == 'I-140 LC Required') |69 (df_tab4['Case Type'] == 'I-140 LC Exempt') |70 (df_tab4['Case Type'] == 'AOS Employment')]71 source_excel_headers_h1b = ['Case No',"Petitioner","Beneficiary Name","Current Status","Current Status Expires","I-797 Expires","NIV Max Out Date","Petition Expiration Date PED","EAD Expiration","Management Info Business Partner Name","Management Info Employee ID","Management Info Job Title","Process Case No","Case Opened","Process Type","Process Reference","Application Filed","Final Action Status","Final Action Date","Summary Case Disposition"] 72 result_excel_headers_h1b = ['Unique Record Id (BT)',"Petitioner","Beneficiary Name","Current Status","Current Status Expiration Date","I-797 Expiration Date","NIV Max Out Date","PED ","EAD Expiration Date","HRBP","Employee Id","Job Title","Case Id","Case Opened Date","Case Type","Case Reference","Case Filed Date ","Final Action Status","Final Action Date","Summary Case Disposition"]73 df_tab5 = pd.DataFrame()74 for x,y in zip(source_excel_headers_h1b,result_excel_headers_h1b): 75 df_tab5[y] = df_case[x]76 df_tab5 = df_tab5[(df_tab5['Case Type'] == 'H-1B CAP')]77 78 book = load_workbook(file_path)79 writer = pd.ExcelWriter(file_path, engine = 'openpyxl')80 writer.book = book81 df_tab2.to_excel(writer,startrow=0,sheet_name='NIV Cases', index=False)82 df_tab3.to_excel(writer,startrow=0,sheet_name='PERM Cases', index=False)83 df_tab4.to_excel(writer,startrow=0,sheet_name='PR Cases', index=False)84 df_tab5.to_excel(writer,startrow=0,sheet_name='H-1B Cap Cases', index=False)85 # print(df_tab2.shape())86 for x in range(5):87 ws = book[book.sheetnames[x]]88 rows = ws.max_row 89 cols= ws.max_column 90 if x == 0: 91 ws.freeze_panes = ws['D2']92 else:93 ws.freeze_panes = ws['F2']94 for y in range(rows):95 for z in range(cols):96 97 ws.cell(row=y+1, column=z+1).font = Font(size = 12, color = 'FFFFFF')98 ws.cell(row=y+1, column=z+1).alignment=Alignment(wrap_text=True, horizontal="justify", vertical="justify")99 ws.cell(row=y+1, column=z+1).font= Font(name = 'Calibri (Body)', size= 11)100 ws.cell(row=y+1, column=z+1).border= Border(left=Side(style='thin'), right=Side(style='thin'), top=Side(style='thin'), bottom=Side(style='thin'))101 102 for cl in range(cols):103 # for rw in range(rows+)104 if cl <= cols:105 ws.column_dimensions[get_column_letter(cl+1)].width = 15106 # ws.row_dimensions[(rows+1)].height = 8107 table = Table(displayName="Table{}".format(x+1), ref="A1:" + get_column_letter(cols) + str(rows))108 style = TableStyleInfo(name="TableStyleMedium2", showFirstColumn=False,109 showLastColumn=False, showRowStripes=True, showColumnStripes=False)110 table.tableStyleInfo = style111 ws.add_table(table)112 writer.save()113 writer.close()114 115def start():116 for name in glob.glob('Source Data/Active Beneficiary*'):117 beneficiary_file = os.path.abspath(name)118 src_name = os.path.basename(name)119 print ('Processing.. ' + str(beneficiary_file))120 df_ben = pd.read_excel(beneficiary_file)121 src_name =src_name.split('-')[1][:-5].strip()122 # quit()123 process_beneficiary(df_ben, src_name)124 print('Processed Successfully beneficiary file\n\n')125 for name in glob.glob('Source Data/Open process Data*'):126 case_file = os.path.abspath(name)127 src_name = os.path.basename(name)128 src_name = src_name.split('-')[1][:-5].strip()129 print(src_name)130 # quit()131 print ('processing.. ' + str(case_file))132 df_case = pd.read_excel(case_file)133 process_casefile(df_case,src_name)134 print('Processed Successfully case file')...
draft_editor.py
Source:draft_editor.py
...36 with open(self.casepath, 'w') as f:37 json.dump(self.case, f, indent=2)38 # generate code39 try:40 AndroidRecorder.process_casefile(self.basedir)41 return True42 except:43 traceback.print_exc()44 return False45 def build_exec_env(self):46 d = atx.connect()47 d.image_path.append(os.path.join(self.basedir, 'case'))48 self._env = {'time': time, 'd': d}49 def run_step(self, frameidx):50 if self._env is None:51 self.build_exec_env()52 for row in self.case:53 if row['frameidx'] == frameidx:54 code = self.record.process_draft(row)...
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!!