aboutsummaryrefslogtreecommitdiffstats
path: root/python/fuse.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/fuse.py')
-rw-r--r--python/fuse.py110
1 files changed, 85 insertions, 25 deletions
diff --git a/python/fuse.py b/python/fuse.py
index ec1e633..ae621f3 100644
--- a/python/fuse.py
+++ b/python/fuse.py
@@ -1,3 +1,5 @@
+#@+leo-ver=4
+#@+node:@file fuse.py
#
# Copyright (C) 2001 Jeff Epler <jepler@unpythonic.dhs.org>
#
@@ -5,34 +7,92 @@
# See the file COPYING.
#
+
+#@@language python
+#@+others
+#@+node:imports
+# suppress version mismatch warnings
+try:
+ import warnings
+ warnings.filterwarnings('ignore',
+ 'Python C API version mismatch',
+ RuntimeWarning,
+ )
+except:
+ pass
+
from _fuse import main, DEBUG
-import os
+import os, sys
from errno import *
+#@-node:imports
+#@+node:class ErrnoWrapper
class ErrnoWrapper:
- def __init__(self, func):
- self.func = func
-
- def __call__(self, *args, **kw):
- try:
- return apply(self.func, args, kw)
- except (IOError, OSError), detail:
- # Sometimes this is an int, sometimes an instance...
- if hasattr(detail, "errno"): detail = detail.errno
- return -detail
-
+ #@ @+others
+ #@+node:__init__
+ def __init__(self, func):
+ self.func = func
+ #@-node:__init__
+ #@+node:__call__
+ def __call__(self, *args, **kw):
+ try:
+ return apply(self.func, args, kw)
+ except (IOError, OSError), detail:
+ # Sometimes this is an int, sometimes an instance...
+ if hasattr(detail, "errno"): detail = detail.errno
+ return -detail
+ #@-node:__call__
+ #@-others
+#@-node:class ErrnoWrapper
+#@+node:class Fuse
class Fuse:
- _attrs = ['getattr', 'readlink', 'getdir', 'mknod', 'mkdir',
- 'unlink', 'rmdir', 'symlink', 'rename', 'link', 'chmod',
- 'chown', 'truncate', 'utime', 'open', 'read', 'write']
-
- flags = 0
- multithreaded = 0
- def main(self):
- d = {'flags': self.flags}
- d['multithreaded'] = self.multithreaded
- for a in self._attrs:
- if hasattr(self,a):
- d[a] = ErrnoWrapper(getattr(self, a))
- apply(main, (), d)
+ #@ @+others
+ #@+node:attribs
+ _attrs = ['getattr', 'readlink', 'getdir', 'mknod', 'mkdir',
+ 'unlink', 'rmdir', 'symlink', 'rename', 'link', 'chmod',
+ 'chown', 'truncate', 'utime', 'open', 'read', 'write', 'release']
+
+ flags = 0
+ multithreaded = 0
+
+ #@-node:attribs
+ #@+node:__init__
+ def __init__(self, *args, **kw):
+
+ # default attributes
+ self.optlist = []
+ self.optdict = {}
+ self.mountpoint = None
+
+ # grab arguments, if any
+ argv = sys.argv
+ argc = len(argv)
+ if argc > 1:
+ # we've been given the mountpoint
+ self.mountpoint = argv[1]
+ if argc > 2:
+ # we've received mount args
+ optstr = argv[2]
+ opts = optstr.split(",")
+ for o in opts:
+ try:
+ k, v = o.split("=", 1)
+ self.optdict[k] = v
+ except:
+ self.optlist.append(o)
+ #@-node:__init__
+ #@+node:main
+ def main(self):
+ d = {'flags': self.flags}
+ d['multithreaded'] = self.multithreaded
+ for a in self._attrs:
+ if hasattr(self,a):
+ d[a] = ErrnoWrapper(getattr(self, a))
+ apply(main, (), d)
+ #@-node:main
+ #@-others
+#@-node:class Fuse
+#@-others
+#@-node:@file fuse.py
+#@-leo