<s> import inspect <EOL> import xlrd <EOL> import os <EOL> import env , log <EOL> class ExcelSheet : <EOL> def __init__ ( self , excel , sheet ) : <EOL> if env . EXCEL_DATA_PATH == "<STR_LIT>" : <EOL> env . EXCEL_DATA_PATH = os . path . join ( env . RESULT_PATH , "<STR_LIT:data>" ) <EOL> self . excel = xlrd . open_workbook ( os . path . join ( env . EXCEL_DATA_PATH , excel ) ) <EOL> self . sheet = self . excel . sheet_by_name ( sheet ) <EOL> self . data = [ [ "<STR_LIT>" for x in range ( self . sheet . ncols ) ] for y in range ( self . sheet . nrows ) ] <EOL> for i in range ( self . sheet . nrows ) : <EOL> for j in range ( self . sheet . ncols ) : <EOL> self . data [ i ] [ j ] = self . cellxy ( i , j ) <EOL> def nrows ( self ) : <EOL> return self . sheet . nrows <EOL> def ncols ( self ) : <EOL> return self . sheet . ncols <EOL> def cellxy ( self , rowx , colx ) : <EOL> '''<STR_LIT>''' <EOL> cell_value = self . sheet . cell ( rowx , colx ) . value <EOL> if self . sheet . cell ( rowx , colx ) . ctype in ( <NUM_LIT:2> , <NUM_LIT:3> ) and int ( cell_value ) == cell_value : <EOL> cell_value = int ( cell_value ) <EOL> return str ( cell_value ) <EOL> def cell ( self , rowx , col_name ) : <EOL> for colx in range ( <NUM_LIT:0> , self . ncols ( ) ) : <EOL> if self . cellxy ( <NUM_LIT:0> , colx ) == col_name : <EOL> log . step_normal ( "<STR_LIT>" % ( rowx , col_name , self . cellxy ( rowx , colx ) ) ) <EOL> return self . cellxy ( rowx , colx ) <EOL> def cell_by_colname ( self , rowx , col_name ) : <EOL> for colx in range ( <NUM_LIT:0> , self . sheet . ncols ) : <EOL> if self . data [ <NUM_LIT:0> ] [ colx ] == col_name : <EOL> log . step_normal ( "<STR_LIT>" % ( colx , col_name , self . data [ rowx ] [ colx ] ) ) <EOL> return self . data [ rowx ] [ colx ] <EOL> return "<STR_LIT>" <EOL> def cell_by_rowname ( self , row_name , colx ) : <EOL> for rowx in range ( <NUM_LIT:0> , self . sheet . nrows ) : <EOL> if self . data [ rowx ] [ <NUM_LIT:0> ] == row_name : <EOL> log . step_normal ( "<STR_LIT>" % ( row_name , colx , self . data [ rowx ] [ colx ] ) ) <EOL> return self . data [ rowx ] [ colx ] <EOL> return "<STR_LIT>" <EOL> def cell_by_row_and_col_name ( self , row_name , col_name ) : <EOL> for rowx in range ( <NUM_LIT:0> , self . nrows ( ) ) : <EOL> if self . cellxy ( rowx , <NUM_LIT:0> ) == row_name : <EOL> return self . cell ( rowx , col_name ) </s>
