parsing yaml file ( dictionary ) with python
cql confluence def get_credential(): import yaml credentialfilename = r'../credential.yaml' diccredential = yaml.load(open(credentialfilename)) urlbase = diccredential['urlbase'] auth = HTTPBasicAuth(diccredential['username'], diccredential['key']) #credentialfilename.close() return (urlbase,auth) def main(): # get credential returntuple = get_credential() urlbase = returntuple[0] auth = returntuple[1] | |
napalm def get_credential(): import yaml credentialfilename = r'credential_napalm.yaml' diccredential = yaml.load(open(credentialfilename)) hostname = diccredential['hostname'] username = diccredential['username'] password = diccredential['password'] port = diccredential['optional_args']['port'] #credentialfilename.close() return (hostname,username,password,port) def main(): # get credential returntuple = get_credential() hostname = returntuple[0] username = returntuple[1] password = returntuple[2] port = returntuple[3] print(hostname,username,password,port) | |