else: if 'ip' not in cmd: return {'response':'ERROR', 'desc':'need ip'} if 'netmask' not in cmd: return {'response':'ERROR', 'desc':'need netmask'} if 'gateway' not in cmd: return {'response':'ERROR', 'desc':'need gateway'} if 'nameserver' not in cmd: return {'response':'ERROR', 'desc':'need nameserver'}

def parse_cell(cell): """Applies the rules to the bunch of text describing a cell and returns the corresponding dictionary""" parsed_cell={} for key in rules: rule=rules[key] parsed_cell.update({key:rule(cell)}) return parsed_cell

I thought it would be useful to mention that if you visit http://www.karotz.com/my/usbkey and fill out your WiFi SSID and key, it will produce a .zip with a network.conf that gives examples of these commands in action.