85
86
raise NoSuchFile('File or directory %r does not exist' % path, orig_error=e)
86
87
raise LocalTransportError(orig_error=e)
88
def get_partial(self, relpath, start, length=None):
89
"""Get just part of a file.
91
:param relpath: Path to the file, relative to base
92
:param start: The starting position to read from
93
:param length: The length to read. A length of None indicates
94
read to the end of the file.
95
:return: A file-like object containing at least the specified bytes.
96
Some implementations may return objects which can be read
97
past this length, but this is not guaranteed.
99
# LocalTransport.get_partial() doesn't care about the length
100
# argument, because it is using a local file, and thus just
101
# returns the file seek'ed to the appropriate location.
103
path = self.abspath(relpath)
108
if e.errno == errno.ENOENT:
109
raise NoSuchFile('File %r does not exist' % path, orig_error=e)
110
raise LocalTransportError(orig_error=e)
112
89
def put(self, relpath, f):
113
90
"""Copy the file-like or string object into the location.
110
def iter_files_recursive(self):
111
"""Iter the relative paths of files in the transports sub-tree."""
112
queue = list(self.list_dir('.'))
114
relpath = queue.pop(0)
115
st = self.stat(relpath)
116
if S_ISDIR(st[ST_MODE]):
117
for i, basename in enumerate(self.list_dir(relpath)):
118
queue.insert(i, relpath+'/'+basename)
133
122
def mkdir(self, relpath):
134
123
"""Create a directory at the given path."""