From bb8dd5066f730f9bb0ac0398bf9a167e9736a808 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 21 Nov 2009 14:54:11 -0500 Subject: Fix libbe.vcs.VCS.get_file_contents(allow_no_vcs=True,binary=True). In it's previous form it had ignored the binary option if self._use_vcs() returned False. Also added a few more details to the docstring, explaining the arguments. --- libbe/vcs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libbe/vcs.py') diff --git a/libbe/vcs.py b/libbe/vcs.py index b1fd114..57a0245 100644 --- a/libbe/vcs.py +++ b/libbe/vcs.py @@ -334,6 +334,10 @@ class VCS(object): """ Get the file as it was in a given revision. Revision==None specifies the current revision. + + allow_no_vcs==True allows direct access to files through + codecs.open() or open() if the vcs decides it can't handle the + given path. """ if not os.path.exists(path): raise NoSuchFile(path) @@ -341,7 +345,10 @@ class VCS(object): relpath = self._u_rel_path(path) contents = self._vcs_get_file_contents(relpath,revision,binary=binary) else: - f = codecs.open(path, "r", self.encoding) + if binary == True: + f = codecs.open(path, "r", self.encoding) + else: + f = open(path, "rb") contents = f.read() f.close() return contents -- cgit