Commit 8f12da81a6051504236d8791f0db07a1129bd4f2

Authored by knodlseder
1 parent 07c96931

use only a single constructor that handles optional arguments

Showing 1 changed file with 9 additions and 26 deletions
scripts/cssens.py
... ... @@ -43,41 +43,24 @@ class cssens(GApplication):
43 43 files, command line arguments, and logging. In that way the Python
44 44 script behaves just as a regular ctool.
45 45 """
46   - def __init__(self):
  46 + def __init__(self, *argv):
47 47 """
48   - Void constructor.
  48 + Constructor.
49 49 """
50 50 # Set name
51 51 self.name = "cssens"
52   - self.version = "0.1.0"
  52 + self.version = "0.1.1"
53 53  
54 54 # Make sure that parfile exists
55 55 file = self.parfile()
56 56  
57 57 # Initialise application
58   - GApplication.__init__(self, self.name, self.version)
59   -
60   - # Set logger properties
61   - self.logFileOpen()
62   - self.log_header()
63   - self.log.date(True)
64   -
65   - # Return
66   - return
67   -
68   - def __init__(self, argv):
69   - """
70   - Command line constructor.
71   - """
72   - # Set name
73   - self.name = "cssens"
74   - self.version = "0.1.0"
75   -
76   - # Make sure that parfile exists
77   - file = self.parfile()
78   -
79   - # Initialise application
80   - GApplication.__init__(self, self.name, self.version, argv)
  58 + if len(argv) == 0:
  59 + GApplication.__init__(self, self.name, self.version)
  60 + elif len(argv) ==1:
  61 + GApplication.__init__(self, self.name, self.version, *argv)
  62 + else:
  63 + raise TypeError("Invalid number of arguments given.")
81 64  
82 65 # Set logger properties
83 66 self.logFileOpen()
... ...