#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of Panucci.
# Copyright (c) 2008-2011 The Panucci Project
#
# Panucci is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Panucci is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Panucci.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import

import os.path
import sys
from optparse import OptionParser

# Set up gettext support
import locale
import gettext

prefix = os.path.join( os.path.dirname(sys.argv[0]), '..' )

for basedir in 'share', 'data':
    locale_dir = os.path.abspath(os.path.join( prefix, basedir, 'locale' ))
    if os.path.exists( locale_dir ):
        break

locale_dir = os.environ.get('LOCALE_DIR', locale_dir)
gettext.install( 'panucci', locale_dir )

# Set up the command line option parser
usage = 'usage: %prog [options] FILE'
parser = OptionParser(usage=usage)
parser.add_option('-q', '--queue', action='store', type='string',
    dest='queue_filename', help='Add FILE to the queue', metavar='FILE')
parser.add_option('-d', '--debug', action='store_true', default=False,
    dest='debug', help='Enable verbose logging')
parser.add_option("--gtk", action="store_true")
parser.add_option("--qt", action="store_true")
parser.add_option("--qml", action="store_true")
opts, args = parser.parse_args()

if len(args) > 1 or ( opts.queue_filename and len(args) ):
    parser.print_help()
    sys.exit(1)

local_module_dir = os.path.join(os.path.dirname(sys.argv[0]), '..', 'src')
if os.path.isdir(local_module_dir):
    sys.path.insert(0, local_module_dir)
if os.path.isdir('/opt/panucci/lib/'):
    sys.path.append('/opt/panucci/lib/')
else:
    sys.path.append('/usr/share/panucci/lib/')

from panucci import main
main.run(opts, args)
