36
36
def has(self, relpath):
37
37
return os.access(self.abspath(relpath), os.F_OK)
39
def get(self, relpath):
39
def get(self, relpath, decode=False):
40
40
"""Get the file at the given relative path.
42
return open(self.abspath(relpath), 'rb')
44
def put(self, relpath, f):
45
"""Copy the file-like object into the location.
42
:param relpath: The relative path to the file
43
:param decode: If True, assume the file is utf-8 encoded and
44
decode it into Unicode
48
codecs.open(self.abspath(relpath), 'rb', encoding='utf-8',
51
return open(self.abspath(relpath), 'rb')
53
def put(self, relpath, f, encode=False):
54
"""Copy the file-like or string object into the location.
56
:param relpath: Location to put the contents, relative to base.
57
:param f: File-like or string object.
58
:param encode: If True, translate the contents into utf-8 encoded text.
60
raise NotImplementedError
47
61
from bzrlib.atomicfile import AtomicFile
49
fp = AtomicFile(self.abspath(relpath), 'wb')
64
fp = AtomicFile(self.abspath(relpath), 'wb', encoding='utf-8')
66
fp = AtomicFile(self.abspath(relpath), 'wb')
57
74
"""Create a directory at the given path."""
58
75
os.mkdir(self.abspath(relpath))
60
def open(self, relpath, mode='wb'):
61
"""Open a remote file for writing.
62
This may return a proxy object, which is written to locally, and
63
then when the file is closed, it is uploaded using put()
65
return open(self.abspath(relpath), mode)
67
77
def append(self, relpath, f):
68
78
"""Append the text in the file-like object into the final