diff options
author | Johan Dahlin <jdahlin@async.com.br> | 2008-10-29 13:08:44 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-10-29 13:08:44 +0000 |
commit | 8a16eeb7b5a749100a8fb55f26ce7f28c571e0dc (patch) | |
tree | 6a1ec3809d48f459d4b7a400102e397bc6f01f8c /giscanner/libtoolimporter.py | |
parent | 13e99bc5c60afbe380f4027b1fc491a9a9f3cfee (diff) | |
download | gobject-introspection-8a16eeb7b5a749100a8fb55f26ce7f28c571e0dc.tar.gz |
Clean up the libtool importer a bit. Add a context so we can use it
2008-10-29 Johan Dahlin <jdahlin@async.com.br>
* giscanner/libtoolimporter.py:
* giscanner/sourcescanner.py:
Clean up the libtool importer a bit. Add a context so we
can use it through a with statement.
Don't just look in the current directory, look in the whole
sys.path.
svn path=/trunk/; revision=830
Diffstat (limited to 'giscanner/libtoolimporter.py')
-rw-r--r-- | giscanner/libtoolimporter.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/giscanner/libtoolimporter.py b/giscanner/libtoolimporter.py index 772a7831..19112e27 100644 --- a/giscanner/libtoolimporter.py +++ b/giscanner/libtoolimporter.py @@ -25,19 +25,19 @@ import sys from .utils import extract_libtool -class LibToolImporter(object): +class LibtoolImporter(object): def __init__(self, name, path): self.name = name self.path = path - @staticmethod - def find_module(name, path=None): + @classmethod + def find_module(cls, name, path=None): modname = name.split('.')[-1] for part in path or sys.path: full = os.path.join(part, '.libs', modname + '.la') if os.path.exists(full): - return LibToolImporter(name, full) + return cls(name, full) def load_module(self, name): realpath = extract_libtool(self.path) @@ -45,10 +45,10 @@ class LibToolImporter(object): ('.so', 'rb', 3)) return mod + @classmethod + def __enter__(cls): + sys.meta_path.append(cls) -def install_libtoolimporter(): - sys.meta_path.append(LibToolImporter) - - -def uninstall_libtoolimporter(): - sys.meta_path.remove(LibToolImporter) + @classmethod + def __exit__(cls, type, value, traceback): + sys.meta_path.remove(cls) |