<s> import requests , zipfile , subprocess , csv , json <EOL> update_data_file = '<STR_LIT>' <EOL> zip_filename = '<STR_LIT>' <EOL> zip_request = requests . get ( '<STR_LIT>' , stream = True ) <EOL> with open ( zip_filename , '<STR_LIT:wb>' ) as zip_file : <EOL> for chunk in zip_request . iter_content ( chunk_size = <NUM_LIT> ) : <EOL> if chunk : <EOL> zip_file . write ( chunk ) <EOL> zip_file . flush ( ) <EOL> zipfile . main ( [ '<STR_LIT>' , zip_filename , '<STR_LIT>' ] ) <EOL> subprocess . call ( '<STR_LIT>' , shell = True ) <EOL> subprocess . call ( '<STR_LIT>' , shell = True ) <EOL> abra_read = csv . reader ( open ( '<STR_LIT>' ) , delimiter = '<STR_LIT:U+002C>' ) <EOL> abra_write = csv . writer ( open ( '<STR_LIT>' , '<STR_LIT:w>' ) , delimiter = '<STR_LIT:U+0020>' ) <EOL> for rec in abra_read : <EOL> if rec [ <NUM_LIT:7> ] == '<STR_LIT:X>' : <EOL> continue <EOL> else : <EOL> output = [ rec [ <NUM_LIT:7> ] ] + [ rec [ <NUM_LIT:8> ] ] <EOL> abra_write . writerow ( output ) <EOL> subprocess . call ( '<STR_LIT>' , shell = True ) <EOL> abra_latlong = csv . reader ( open ( '<STR_LIT>' ) , delimiter = '<STR_LIT:U+0020>' ) <EOL> licenses = { } <EOL> for rec in abra_latlong : <EOL> location = rec [ <NUM_LIT:1> ] + '<STR_LIT:U+002C>' + rec [ <NUM_LIT:0> ] <EOL> url = '<STR_LIT>' + location <EOL> request = requests . get ( url ) <EOL> data = json . loads ( request . text ) <EOL> smd = data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> anc = data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ : <NUM_LIT:2> ] <EOL> print smd , rec [ <NUM_LIT:0> ] , rec [ <NUM_LIT:1> ] <EOL> if anc in licenses : <EOL> if smd in licenses [ anc ] [ '<STR_LIT>' ] : <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] [ '<STR_LIT>' ] += <NUM_LIT:1> <EOL> else : <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] = { } <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] [ '<STR_LIT>' ] = [ ] <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> licenses [ anc ] [ '<STR_LIT>' ] += <NUM_LIT:1> <EOL> else : <EOL> licenses [ anc ] = { } <EOL> licenses [ anc ] [ '<STR_LIT>' ] = [ ] <EOL> licenses [ anc ] [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> licenses [ anc ] [ '<STR_LIT>' ] = { } <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] = { } <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] [ '<STR_LIT>' ] = [ ] <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> licenses [ anc ] [ '<STR_LIT>' ] [ smd ] [ '<STR_LIT>' ] . append ( location ) <EOL> licenses [ anc ] [ '<STR_LIT>' ] . append ( location ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as output : <EOL> json . dump ( licenses , output , sort_keys = True , indent = <NUM_LIT:4> ) <EOL> subprocess . call ( '<STR_LIT>' , shell = True ) </s>
