~manxi-david/pyeffect/pyeffect

« back to all changes in this revision

Viewing changes to args.py

  • Committer: dvspeed
  • Date: 2011-12-26 13:18:36 UTC
  • Revision ID: manxi.david@gmail.com-20111226131836-mvoy9y32z0ujxvm1
-Change of folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2011 David Manzanares <manxi.david@gmail.com>
2
 
#This file is part of PyEffect.
3
 
#
4
 
# PyEffect is free software: you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation, either version 3 of the License, or
7
 
# (at your option) any later version.
8
 
#
9
 
# PyEffect is distributed in the hope that it will be useful,
10
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 
# GNU General Public License for more details.
13
 
#
14
 
# You should have received a copy of the GNU General Public License
15
 
# along with PyEffect. If not, see <http://www.gnu.org/licenses/>.
16
 
 
17
 
#This is the PyEffect argument parser
18
 
 
19
 
#Purpose:
20
 
#Check all the arguments given to PyEffect
21
 
 
22
 
#Third party libraries:
23
 
 
24
 
#Global variables:
25
 
#These vars are read by the other modules
26
 
target = -1
27
 
execute = False
28
 
quiet = False
29
 
verbose = False
30
 
keep = False
31
 
gstabs = False
32
 
opt = True
33
 
arch = None
34
 
color = False
35
 
log = False
36
 
makeLib = False
37
 
 
38
 
#Own libraries:
39
 
import files
40
 
import help
41
 
import out
42
 
 
43
 
def parser(argv):
44
 
        """Parse all arguments"""
45
 
        global target
46
 
        global execute
47
 
        global quiet
48
 
        global verbose
49
 
        global keep
50
 
        global gstabs
51
 
        global opt
52
 
        global arch
53
 
        global color
54
 
        global log
55
 
        global makeLib
56
 
        argv = argv[2:]
57
 
        for arg in argv:
58
 
                if arg[0] == "-":
59
 
                        if arg == "--version":
60
 
                                out.printVersion()
61
 
                                exit(0)
62
 
                        elif arg == "-c" or arg == "--clean":
63
 
                                clean()
64
 
                        elif arg == "-e" or arg == "--execute":
65
 
                                execute = True
66
 
                        elif arg == "-q" or arg == "--quiet":
67
 
                                quiet = True
68
 
                        elif arg == "-k" or arg == "--keep":
69
 
                                keep = True
70
 
                        elif arg == "-v" or arg == "--verbose":
71
 
                                verbose = True
72
 
                        elif arg == "-g" or arg == "--gstabs":
73
 
                                gstabs = True
74
 
                        elif arg == "--log":
75
 
                                log = True
76
 
                                gstabs = True
77
 
                        elif arg == "-mkl":
78
 
                                makeLib = True
79
 
                        elif arg == "-nopt":
80
 
                                opt = False
81
 
                        elif arg[0:7] == "--arch=":
82
 
                                arch = arg[7:]
83
 
                        elif arg == "--color":
84
 
                                out.activateColor()
85
 
                                color = True
86
 
                        elif arg == "-h" or arg == "--help":
87
 
                                print help.all
88
 
                                exit(0)
89
 
                        else:
90
 
                                print "Error, argument (" + repr(arg) + ") invalid"
91
 
                                exit(1)
92
 
                else:
93
 
                        target = arg
94
 
        if target == -1:
95
 
                out.error("There is no target, please check usage with: cec --help")
96
 
 
97
 
def version():
98
 
        """Print the version and exit"""
99
 
        out.version()
100
 
        exit(0)
101
 
def clean():
102
 
        """Clean the directory"""
103
 
        files.cleanDir("")
104
 
        exit(0)