My partner and I have written a def, The logic of the def is:
- input table's field name,
- input parameter to the parentheses(parentheses is set for some commands who needs to input string such as:
interface fa(1)/(2)
ip address (3) (4))
input parameter to the parentheses (if requested),then will select command from sqlite db.
interface fa0/1
ip address 192.168.1.1 255.255.255.0
- Finally output commands.
Recently, my partner requests me that I have not to use input He tolds me that I must use "input parameter" And I cannot get his meaning and he will not response me about this question. I have no idea now. If anyone have know about what its mean, please provide an suggestion Thank you.
This is me and my partner python codes:
def get_input():
a = input("function and params (comma separated):")
b = input("device:")
pattern = re.compile('\(.*?\)')
output_commands = []
params = a.split(',')
function = params[0]
print (params)
counter = 1
for result in readciscodevice(function,b):
command = result[0]
found_parentheses_list = re.findall(pattern, command)
output_command = command
for i, param_placeholder in enumerate(found_parentheses_list):
param = params[counter]
output_command = re.sub(pattern, param, output_command, count=1)
counter +=1
output_commands.append(output_command)
return output_commands
# other program calls:
commands = get_input()
for command in commands:
#do sth, print for example
print(command)
Aucun commentaire:
Enregistrer un commentaire