<s> import zipfile <EOL> import yaml <EOL> import sys <EOL> import os <EOL> import requests <EOL> from collections import defaultdict <EOL> from StringIO import StringIO <EOL> IPV_CONFIG_URL = "<STR_LIT>" <EOL> def get_country_to_hosts ( ipvanish_zip ) : <EOL> res = defaultdict ( list ) <EOL> for f in ipvanish_zip . namelist ( ) : <EOL> if not f . endswith ( "<STR_LIT>" ) : <EOL> continue <EOL> country_code = f . split ( "<STR_LIT:->" ) [ <NUM_LIT:1> ] . lower ( ) <EOL> if country_code == '<STR_LIT>' : <EOL> country_code = '<STR_LIT>' <EOL> ovpn = ipvanish_zip . open ( f ) <EOL> for line in ovpn . readlines ( ) : <EOL> if line . startswith ( "<STR_LIT>" ) : <EOL> res [ country_code ] . append ( line . split ( "<STR_LIT:U+0020>" ) [ <NUM_LIT:1> ] ) <EOL> return dict ( res ) <EOL> def get_ipvanish_zip ( ) : <EOL> zipdata = StringIO ( ) <EOL> zipdata . write ( requests . get ( IPV_CONFIG_URL ) . content ) <EOL> return zipfile . ZipFile ( zipdata ) <EOL> def main ( ) : <EOL> print ( yaml . dump ( <EOL> get_country_to_hosts ( get_ipvanish_zip ( ) ) , <EOL> default_flow_style = False <EOL> ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
