@classmethod<EOL><INDENT>def file(cls, uri_or_path):<DEDENT>
uri = urlparse(uri_or_path)<EOL>if not uri.scheme:<EOL><INDENT>return open(uri_or_path, '<STR_LIT:rb>')<EOL><DEDENT>else:<EOL><INDENT>it = cls(uri_or_path).download_iter(uri.path.lstrip('<STR_LIT:/>'), skip_hash=True)<EOL>if not it:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(uri_or_path))<EOL><DEDENT>tmp = tempfile.TemporaryFile()<EOL>for chunk in it:<EOL><INDENT>tmp.write(chunk)<EOL><DEDENT>tmp.seek(<NUM_LIT:0>, <NUM_LIT:0>)<EOL>return tmp<EOL><DEDENT>
Given either a URI like s3://bucket/path.txt or a path like /path.txt,
return a file object for it.