Add to TODO: Use a gconf schema
[dragbox.git] / dragbox
blob3f14c4d6068dcd4f274aceda63cd9e32d4c2abc6
1 #!/usr/bin/env python
2 # -*- coding: utf8 -*-
3 # Copyright (C) 2006, 2007 Ulrik Sverdrup
5 # dragbox -- Commandline drag-and-drop tool for GNOME
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 # USA
22 def find_package_path():
23 u"""
24 If the Dragbox package is not in the path, try to find it
26 Adapted scribes' source (http://scribes.sf.net)
27 Copyright © 2005 Lateef Alabi-Oki
28 """
30 from sys import argv, exit
31 from os import path
33 package_name = "Dragbox"
35 head, tail = path.split(path.split(path.abspath(argv[0]))[0])
37 if tail == 'bin':
39 libdir = path.join(head, "lib")
41 if path.exists(libdir):
43 python_dir = libdir + "/python"
44 package_lib_dir = path.join(python_dir, package_name)
46 if package_lib_dir and path.exists(package_lib_dir):
48 return python_dir
50 else:
52 python_dir = libdir + "/python2.4/site-packages"
53 package_lib_dir = path.join(python_dir, package_name)
55 if package_lib_dir and path.exists(package_lib_dir):
57 return python_dir
59 else:
61 print "Could not find the Dragbox package"
62 print "Check your PYTHONPATH, _and_ file a bug"
63 raise SystemExit(1)
65 return
67 try:
68 from Dragbox.main import dragbox
69 except ImportError:
70 from sys import path
71 python_dir = find_package_path()
72 path.insert(0, python_dir)
73 from Dragbox.main import dragbox
76 if __name__ == "__main__":
77 dragbox()