~ubuntu-branches/ubuntu/karmic/tahoe-lafs/karmic

« back to all changes in this revision

Viewing changes to contrib/fuse/impl_b/pyfuse/svnfs.py

  • Committer: Bazaar Package Importer
  • Author(s): Zooko O'Whielacronx (Hacker)
  • Date: 2009-09-24 00:00:05 UTC
  • Revision ID: james.westby@ubuntu.com-20090924000005-ixe2n4yngmk49ysz
Tags: upstream-1.5.0
ImportĀ upstreamĀ versionĀ 1.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import py
 
2
from handler import Handler
 
3
from objectfs import ObjectFs
 
4
 
 
5
 
 
6
class SvnDir:
 
7
    def __init__(self, path):
 
8
        self.path = path
 
9
 
 
10
    def listdir(self):
 
11
        for p in self.path.listdir():
 
12
            if p.check(dir=1):
 
13
                cls = SvnDir
 
14
            else:
 
15
                cls = SvnFile
 
16
            yield p.basename, cls(p)
 
17
 
 
18
 
 
19
class SvnFile:
 
20
    data = None
 
21
 
 
22
    def __init__(self, path):
 
23
        self.path = path
 
24
 
 
25
    def size(self):
 
26
        if self.data is None:
 
27
            return None
 
28
        else:
 
29
            return len(self.data)
 
30
 
 
31
    def read(self):
 
32
        if self.data is None:
 
33
            self.data = self.path.read()
 
34
        return self.data
 
35
 
 
36
 
 
37
if __name__ == '__main__':
 
38
    import sys
 
39
    svnurl, mountpoint = sys.argv[1:]
 
40
    root = SvnDir(py.path.svnurl(svnurl))
 
41
    handler = Handler(mountpoint, ObjectFs(root))
 
42
    handler.loop_forever()