#!/usr/bin/env python # $Id: documancer.py,v 1.15 2005/02/05 12:36:53 vaclavslavik Exp $ DOCUMANCER_VERSION='0.2.4' # Find out what the data directory is: import sys, os, os.path homedir = os.path.dirname(os.path.realpath(sys.argv[0])) os.environ['DOCUMANCER_HOME'] = homedir # change cwd, to keep wxGlade-generated code happy (FIXME) os.chdir(homedir) # complain about too old Python version: if sys.version_info[0:2] < (2,3): print 'Documancer requires at least Python 2.3, please upgrade.' sys.exit(1) # so that we can run wget.exe and swish-e.exe: if sys.platform == 'win32': # if Mozilla is bundled with the app, use the bundle # otherwise, just assume the user has Python installed # with wxPython/wxMozilla already configured. if os.path.exists(os.path.join(homedir, "mozilla")): os.environ['PATH'] = '%s;%s\\mozilla;%s' % \ (homedir, homedir, os.environ['PATH']) sys.path.append('%s\\mozilla' % homedir) # carry on neccessary upgrades, if any: import compatibility compatibility.upgrade() # handle command-line options: from optparse import OptionParser parser = OptionParser() parser.add_option('-v', '--version', action='store_true', dest='version', default=0, help='show Documancer version and exit') parser.add_option('', '--load-book', action='append', dest='added_books', metavar='BOOK', help='load book from XML file') options, args = parser.parse_args(sys.argv[1:]) if options.version: print 'Documancer %s' % DOCUMANCER_VERSION sys.exit(0) if options.added_books != None: import book if sys.platform == 'win32': import string for mybook in options.added_books: bookname = mybook #on Windows, the filename will have ' ' around it #when double-clicked from Windows Explorer #we need to remove the single quotes before #passing in the book name if bookname[0] == "'" and bookname[-1] == "'": bookname = bookname[1:-1] book.additionalBooks.append(bookname) else: book.additionalBooks = options.added_books # initialize gettext: import gettext # FIXME: bind the domain as on this commented-out line: #gettext.bindtextdomain('documancer', '/path/to/my/language/directory') gettext.textdomain('documancer') # run the application: import gui.app gui.app.run()