MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/577280_Holiday_Leave/recipe-577280.py:130–164  ·  view source on GitHub ↗

Prepare argparse & pickle.

(self)

Source from the content-addressed store, hash-verified

128 """
129
130 def __init__(self):
131 """
132 Prepare argparse & pickle.
133 """
134
135 # create the parser
136 parser = argparse.ArgumentParser(
137 description=self.__class__.__doc__,
138 argument_default=argparse.SUPPRESS)
139
140 # add the arguments
141 parser.add_argument('--add', '-a', type=int, dest='add', action=Operate,
142 help='add some free days', default=0)
143 parser.add_argument('--remove', '-rm', type=int, dest='remove', action=Operate,
144 help='remove some free days', default=0)
145 parser.add_argument('--reset', type=int, dest='reset',
146 action=Operate,
147 help='reset holiday base', default=26)
148 parser.add_argument('--show', action=Operate, nargs='?',
149 help='show holiday changelog')
150 parser.add_argument('--clear', action=Operate, nargs='?',
151 help='clear all logs')
152
153 # create file | use the existing one
154 try:
155 Log.history = pickle.load(open('history.p', 'rb'))
156 except IOError:
157 output = open(STATIC_P, 'wb')
158 Log.history = [('*' + \
159 str(int(raw_input('Your holiday base (int): '))),
160 time.strftime(STATIC_T, time.gmtime()))]
161 pickle.dump( Log.history, output, protocol=PROTOCOL )
162 output.close()
163 finally:
164 parser.parse_args()
165
166if __name__ == '__main__':
167 LEAVE = Leave()

Callers

nothing calls this directly

Calls 7

strFunction · 0.85
gmtimeMethod · 0.80
openFunction · 0.50
loadMethod · 0.45
dumpMethod · 0.45
closeMethod · 0.45
parse_argsMethod · 0.45

Tested by

no test coverage detected