def get_networks(base_file, ipaddr_file):
networks = []<EOL>base = open(base_file, '<STR_LIT:r>')<EOL>csv_reader = csv.reader(base, delimiter='<STR_LIT:\t>')<EOL>buffer = "<STR_LIT>"<EOL>for row in csv_reader:<EOL><INDENT>if len(networks) > <NUM_LIT:0> and len(buffer) > <NUM_LIT:0>:<EOL><INDENT>networks[-<NUM_LIT:1>]['<STR_LIT>'] += "<STR_LIT:U+0020>".join(buffer)<EOL>buffer = "<STR_LIT>"<EOL><DEDENT>if len(row) < <NUM_LIT:3>:<EOL><INDENT>buffer = row<EOL><DEDENT>else:<EOL><INDENT>network = {<EOL>'<STR_LIT>': ipaddress.ip_network("<STR_LIT>".format(row[<NUM_LIT:0>], row[<NUM_LIT:2>])),<EOL>'<STR_LIT:description>': row[<NUM_LIT:1>],<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': "<STR_LIT>"<EOL>}<EOL>if len(row) > <NUM_LIT:3>:<EOL><INDENT>network['<STR_LIT>'] = "<STR_LIT:U+0020>".join(row[<NUM_LIT:3>:])<EOL><DEDENT>networks.append(network)<EOL><DEDENT><DEDENT>base.close()<EOL>ipaddr = open(ipaddr_file, '<STR_LIT:r>')<EOL>csv_reader = csv.reader(ipaddr, delimiter='<STR_LIT:\t>')<EOL>for row in csv_reader:<EOL><INDENT>host = {<EOL>'<STR_LIT>': ipaddress.ip_address(row[<NUM_LIT:0>]),<EOL>'<STR_LIT:user>': row[<NUM_LIT:1>],<EOL>'<STR_LIT:location>': row[<NUM_LIT:2>],<EOL>'<STR_LIT:description>': row[<NUM_LIT:3>],<EOL>'<STR_LIT>': row[<NUM_LIT:4>],<EOL>'<STR_LIT>': row[<NUM_LIT:5>],<EOL>'<STR_LIT>': row[<NUM_LIT:6>]<EOL>}<EOL>if len(row) > <NUM_LIT:7>:<EOL><INDENT>host['<STR_LIT>'] = "<STR_LIT:U+0020>".join(row[<NUM_LIT:7>:])<EOL><DEDENT>add_ip_to_net(networks, host)<EOL><DEDENT>ipaddr.close()<EOL>return networks<EOL>
Gather network and host information from ipplan export files.