私は変数でいっぱいのライブラリを持っています(私は手で編集したくないです)、それは次のようになります:
def get_variables(gateway):
variables={
'gateway':gateway,
'license_test_data':gateway['license_data'],
'license_for_application':gateway['license_for_application'],
'Valid_Login_Test_Vairables':{'valid_ssh_command':['ssh '+gateway['DeviceUnderTestUserid']+'@'+gateway['DeviceUnderTestIP'],'password:']}
#around 3000 more just like this or worse
}
return variables
'gateway'変数を置き換えずに、この情報をPythonデータ構造にインポートする必要があります。言い換えれば、私は次のことができるようになりたいと思っています。
print vars['Valid_Login_Test_Vairables']['valid_ssh_command']
まさにこれを手に入れよう
'ssh +gateway['DeviceUnderTestUserid']+'@'+gateway['DeviceUnderTestIP'],'password:']
代わりに私はこれで終わります:
print vars['Valid_Login_Test_Vairables']['valid_ssh_command']
"ssh gateway['DeviceUnderTestUserid']@gateway['DeviceUnderTestIP']", 'password:'
私が試しているのはこれです:
import varfile
import dummy.gateway
vars=varfile.get_variables(dummy.gateway)
私のdummy.gatewayは次のようになっています:
gateway['license_test_data'] = "gateway['license_test_data']"
gateway['license_for_application'] = "gateway['license_for_application']"
gateway['license_for_setup'] = "gateway['license_for_setup']"
変数ファイルの正確な内容を有用なデータ構造にするにはどうすればよいですか?