proplists:get_value
本帖最后由 shijiang1130 于 2014-11-26 13:29 编辑在哪个开源的地方或者内部的OTP/APP里使用到了:
从ssh的lib来看,proplists:get_value使用率还是很高的。
怎么用的:---------- SSH.ERL
-spec connect(string(), integer(), proplists:proplist()) -> {ok, pid()} |{error, term()}.
-spec connect(string(), integer(), proplists:proplist(), timeout()) -> {ok, pid()} |{error, term()}.
proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}),
ConnectionTimeout = proplists:get_value(connect_timeout, Options, infinity),
-spec daemon(integer(), proplists:proplist()) -> {ok, pid()}.
-spec daemon(any | inet:ip_address(), integer(), proplists:proplist()) -> {ok, pid()}.
Options1 = case proplists:get_value(shell, Options0) of
{Host0,proplists:get_value(inet, Options1, inet), Options1};
-spec shell(string(), proplists:proplist()) ->_.
-spec shell(string(), integer(), proplists:proplist()) ->_.
case proplists:get_value(idle_time, SshOptions) of
try handle_option(proplists:unfold(Opts), [], []) of
---------- SSHC_SUP.ERL
---------- SSHD_SUP.ERL
Address = proplists:get_value(address, ServerOpts),
Port = proplists:get_value(port, ServerOpts),
Address = proplists:get_value(address, ServerOpts),
Port = proplists:get_value(port, ServerOpts),
---------- SSH_ACCEPTOR.ERL
proplists:get_value(transport, Opts, {tcp, gen_tcp, tcp_closed}),
SSHopts = proplists:get_value(ssh_opts, Options, []),
MaxSessions = proplists:get_value(max_sessions,SSHopts,infinity),
Timeout = proplists:get_value(negotiation_timeout, SSHopts, 2*60*1000),
---------- SSH_ACCEPTOR_SUP.ERL
Address = proplists:get_value(address, ServerOpts),
Port = proplists:get_value(port, ServerOpts),
Address = proplists:get_value(address, ServerOpts),
Port = proplists:get_value(port, ServerOpts),
Timeout = proplists:get_value(timeout, ServerOpts, ?DEFAULT_TIMEOUT),
SocketOpts = proplists:get_value(socket_opts, ServerOpts),
---------- SSH_APP.ERL
---------- SSH_AUTH.ERL
KeyCb = proplists:get_value(key_cb, Opts, ssh_file),
Password = case proplists:get_value(password, Opts) of
case proplists:get_value(pref_public_key_algs, Opts, false) of
FirstAlg = proplists:get_value(public_key_alg, Opts, ?PREFERRED_PK_ALG),
AllowUserInt =proplists:get_value(user_interaction, Opts, true),
AllowUserInt =proplists:get_value(user_interaction, Opts, true),
AllowUserInt = proplists:get_value(user_interaction, Opts, true),
case proplists:get_value(user, Opts, os:getenv(Env)) of
case proplists:get_value(pwdfun, Opts) of
Passwords = proplists:get_value(user_passwords, Opts, []),
false -> proplists:get_value(password, Opts, false)
KeyCb =proplists:get_value(key_cb, Opts, ssh_file),
case proplists:get_value(keyboard_interact_fun, Opts) of
case proplists:get_value(password, Opts) of
---------- SSH_BITS.ERL
---------- SSH_CHANNEL.ERL
Cb = proplists:get_value(channel_cb, Options),
ConnectionManager =proplists:get_value(cm, Options),
ChannelId = proplists:get_value(channel_id, Options),
case proplists:get_value(exec, Options) of
proplists:get_value(init_args, Options);
proplists:get_value(init_args, Options) ++
---------- SSH_CHANNEL_SUP.ERL
---------- SSH_CLI.ERL
proplists:get_value(user, ConnectionInfo),
proplists:get_value(peer, ConnectionInfo),
proplists:get_value(user, ConnectionInfo),
proplists:get_value(peer, ConnectionInfo),
case proplists:get_value(echo, Modes, 1) of
---------- SSH_CLIENT_KEY_API.ERL
Algorithm :: 'ssh-rsa'| 'ssh-dss'| atom(), ConnectOptions :: proplists:proplist()) ->
-callback user_key(Algorithm ::'ssh-rsa'| 'ssh-dss'| atom(), ConnectOptions :: proplists:proplist()) ->
---------- SSH_CONNECTION.ERL
case proplists:get_value(subsystems, Options, no_subsys) of
proplists:get_value(SsName, SubSystems, {none, []})
Subsystems = proplists:get_value(subsystems, Options, []),
case proplists:get_value(SsName, Subsystems, {none, []}) of
---------- SSH_CONNECTION_HANDLER.ERL
-spec start_connection(client| server, port(), proplists:proplist(),
proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}),
case proplists:get_value(parallel_login, Options, false) of
Sups = proplists:get_value(supervisors, Options),
ConnectionSup = proplists:get_value(connection_sup, Sups),
Opts = [{supervisors, Sups}, {user_pid, self()} | proplists:get_value(ssh_opts, Options, [])],
{_, Callback, _} =proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}),
proplists:get_value(transport, SshOpts, {tcp, gen_tcp, tcp_closed}),
-spec connection_info(pid(), ) -> proplists:proplist().
-spec channel_info(pid(), channel_id(), ) -> proplists:proplist().
MaxSent = proplists:get_value(rekey_limit, State#state.opts, 1024000000),
SSHOpts = proplists:get_value(ssh_opts, Opts),
proplists:get_value(address, SshParams#ssh.opts)])),
Pid = proplists:get_value(user_pid, Opts),
Sups = proplists:get_value(supervisors, Opts),
Pid = proplists:get_value(user_pid, Opts),
SystemSup = proplists:get_value(system_sup, Sups),
SubSystemSup = proplists:get_value(subsystem_sup, Sups),
ConnectionSup = proplists:get_value(connection_sup, Sups),
Shell = proplists:get_value(shell, Opts),
Exec = proplists:get_value(exec, Opts),
CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, }),
case proplists:get_value(idle_time, SshOptions) of
IOCb = case proplists:get_value(user_interaction, Options, true) of
AuthMethods = proplists:get_value(auth_methods, Options,
PeerName =proplists:get_value(host, Options),
KeyCb =proplists:get_value(key_cb, Options, ssh_file),
userauth_quiet_mode = proplists:get_value(quiet_mode, Options, false),
AuthMethods = proplists:get_value(auth_methods, Options,
KeyCb =proplists:get_value(key_cb, Options, ssh_file),
io_cb = proplists:get_value(io_cb, Options, ssh_io),
case extract_algs(proplists:get_value(pref_public_key_algs, Options, false), []) of
SSHOpts = proplists:get_value(ssh_opts, Opts),
SSHOpts = proplists:get_value(ssh_opts, Opts),
case proplists:get_value(idle_time, Opts, infinity) of
case proplists:get_value(connectfun, Opts) of
case proplists:get_value(failfun, Opts) of
case proplists:get_value(infofun, Opts) of
case proplists:get_value(disconnectfun, Opts) of
case proplists:get_value(size, ets:info(Cache)) of
case proplists:get_value(idle_time, Opts, infinity) of
---------- SSH_CONNECTION_SUP.ERL
---------- SSH_DAEMON_CHANNEL.ERL
---------- SSH_FILE.ERL
Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore),
Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore),
case proplists:get_value(user_dir_fun, Opts) of
case proplists:get_value(user_dir, Opts) of
case proplists:get_value(user_dir, Opts, false) of
proplists:get_value(system_dir, Opts, "/etc/ssh").
handle_host(Fd, KeyToMatch, Host, proplists:get_value(hostnames, Attributes), Key, KeyType);
---------- SSH_IO.ERL
proplists:get_value(user_pid, Ssh) ! {self(), question},
proplists:get_value(user_pid, Ssh#ssh.opts) ! {self(), question},
proplists:get_value(user_pid, Ssh#ssh.opts) ! {self(), user_password};
proplists:get_value(user_pid, Ssh) ! {self(), user_password}
---------- SSH_MATH.ERL
---------- SSH_MESSAGE.ERL
---------- SSH_NO_IO.ERL
---------- SSH_SERVER_KEY_API.ERL
-callback host_key(Algorithm :: 'ssh-rsa'| 'ssh-dss'| atom(), DaemonOptions :: proplists:proplist()) ->
User :: string(), DaemonOptions :: proplists:proplist()) ->
---------- SSH_SFTP.ERL
Timeout = proplists:get_value(timeout, Opts, infinity),
Timeout = proplists:get_value(timeout, Opts, infinity),
case ssh_xfer:connect(Host, Port, proplists:delete(timeout, Opts)) of
---------- SSH_SFTPD.ERL
{FileMod, FS0} = case proplists:get_value(file_handler, Options,
CWD = proplists:get_value(cwd, Options, Default),
Root0 = proplists:get_value(root, Options, ""),
MaxLength = proplists:get_value(max_files, Options, 0),
Vsn = proplists:get_value(sftpd_vsn, Options, 5),
---------- SSH_SFTPD_FILE.ERL
---------- SSH_SFTPD_FILE_API.ERL
---------- SSH_SHELL.ERL
---------- SSH_SUBSYSTEM_SUP.ERL
case proplists:get_value(role, Opts) of
Address = proplists:get_value(address, Opts),
Port = proplists:get_value(port, Opts),
Role = proplists:get_value(role, Opts),
Address = proplists:get_value(address, Opts),
Port = proplists:get_value(port, Opts),
Role = proplists:get_value(role, Opts),
---------- SSH_SUP.ERL
---------- SSH_SYSTEM_SUP.ERL
Address = proplists:get_value(address, ServerOpts),
Port = proplists:get_value(port, ServerOpts),
Address = proplists:get_value(address, ServerOpts),
Port = proplists:get_value(port, ServerOpts),
---------- SSH_TRANSPORT.ERL
Vsn = proplists:get_value(vsn, Options, ?DEFAULT_CLIENT_VERSION),
Vsn = proplists:get_value(vsn, Options, ?DEFAULT_SERVER_VERSION),
Compression = case proplists:get_value(compression, Opts, none) of
lists:member(CryptoAlgo, proplists:get_value(ciphers, Supports, []))],
lists:member(CryptoAlgo, proplists:get_value(hashs, Supports, []))],
case proplists:get_value(silently_accept_hosts, Opts, false) of
---------- SSH_XFER.ERL
TMO = proplists:get_value(timeout, Opts, infinity), 本帖最后由 shijiang1130 于 2014-11-26 13:30 编辑
基本用法:9> L=[{a,"1"},{b,"2"}].
[{a,"1"},{b,"2"}]
10> proplists:get_value(b,L).
"2"
看了你发的众多帖子,很多既不是提问,也不是浅显或者深入的介绍,顶多就是让大家或者让自己知道有这么个东西,
能否从 基本介绍,应该怎么使用,使用的注意事项,使用的场景,在哪个开源的地方或者内部的OTP/APP里使用到了,怎么用的等方面来发帖子,这样我想关注和互动的人会更多,这版块也会更活跃些 二货康康 发表于 2014-11-26 13:01 static/image/common/back.gif
看了你发的众多帖子,很多既不是提问,也不是浅显或者深入的介绍,顶多就是让大家或者让自己知道有这么个东 ...:谢谢精彩的评论。
页:
[1]