File: pyching.py

package info (click to toggle)
pyching 1.2.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 504 kB
  • ctags: 286
  • sloc: python: 4,066; makefile: 38; sh: 2
file content (75 lines) | stat: -rwxr-xr-x 2,980 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /usr/bin/env python
##---------------------------------------------------------------------------##
##
## pyChing -- a Python program to cast and interpret I Ching hexagrams
##
## Copyright (C) 1999-2006 Stephen M. Gava
##
## This program 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 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be of some
## interest to somebody, 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 this program; see the file COPYING or COPYING.txt. If not, 
##  write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
## The license can also be found at the GNU/FSF website: http://www.gnu.org
##
## Stephen M. Gava
## <elguavas@users.sourceforge.net>
## http://pyching.sourgeforge.net
##
##---------------------------------------------------------------------------##
"""
start-up module for pyching
"""

import sys

#handle command line switches
def CommandLineSwitches():
    if ('-h' in sys.argv) or ('/h' in sys.argv) or('--help' in sys.argv):
        print ' pyChing - command line switches\n'
        print ' -h, --help                   display this help message'
        print ' -v, --version                display pyching version'
        print ' -d, --disable-version-check  disable Python and Tk version check'
        #print ' -c, --console                run the console version of pyChing 
        sys.exit(0)
    elif ('-v' in sys.argv) or ('/v' in sys.argv) or('--version' in sys.argv):
        from pyching_engine import PychingAppDetails 
        pyching = PychingAppDetails(createConfigDir=0)
        print 'pyChing version:',pyching.version
        sys.exit(0)

    if ('-d' in sys.argv) or ('/d' in sys.argv) or('--disable-version-check' in sys.argv):
        sys.stderr.write("warning - Python and Tk version checking disabled!\n")
    else: #do version checking
        import string
        from Tkinter import TkVersion
        if string.split(sys.version)[0] < '1.5.1': #python version check
            sys.stderr.write("Sorry, pyChing requires at least Python 1.5.1\n")
            sys.exit(1)
        if `TkVersion` < '8.0': #tk version check
            sys.stderr.write("Sorry, pyChing requires at least Tk 8.0\n")
            sys.exit(1)

CommandLineSwitches()

#run pyching

#if ('-c' in sys.argv) or ('/c' in sys.argv) or('--console' in sys.argv):
# #run the console version of pyChing - needs tidying up first
# import pyching_interface_console 
#else:

#run pyching Tkinter GUI
import pyching_interface_tkinter

#if we got to here exit cleanly
sys.exit(0)