Package flumotion :: Package extern :: Package pytrayicon :: Module ltihooks
[hide private]

Source Code for Module flumotion.extern.pytrayicon.ltihooks

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3   
 4  # ltihooks.py: python import hooks that understand libtool libraries. 
 5  # Copyright (C) 2000 James Henstridge. 
 6  # 
 7  # This program is free software; you can redistribute it and/or modify 
 8  # it under the terms of the GNU General Public License as published by 
 9  # the Free Software Foundation; either version 2 of the License, or 
10  # (at your option) any later version. 
11  # 
12  # This program is distributed in the hope that it will be useful, 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  # GNU General Public License for more details. 
16  # 
17  # You should have received a copy of the GNU General Public License 
18  # along with this program; if not, write to the Free Software 
19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
20   
21  import os, ihooks 
22   
23 -class LibtoolHooks(ihooks.Hooks):
24 - def get_suffixes(self):
25 """Like normal get_suffixes, but adds .la suffixes to list""" 26 ret = ihooks.Hooks.get_suffixes(self) 27 ret.insert(0, ('module.la', 'rb', 3)) 28 ret.insert(0, ('.la', 'rb', 3)) 29 return ret
30
31 - def load_dynamic(self, name, filename, file=None):
32 """Like normal load_dynamic, but treat .la files specially""" 33 if len(filename) > 3 and filename[-3:] == '.la': 34 fp = open(filename, 'r') 35 dlname = '' 36 installed = 1 37 line = fp.readline() 38 while line: 39 # dlname: the name that we can dlopen 40 if len(line) > 7 and line[:7] == 'dlname=': 41 dlname = line[8:-2] 42 # installed: whether it's already installed 43 elif len(line) > 10 and line[:10] == 'installed=': 44 installed = line[10:-1] == 'yes' 45 line = fp.readline() 46 fp.close() 47 if dlname: 48 if installed: 49 filename = os.path.join(os.path.dirname(filename), 50 dlname) 51 else: 52 # if .libs already there, don't need to add it again 53 if os.path.dirname(filename).endswith('.libs'): 54 filename = os.path.join(os.path.dirname(filename), 55 dlname) 56 else: 57 filename = os.path.join(os.path.dirname(filename), 58 '.libs', dlname) 59 return ihooks.Hooks.load_dynamic(self, name, filename, file)
60 61 importer = ihooks.ModuleImporter() 62 importer.set_hooks(LibtoolHooks()) 63
64 -def install():
65 importer.install()
66 -def uninstall():
67 importer.uninstall()
68 69 install() 70