免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2268 | 回复: 3

[函数] proplists:get_value [复制链接]

论坛徽章:
27
水瓶座
日期:2014-08-22 21:06:34程序设计版块每日发帖之星
日期:2015-11-25 06:20:0015-16赛季CBA联赛之新疆
日期:2015-12-19 19:05:48IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:3315-16赛季CBA联赛之上海
日期:2016-04-15 19:51:31程序设计版块每日发帖之星
日期:2016-04-17 06:23:29程序设计版块每日发帖之星
日期:2016-04-23 06:20:00程序设计版块每日发帖之星
日期:2016-05-26 06:20:00每日论坛发贴之星
日期:2016-05-26 06:20:0015-16赛季CBA联赛之辽宁
日期:2017-02-16 23:59:47
发表于 2014-11-26 12:43 |显示全部楼层
本帖最后由 shijiang1130 于 2014-11-26 13:29 编辑

在哪个开源的地方或者内部的OTP/APP里使用到了:
ssh的lib来看,proplists:get_value使用率还是很高的。
怎么用的:
  1. ---------- SSH.ERL
  2. [62]-spec connect(string(), integer(), proplists:proplist()) -> {ok, pid()} |  {error, term()}.
  3. [63]-spec connect(string(), integer(), proplists:proplist(), timeout()) -> {ok, pid()} |  {error, term()}.
  4. [75]            proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}),
  5. [76]        ConnectionTimeout = proplists:get_value(connect_timeout, Options, infinity),
  6. [117]-spec daemon(integer(), proplists:proplist()) -> {ok, pid()}.
  7. [118]-spec daemon(any | inet:ip_address(), integer(), proplists:proplist()) -> {ok, pid()}.
  8. [130]    Options1 = case proplists:get_value(shell, Options0) of
  9. [140]                               {Host0,  proplists:get_value(inet, Options1, inet), Options1};
  10. [176]-spec shell(string(), proplists:proplist()) ->  _.
  11. [177]-spec shell(string(), integer(), proplists:proplist()) ->  _.
  12. [213]    case proplists:get_value(idle_time, SshOptions) of
  13. [257]    try handle_option(proplists:unfold(Opts), [], []) of

  14. ---------- SSHC_SUP.ERL

  15. ---------- SSHD_SUP.ERL
  16. [42]    Address = proplists:get_value(address, ServerOpts),
  17. [43]    Port = proplists:get_value(port, ServerOpts),
  18. [79]              Address = proplists:get_value(address, ServerOpts),
  19. [80]              Port = proplists:get_value(port, ServerOpts),

  20. ---------- SSH_ACCEPTOR.ERL
  21. [44]    proplists:get_value(transport, Opts, {tcp, gen_tcp, tcp_closed}),
  22. [85]    SSHopts = proplists:get_value(ssh_opts, Options, []),
  23. [86]    MaxSessions = proplists:get_value(max_sessions,SSHopts,infinity),
  24. [91]        Timeout = proplists:get_value(negotiation_timeout, SSHopts, 2*60*1000),

  25. ---------- SSH_ACCEPTOR_SUP.ERL
  26. [46]        Address = proplists:get_value(address, ServerOpts),
  27. [47]        Port = proplists:get_value(port, ServerOpts),
  28. [78]    Address = proplists:get_value(address, ServerOpts),
  29. [79]    Port = proplists:get_value(port, ServerOpts),
  30. [80]    Timeout = proplists:get_value(timeout, ServerOpts, ?DEFAULT_TIMEOUT),
  31. [82]    SocketOpts = proplists:get_value(socket_opts, ServerOpts),

  32. ---------- SSH_APP.ERL

  33. ---------- SSH_AUTH.ERL
  34. [45]    KeyCb = proplists:get_value(key_cb, Opts, ssh_file),
  35. [70]    Password = case proplists:get_value(password, Opts) of
  36. [118]       case proplists:get_value(pref_public_key_algs, Opts, false) of
  37. [120]               FirstAlg = proplists:get_value(public_key_alg, Opts, ?PREFERRED_PK_ALG),
  38. [122]               AllowUserInt =  proplists:get_value(user_interaction, Opts, true),
  39. [133]                       AllowUserInt =  proplists:get_value(user_interaction, Opts, true),
  40. [140]                       AllowUserInt = proplists:get_value(user_interaction, Opts, true),
  41. [307]    case proplists:get_value(user, Opts, os:getenv(Env)) of
  42. [320]    case proplists:get_value(pwdfun, Opts) of
  43. [329]    Passwords = proplists:get_value(user_passwords, Opts, []),
  44. [332]   false -> proplists:get_value(password, Opts, false)
  45. [337]    KeyCb =  proplists:get_value(key_cb, Opts, ssh_file),
  46. [372]    case proplists:get_value(keyboard_interact_fun, Opts) of
  47. [376]       case proplists:get_value(password, Opts) of

  48. ---------- SSH_BITS.ERL

  49. ---------- SSH_CHANNEL.ERL
  50. [151]    Cb = proplists:get_value(channel_cb, Options),
  51. [152]    ConnectionManager =  proplists:get_value(cm, Options),
  52. [153]    ChannelId = proplists:get_value(channel_id, Options),
  53. [156]   case proplists:get_value(exec, Options) of
  54. [158]           proplists:get_value(init_args, Options);
  55. [160]           proplists:get_value(init_args, Options) ++ [Exec]

  56. ---------- SSH_CHANNEL_SUP.ERL

  57. ---------- SSH_CLI.ERL
  58. [465]                      proplists:get_value(user, ConnectionInfo),
  59. [471]                              proplists:get_value(peer, ConnectionInfo),
  60. [491]   proplists:get_value(user, ConnectionInfo),
  61. [500]               proplists:get_value(peer, ConnectionInfo),
  62. [514]    case proplists:get_value(echo, Modes, 1) of

  63. ---------- SSH_CLIENT_KEY_API.ERL
  64. [26]                  Algorithm :: 'ssh-rsa'| 'ssh-dss'| atom(), ConnectOptions :: proplists:proplist()) ->
  65. [29]-callback user_key(Algorithm ::  'ssh-rsa'| 'ssh-dss'| atom(), ConnectOptions :: proplists:proplist()) ->

  66. ---------- SSH_CONNECTION.ERL
  67. [935]    case proplists:get_value(subsystems, Options, no_subsys) of
  68. [940]       proplists:get_value(SsName, SubSystems, {none, []})
  69. [944]    Subsystems = proplists:get_value(subsystems, Options, []),
  70. [945]    case proplists:get_value(SsName, Subsystems, {none, []}) of

  71. ---------- SSH_CONNECTION_HANDLER.ERL
  72. [87]-spec start_connection(client| server, port(), proplists:proplist(),
  73. [94]        proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}),
  74. [107]   case proplists:get_value(parallel_login, Options, false) of
  75. [122]    Sups = proplists:get_value(supervisors, Options),
  76. [123]    ConnectionSup = proplists:get_value(connection_sup, Sups),
  77. [124]    Opts = [{supervisors, Sups}, {user_pid, self()} | proplists:get_value(ssh_opts, Options, [])],
  78. [126]    {_, Callback, _} =  proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}),
  79. [139]   proplists:get_value(transport, SshOpts, {tcp, gen_tcp, tcp_closed}),
  80. [232]-spec connection_info(pid(), [atom()]) -> proplists:proplist().
  81. [238]-spec channel_info(pid(), channel_id(), [atom()]) -> proplists:proplist().
  82. [595]    MaxSent = proplists:get_value(rekey_limit, State#state.opts, 1024000000),
  83. [791]    SSHOpts = proplists:get_value(ssh_opts, Opts),
  84. [905]               proplists:get_value(address, SshParams#ssh.opts)])),
  85. [965]    Pid = proplists:get_value(user_pid, Opts),
  86. [973]    Sups = proplists:get_value(supervisors, Opts),
  87. [974]    Pid = proplists:get_value(user_pid, Opts),
  88. [975]    SystemSup = proplists:get_value(system_sup, Sups),
  89. [976]    SubSystemSup = proplists:get_value(subsystem_sup, Sups),
  90. [977]    ConnectionSup = proplists:get_value(connection_sup, Sups),
  91. [978]    Shell = proplists:get_value(shell, Opts),
  92. [979]    Exec = proplists:get_value(exec, Opts),
  93. [980]    CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}),
  94. [990]    case proplists:get_value(idle_time, SshOptions) of
  95. [998]    IOCb = case proplists:get_value(user_interaction, Options, true) of
  96. [1005]    AuthMethods = proplists:get_value(auth_methods, Options,
  97. [1009]    PeerName =  proplists:get_value(host, Options),
  98. [1010]    KeyCb =  proplists:get_value(key_cb, Options, ssh_file),
  99. [1017]   userauth_quiet_mode = proplists:get_value(quiet_mode, Options, false),
  100. [1026]    AuthMethods = proplists:get_value(auth_methods, Options,
  101. [1029]    KeyCb =  proplists:get_value(key_cb, Options, ssh_file),
  102. [1035]   io_cb = proplists:get_value(io_cb, Options, ssh_io),
  103. [1044]  case extract_algs(proplists:get_value(pref_public_key_algs, Options, false), []) of
  104. [1192]      SSHOpts = proplists:get_value(ssh_opts, Opts),
  105. [1203]      SSHOpts = proplists:get_value(ssh_opts, Opts),
  106. [1277]    case proplists:get_value(idle_time, Opts, infinity) of
  107. [1416]    case proplists:get_value(connectfun, Opts) of
  108. [1427]    case proplists:get_value(failfun, Opts) of
  109. [1435]    case proplists:get_value(infofun, Opts) of
  110. [1515]    case proplists:get_value(disconnectfun, Opts) of
  111. [1524]    case proplists:get_value(size, ets:info(Cache)) of
  112. [1526]      case proplists:get_value(idle_time, Opts, infinity) of

  113. ---------- SSH_CONNECTION_SUP.ERL

  114. ---------- SSH_DAEMON_CHANNEL.ERL

  115. ---------- SSH_FILE.ERL
  116. [53]    Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore),
  117. [77]    Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore),
  118. [160]    case proplists:get_value(user_dir_fun, Opts) of
  119. [162]       case proplists:get_value(user_dir, Opts) of
  120. [174]    case proplists:get_value(user_dir, Opts, false) of
  121. [181]    proplists:get_value(system_dir, Opts, "/etc/ssh").
  122. [238]               handle_host(Fd, KeyToMatch, Host, proplists:get_value(hostnames, Attributes), Key, KeyType);

  123. ---------- SSH_IO.ERL
  124. [31]    proplists:get_value(user_pid, Ssh) ! {self(), question},
  125. [39]    proplists:get_value(user_pid, Ssh#ssh.opts) ! {self(), question},
  126. [60]        proplists:get_value(user_pid, Ssh#ssh.opts) ! {self(), user_password};
  127. [62]        proplists:get_value(user_pid, Ssh) ! {self(), user_password}

  128. ---------- SSH_MATH.ERL

  129. ---------- SSH_MESSAGE.ERL

  130. ---------- SSH_NO_IO.ERL

  131. ---------- SSH_SERVER_KEY_API.ERL
  132. [25]-callback host_key(Algorithm :: 'ssh-rsa'| 'ssh-dss'| atom(), DaemonOptions :: proplists:proplist()) ->
  133. [29]                  User :: string(), DaemonOptions :: proplists:proplist()) ->

  134. ---------- SSH_SFTP.ERL
  135. [87]    Timeout = proplists:get_value(timeout, Opts, infinity),
  136. [111]    Timeout = proplists:get_value(timeout, Opts, infinity),
  137. [112]    case ssh_xfer:connect(Host, Port, proplists:delete(timeout, Opts)) of

  138. ---------- SSH_SFTPD.ERL
  139. [93]    {FileMod, FS0} = case proplists:get_value(file_handler, Options,
  140. [102]    CWD = proplists:get_value(cwd, Options, Default),
  141. [104]    Root0 = proplists:get_value(root, Options, ""),
  142. [120]    MaxLength = proplists:get_value(max_files, Options, 0),
  143. [121]    Vsn = proplists:get_value(sftpd_vsn, Options, 5),

  144. ---------- SSH_SFTPD_FILE.ERL

  145. ---------- SSH_SFTPD_FILE_API.ERL

  146. ---------- SSH_SHELL.ERL

  147. ---------- SSH_SUBSYSTEM_SUP.ERL
  148. [64]    case proplists:get_value(role, Opts) of
  149. [72]    Address = proplists:get_value(address, Opts),
  150. [73]    Port = proplists:get_value(port, Opts),
  151. [74]    Role = proplists:get_value(role, Opts),
  152. [84]    Address = proplists:get_value(address, Opts),
  153. [85]    Port = proplists:get_value(port, Opts),
  154. [86]    Role = proplists:get_value(role, Opts),

  155. ---------- SSH_SUP.ERL

  156. ---------- SSH_SYSTEM_SUP.ERL
  157. [46]    Address = proplists:get_value(address, ServerOpts),
  158. [47]    Port = proplists:get_value(port, ServerOpts),
  159. [138]    Address = proplists:get_value(address, ServerOpts),
  160. [139]    Port = proplists:get_value(port, ServerOpts),

  161. ---------- SSH_TRANSPORT.ERL
  162. [46]    Vsn = proplists:get_value(vsn, Options, ?DEFAULT_CLIENT_VERSION),
  163. [50]    Vsn = proplists:get_value(vsn, Options, ?DEFAULT_SERVER_VERSION),
  164. [104]    Compression = case proplists:get_value(compression, Opts, none) of
  165. [121]   lists:member(CryptoAlgo, proplists:get_value(ciphers, Supports, []))],
  166. [125]   lists:member(CryptoAlgo, proplists:get_value(hashs, Supports, []))],
  167. [346]    case proplists:get_value(silently_accept_hosts, Opts, false) of

  168. ---------- SSH_XFER.ERL
  169. [62]    TMO = proplists:get_value(timeout, Opts, infinity),
复制代码

论坛徽章:
27
水瓶座
日期:2014-08-22 21:06:34程序设计版块每日发帖之星
日期:2015-11-25 06:20:0015-16赛季CBA联赛之新疆
日期:2015-12-19 19:05:48IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:3315-16赛季CBA联赛之上海
日期:2016-04-15 19:51:31程序设计版块每日发帖之星
日期:2016-04-17 06:23:29程序设计版块每日发帖之星
日期:2016-04-23 06:20:00程序设计版块每日发帖之星
日期:2016-05-26 06:20:00每日论坛发贴之星
日期:2016-05-26 06:20:0015-16赛季CBA联赛之辽宁
日期:2017-02-16 23:59:47
发表于 2014-11-26 12:44 |显示全部楼层
本帖最后由 shijiang1130 于 2014-11-26 13:30 编辑

基本用法:
  1. 9> L=[{a,"1"},{b,"2"}].
  2. [{a,"1"},{b,"2"}]
  3. 10> proplists:get_value(b,L).
  4. "2"
复制代码

论坛徽章:
0
发表于 2014-11-26 13:01 |显示全部楼层
看了你发的众多帖子,很多既不是提问,也不是浅显或者深入的介绍,顶多就是让大家或者让自己知道有这么个东西,
能否从 基本介绍,应该怎么使用,使用的注意事项,使用的场景,在哪个开源的地方或者内部的OTP/APP里使用到了,怎么用的  等方面来发帖子,这样我想关注和互动的人会更多,这版块也会更活跃些

论坛徽章:
27
水瓶座
日期:2014-08-22 21:06:34程序设计版块每日发帖之星
日期:2015-11-25 06:20:0015-16赛季CBA联赛之新疆
日期:2015-12-19 19:05:48IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:3315-16赛季CBA联赛之上海
日期:2016-04-15 19:51:31程序设计版块每日发帖之星
日期:2016-04-17 06:23:29程序设计版块每日发帖之星
日期:2016-04-23 06:20:00程序设计版块每日发帖之星
日期:2016-05-26 06:20:00每日论坛发贴之星
日期:2016-05-26 06:20:0015-16赛季CBA联赛之辽宁
日期:2017-02-16 23:59:47
发表于 2014-11-26 13:34 |显示全部楼层
二货康康 发表于 2014-11-26 13:01
看了你发的众多帖子,很多既不是提问,也不是浅显或者深入的介绍,顶多就是让大家或者让自己知道有这么个东 ...
:谢谢精彩的评论。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP