Thank you for your suggestion, however your code cannot be applied,
since input can be 1 line (original code) and can be 2 lines (need to modify code)
Please see below for original code
I think I will need to save variable filtered from #1 line input and
call that variable while #2 line input being processed.
But I have no idea how to do this???
since input can be 1 line (original code) and can be 2 lines (need to modify code)
Please see below for original code
def parse_mochad_line(self, line): """ Parse a raw line of output from mochad """ # bail out unless it's an incoming RFSEC message if line[15:23] == 'Rx RFSEC': # decode message. format is either: # 09/22 15:39:07 Rx RFSEC Addr: 21:26:80 Func: Contact_alert_min_DS10A # ~ or ~ # 09/22 15:39:07 Rx RFSEC Addr: 0x80 Func: Motion_alert_SP554A line_list = line.split(' ') addr = line_list[5] func = line_list[7] func_dict = self.decode_func(func) return addr, {'func': func_dict}, 'security' elif line[15:20] == 'Rx RF': # decode RF message. format is: # 02/13 23:54:28 Rx RF HouseUnit: B1 Func: On line_list = line.split(' ') house_code = line_list[5]; house_func = line_list[7] return house_code, {'func': house_func}, 'button' return '', ''so I want to extend the code so that can accept 2 lines, something like below.
I think I will need to save variable filtered from #1 line input and
call that variable while #2 line input being processed.
But I have no idea how to do this???
elif line[15:20] == 'Rx PL': # decode RF message. input has 2 lines, format is: # 02/13 23:54:28 Rx PL HouseUnit: A1 # 02/13 23:54:28 Rx PL House: A Func: On line_list = line.split(' ') if line[21:27] == 'HouseU': #filtering #1 line input for 'HouseUnit'=A1 house_code = line_list[5] #but this variable 'house_code' has to be saved somewhere #so that can be called when the next line input being processed elif line[21:27] == 'House:': #filtering #2 line input for 'Func'=On house_func = line_list[7] house_code = ???? #here need to call variable 'HouseUnit'=A1 which already being saved #while filtering #1 line input