def mode_settings(cmd, mode=None): cmd = cmd.split(' ') if cmd == ['']: # If empty response, then leave prematurely. return mode rv_modes = [] if '-dp' in cmd: removal_idx = cmd.index('-dp') print('Adding: ') if '-dp' in cmd: print(cmd[:removal_idx]) print('Removing') print(cmd[removal_idx + 1:]) rv_modes = cmd[removal_idx + 1:] cmd = cmd[:removal_idx] else: print(cmd) if len(cmd) > 0 and '-dp' not in cmd: for i in range(len(cmd)): try: int(cmd[i]) except ValueError: print('Wrong data type for mode, please check your inputs.') continue if int(cmd[i]) == 1: mode01() if mode01.flag == 'X': mode[1] = mode01 else: mode.pop(1) elif int(cmd[i]) == 10: mode10() if mode10.flag == 'X': mode[10] = mode10 else: mode.pop(10) elif int(cmd[i]) == 11: mode11() if mode11.flag == 'X': mode[11] = mode11 else: mode.pop(11) # Remove modes (Check if the modes itself overwrites basic settings) if len(rv_modes) > 0: for mode_opt in rv_modes: try: print(mode[int(mode_opt)].flag) mode[int(mode_opt)].drop_flag() except KeyError: continue except ValueError: continue return mode
def mode_settings(cmd, mode=None): cmd = cmd.split(' ') if cmd == ['']: # If empty response, then leave prematurely. return mode rv_modes = [] if '-dp' in cmd: removal_idx = cmd.index('-dp') print('Adding: ') if '-dp' in cmd: print(cmd[:removal_idx]) print('Removing') print(cmd[removal_idx + 1:]) rv_modes = cmd[removal_idx + 1:] cmd = cmd[:removal_idx] else: print(cmd) if len(cmd) > 0 and '-dp' not in cmd: for i in range(len(cmd)): try: int(cmd[i]) except ValueError: print('Wrong data type for mode, please check your inputs.') continue if int(cmd[i]) == 1: mode01() if mode01.flag == 'X': mode[1] = mode01 else: mode.pop(1) elif int(cmd[i]) == 2: mode02() if mode02.flag == 'X': mode[2] = mode02 else: mode.pop(2) elif int(cmd[i]) == 4: mode04() if mode04.flag == 'X': mode[4] = mode04 else: mode.pop(4) elif int(cmd[i]) == 5: mode05() if mode05.flag == 'X': mode[5] = mode05 else: mode.pop(5) elif int(cmd[i]) == 7: mode07() if mode07.flag == 'X': mode[7] = mode07 else: mode.pop(7) elif int(cmd[i]) == 8: mode08() if mode08.flag == 'X': mode[8] = mode08 else: mode.pop(8) elif int(cmd[i]) == 10: mode10() if mode10.flag == 'X': mode[10] = mode10 else: mode.pop(10) elif int(cmd[i]) == 11: mode11() if mode11.flag == 'X': mode[11] = mode11 else: mode.pop(10) elif int(cmd[i]) == 20: mode20() if mode20.flag == 'X': mode[20] = mode20 else: mode.pop(21) elif int(cmd[i]) == 21: mode21() if mode21.flag == 'X': mode[21] = mode21 else: mode.pop(21) elif int(cmd[i]) == 22: if check_main_mode_opinion(modes, 22) == True: mode22() if mode22.flag == 'X': mode[22] = mode22 else: mode.pop(22) elif int(cmd[i]) == 23: if check_main_mode_opinion(modes, 23) == True: mode23() if mode23.flag == 'X': mode[23] = mode23 else: mode.pop(23) elif int(cmd[i]) == 24: if check_main_mode_opinion(modes, 24) == True: mode24() if mode24.flag == 'X': mode[24] = mode24 else: mode.pop(24) elif int(cmd[i]) == 31: mode31() if mode31.flag == 'X': mode[31] = mode31 else: mode.pop(31) elif int(cmd[i]) == 51: if (mode52.flag == 'X'): print( 'Mode 52 has been activated. Mode 51 unable to start.') break elif (mode53.flag == 'X'): print( 'Mode 53 has been activated. Mode 51 unable to start.') break elif (mode54.flag == 'X'): print( 'Mode 54 has been activated. Mode 51 unable to start.') break mode51() if mode51.flag == 'X': mode[51] = mode51 else: mode.pop(51) elif int(cmd[i]) == 52: if (mode51.flag == 'X'): print( 'Mode 51 has been activated. Mode 52 unable to start.') break elif (mode53.flag == 'X'): print( 'Mode 53 has been activated. Mode 51 unable to start.') break elif (mode54.flag == 'X'): print( 'Mode 54 has been activated. Mode 51 unable to start.') break mode52() if mode52.flag == 'X': mode[52] = mode52 else: mode.pop(52) # Remove modes (Check if the modes itself overwrites basic settings) if len(rv_modes) > 0: for mode_opt in rv_modes: try: print(mode[int(mode_opt)].flag) mode[int(mode_opt)].drop_flag() except KeyError: continue except ValueError: continue return mode
def mode_settings(cmd, mode=None): cmd = cmd.split(' ') print(cmd) if len(cmd) > 0: for i in range(len(cmd)): try: int(cmd[i]) except ValueError: print('Wrong data type for mode, please check your inputs.') continue if int(cmd[i]) == 1: mode01() if mode01.flag == 'X': mode[1] = mode01 else: mode.pop(1) elif int(cmd[i]) == 2: mode02.set_proportion() mode02() if mode02.flag == 'X': mode[2] = mode02 else: mode.pop(2) elif int(cmd[i]) == 4: mode04() if mode04.flag == 'X': mode[4] = mode04 else: mode.pop(4) elif int(cmd[i]) == 5: mode05() if mode05.flag == 'X': mode[5] = mode05 else: mode.pop(5) elif int(cmd[i]) == 6: mode06() if mode06.flag == 'X': mode[6] = mode06 else: mode.pop(6) elif int(cmd[i]) == 21: mode21() if mode21.flag == 'X': mode[21] = mode21 else: mode.pop(21) elif int(cmd[i]) == 31: mode31() if mode31.flag == 'X': mode[31] = mode31 else: mode.pop(31) elif int(cmd[i]) == 51: if 52 in cmd: print( 'Mode 52 has been activated. Mode 51 unable to start.') break mode51() if mode51.flag == 'X': mode[51] = mode51 else: mode.pop(51) elif int(cmd[i]) == 52: if 51 in cmd: print( 'Mode 51 has been activated. Mode 52 unable to start.') break mode52() if mode52.flag == 'X': mode[52] = mode52 else: mode.pop(52) return mode
elif sys.argv[i] == '-m': for j in range(i + 1, len(sys.argv)): # Skip at other options if sys.argv[j][:2] == '--': mode_flag = int(sys.argv[j][2:]) print('Loading mode: {}'.format(mode_flag)) # Activate modes with no options needed if mode_flag == 21: info_nwk.set_roster() info_nwk.set_population() mode21.raise_flag() if mode21.flag == 'X': modes[21] = mode21 else: mode.pop(21) elif mode_flag == 51: if 52 in modes: print( 'Mode 52 has been activated. Ignore mode 51. ') break elif 53 in modes: print( 'Mode 53 has been activated. Ignore mode 52. ') break elif 54 in modes: print( 'Mode 54 has been activated. Ignore mode 52. ') break mode51() if mode51.flag == 'X':
break mode51() if mode51.flag == 'X': modes[51] = mode51 else: modes.pop(51) elif mode_flag == 52: if 51 in modes: print( 'Mode 51 has been activated. Ignore mode 52. ') break mode52() if mode52.flag == 'X': modes[52] = mode52 else: mode.pop(52) # Loop through config values for k in range(j + 1, len(sys.argv)): if sys.argv[k][0] == '-' and sys.argv[k][1].isalpha(): break if sys.argv[k][:2] == '--': break # Set up individual modes if mode_flag == 1: # Placeholder # print(sys.argv[k]) pass elif mode_flag == 6: # Set weight [---w]