Each action should call this logic.
(self, parser, namespace, values, option_string=None)
| 90 | """ |
| 91 | |
| 92 | def __call__(self, parser, namespace, values, option_string=None): |
| 93 | """ |
| 94 | Each action should call this logic. |
| 95 | """ |
| 96 | |
| 97 | dis_dict = {'--add': '+', |
| 98 | '--remove': '-', |
| 99 | '-a': '+', |
| 100 | '-rm': '-', |
| 101 | '--reset': '*'} |
| 102 | #debug |
| 103 | #print '%r %r %r' % (namespace, values, option_string) |
| 104 | if option_string == '--reset': |
| 105 | print 'Base reset to: ', values |
| 106 | Log.history.append(('*' + str(values), |
| 107 | time.strftime(STATIC_T, time.gmtime()))) |
| 108 | Log.save_log() |
| 109 | elif option_string == '--clear': |
| 110 | Log.history = [] |
| 111 | Log.save_log() |
| 112 | os.remove(STATIC_P) |
| 113 | sys.exit('Clear all data...OK') |
| 114 | else: |
| 115 | try: |
| 116 | Log.history.append((dis_dict[option_string] + str(values), |
| 117 | time.strftime(STATIC_T, time.gmtime()))) |
| 118 | except KeyError: |
| 119 | pass |
| 120 | else: |
| 121 | Log.save_log() |
| 122 | Log.print_log() |
| 123 | |
| 124 | |
| 125 | class Leave(object): |