# # To start with: # python svnfs.py http://somewhere/svn/repository mnt # # Stop with Ctrl-C or with # lufsumount mnt # import py, os import lufs UID = os.getuid() GID = os.getgid() class Filesystem: def __init__(self, root): self.root = root self.paths = {} self.openfiles = {} def get(self, path): path = os.path.normpath(path) try: return self.paths[path] except KeyError: p = self.root.join(path.lstrip('/')) self.paths[path] = p return p def readdir(self, dir): d = self.get(dir) yield '.' yield '..' for d1 in d.listdir(): self.paths[os.path.join(dir, d1.basename)] = d1 yield d1.basename def stat(self, filename): print "stat", filename f = self.get(filename) try: info = f.info() except py.error.ENOENT: if f != self.root: raise return (0040500, 2, UID, GID, 512, 0, 0, 0) # cannot info() root mtime = int(info.mtime) if info.kind == 'dir': return (0040500, 2, UID, GID, 512, mtime, mtime, mtime) else: return (0100400, 1, UID, GID, info.size, mtime, mtime, mtime) def open(self, filename, mode): f = self.get(filename) self.openfiles[filename] = f def release(self, filename): del self.openfiles[filename] def read(self, filename, offset, count): fd = self.openfiles[filename] if type(fd) is not str: fd = fd.read() self.openfiles[filename] = fd return fd[offset:offset+count] # ____________________________________________________________ if __name__ == '__main__': import sys svnurl = py.path.svnurl(sys.argv[1]) svnurl.listdir() # check path lufs.mount(lambda: Filesystem(svnurl), sys.argv[2])