def _get_data(url):
if url.startswith('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>resp = urllib.urlopen(url)<EOL>encoding = resp.headers.dict.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>resp = urllib.request.urlopen(url)<EOL>encoding = resp.headers.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>data = resp.read()<EOL>if encoding == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>elif encoding == '<STR_LIT>':<EOL><INDENT>data = StringIO(data)<EOL>data = gzip.GzipFile(fileobj=data).read()<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(url, '<STR_LIT:r>') as fid:<EOL><INDENT>data = fid.read()<EOL><DEDENT><DEDENT>return data<EOL>
Helper function to get data over http or from a local file