Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def open(self, filename):
"""
Yield a file-like object for file `filename`.
This function is a context manager.
"""
filename = self.real_filename(filename)
command = "git --no-pager show {}".format(filename)
command_tokens = shlex.split(command)
try:
output = subprocess.check_output(command_tokens, cwd=self.repository)
except (OSError, subprocess.CalledProcessError):
raise self.FileNotFound(filename)
output = output.decode("utf-8").rstrip()
yield io.StringIO(output)
def open(self, filename):
"""
Yield a file-like object for file `filename`.
This function is a context manager.
"""
filename = self.real_filename(filename)
if not os.path.exists(filename):
raise self.FileNotFound(filename)
with codecs.open(filename, encoding="utf-8") as f:
yield f
def open(self, filename):
filename = self.real_filename(filename)
try:
f = self.zipfile.open(filename)
yield f
f.close()
except KeyError:
raise self.FileNotFound(filename)