~gestikk/gestikk/main

« back to all changes in this revision

Viewing changes to gestikk/files.py

  • Committer: Friedrich Weber
  • Date: 2008-07-16 12:54:28 UTC
  • Revision ID: fred@reichbier.de-20080716125428-pun68suubzku2rj5
a new basic plugin interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import sys
24
24
import os.path
25
25
 
 
26
START_FILE = 'start_gestikk.py' # TODO?
 
27
 
26
28
def get_basedir():
27
29
    """ func to get the basedir, from exaile """
28
30
    basedir = os.path.dirname(os.path.realpath(__file__))
29
 
    if not os.path.exists(os.path.join(basedir, "gestikk.py")):
30
 
        if os.path.exists(os.path.join(os.getcwd(), "gestikk.py")):
 
31
    if not os.path.exists(os.path.join(basedir, START_FILE)):
 
32
        if os.path.exists(os.path.join(os.getcwd(), START_FILE)):
31
33
            basedir = os.getcwd()
32
 
        elif os.path.exists(os.path.join(os.path.normpath(os.path.join(basedir, '..')), 'gestikk.py')):
 
34
        elif os.path.exists(os.path.join(os.path.normpath(os.path.join(basedir, '..')), START_FILE)):
33
35
            basedir = os.path.normpath(os.path.join(basedir, '..'))
34
36
        else:
35
37
            basedir = '/usr/share/gestikk'
37
39
 
38
40
BASEDIR = get_basedir()
39
41
sys.path.insert(0, BASEDIR)
 
42
sys.path.insert(0, os.path.split(BASEDIR)[0])
40
43
 
41
44
def get_path_for(kind):
42
45
    """ return path for `kind`; linux-only at the moment
43
46
        :param kind: one of 'pixmap', 'icon'
44
47
    """
 
48
    if kind == 'plugins':
 
49
        return os.path.join(get_path_for('configuration'), 'plugins')
45
50
    return {'pixmap':'/usr/share/pixmaps',
46
51
            'icon':'/usr/share/icons',
47
52
            'gladefile':'/usr/share/gestikk',
48
53
            'executable':'/usr/bin',
49
 
            'configuration':os.path.expanduser('~/.gestikk')}.get(kind, '')
 
54
            'configuration':os.path.expanduser('~/.gestikk'),
 
55
            }.get(kind, '')
50
56
 
51
57
def get_file(name, kind):
52
58
    """ get a file. I'll try to search it in-place, then system-wide; linux-only at the moment