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 ihooks 
22  import os 
23   
24   
25 -class LibtoolHooks(ihooks.Hooks):
26
27 - def get_suffixes(self):
28 """Like normal get_suffixes, but adds .la suffixes to list""" 29 ret = ihooks.Hooks.get_suffixes(self) 30 ret.insert(0, ('module.la', 'rb', 3)) 31 ret.insert(0, ('.la', 'rb', 3)) 32 return ret
33
34 - def load_dynamic(self, name, filename, file=None):
35 """Like normal load_dynamic, but treat .la files specially""" 36 if len(filename) > 3 and filename[-3:] == '.la': 37 fp = open(filename, 'r') 38 dlname = '' 39 installed = 1 40 line = fp.readline() 41 while line: 42 # dlname: the name that we can dlopen 43 if len(line) > 7 and line[:7] == 'dlname=': 44 dlname = line[8:-2] 45 # installed: whether it's already installed 46 elif len(line) > 10 and line[:10] == 'installed=': 47 installed = line[10:-1] == 'yes' 48 line = fp.readline() 49 fp.close() 50 if dlname: 51 if installed: 52 filename = os.path.join(os.path.dirname(filename), 53 dlname) 54 else: 55 # if .libs already there, don't need to add it again 56 if os.path.dirname(filename).endswith('.libs'): 57 filename = os.path.join(os.path.dirname(filename), 58 dlname) 59 else: 60 filename = os.path.join(os.path.dirname(filename), 61 '.libs', dlname) 62 return ihooks.Hooks.load_dynamic(self, name, filename, file)
63 64 importer = ihooks.ModuleImporter() 65 importer.set_hooks(LibtoolHooks()) 66 67
68 -def install():
69 importer.install()
70 71
72 -def uninstall():
73 importer.uninstall()
74 75 install() 76