From 73070a4396d22378763e769f31e9df711b170843 Mon Sep 17 00:00:00 2001 From: David McNab Date: Mon, 22 Dec 2003 23:26:52 +0000 Subject: [PATCH] Changed the '#include ' to '#include "fuse.h"' to allow symlinking of fuse.h into python dir. --- python/_fusemodule.c | 2 +- python/code.leo | 137 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 134 insertions(+), 5 deletions(-) diff --git a/python/_fusemodule.c b/python/_fusemodule.c index c323c60..9518074 100644 --- a/python/_fusemodule.c +++ b/python/_fusemodule.c @@ -11,7 +11,7 @@ //@+others //@+node:includes #include -#include +#include "fuse.h" #include //@-node:includes //@+node:globals diff --git a/python/code.leo b/python/code.leo index 2fa915d..8ff723e 100644 --- a/python/code.leo +++ b/python/code.leo @@ -2,7 +2,7 @@ - + @@ -13,7 +13,7 @@ fuse python bindings -@file _fusemodule.c +@file _fusemodule.c includes globals PROLOGUE @@ -81,14 +81,27 @@ read write release -statfs +statfs fsync mainline @file setup.py @file README -@file mount.fuse +@file mount.fuse +@file fuse.py +<< fuse declarations >> +class ErrnoWrapper +<< class ErrnoWrapper declarations >> +__init__ +__call__ + +class Fuse +<< class Fuse declarations >> +__init__ +main + + @@ -986,6 +999,122 @@ EPILOGUE EPILOGUE } + +@ignore +@language python +<< fuse declarations >> +@others + #@-node:main + #@-others +#@-node:class Fuse +#@-others +#@-node:@file fuse.py +#@-leo + +#@+leo-ver=4 +#@+node:@file fuse.py +# +# Copyright (C) 2001 Jeff Epler <jepler@unpythonic.dhs.org> +# +# This program can be distributed under the terms of the GNU GPL. +# 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, sys +from errno import * + +#@-node:imports +#@+node:class ErrnoWrapper + +class ErrnoWrapper: + << class ErrnoWrapper declarations >> + @others + + #@ @+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: + << class Fuse declarations >> + @others + +#@ @+others +#@+node:attribs +_attrs = ['getattr', 'readlink', 'getdir', 'mknod', 'mkdir', + 'unlink', 'rmdir', 'symlink', 'rename', 'link', 'chmod', + 'chown', 'truncate', 'utime', 'open', 'read', 'write', 'release', + 'statfs', 'fsync'] + +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) -- 2.30.2