搜索矿山目录
csmdirsearch的Python项目详细描述
Mines DirSearch网站允许搜索拥有 标题系统中列出的目录信息。这是一条方便的Python 与该网站的接口。
Author: | Jack Rosenthal |
---|---|
Requires: | Python 3.4 or greater, Beautiful Soup 4.4.0 or greater, Requests |
License: | MIT |
Contributing: | See ^{tt1}$ |
来自python的用法
使用search(query)通过用户名(部分)搜索用户,或 (部分)全名。search是生成唯一 Person对象。此对象的典型属性包括name, business_email、major、classification和department;但是, 仅保证了^ {Tt5} $属性存在。
每个Person对象也有一些属性:
^{tt12}$: | Based on the ^{tt6}$ (and potentially more information in the future), a “best guess” for the username of the user, otherwise ^{tt14}$. |
---|---|
^{tt15}$: | An automatic, brief description of the person, for example: ^{tt16}$. |
每个人的name也是一个特殊的Name类型,包含 first、last和nick属性您可以将名称转换为 使用strfname函数的字符串,或使用str(person.name)作为 “合理违约”:
>>> name = Name("Rosenthal, Jack (NickName)") >>> name.strfname("{first} {last}") 'Jack Rosenthal' >>> str(name) 'Jack (NickName) Rosenthal'
在strfname中还可以使用方便的属性:
^{tt25}$: | Short for “preferred first”. This will be set to ^{tt21}$ if there is a nick name, ^{tt19}$ otherwise. |
---|---|
^{tt28}$: | Short for “nick, wrapped in parens, if there is one”. This will be set to ^{tt29}$ if there’s a nick name, ^{tt30}$ otherwise. |
示例:
>>> name = Name("Rosenthal, Jack (NickName)") >>> name.strfname("{pfirst} {last}") 'NickName Rosenthal' >>> name.strfname("{first}{nickp} {last}") 'Jack (NickName) Rosenthal'
下面是一个示例:
import csmdirsearch for person in csmdirsearch.search("Jack Rosenthal"): print(person.name, person.desc)
如果您希望将搜索限制为,只需一个部分用户名(没有实名 使用search_by_partial生成器,而不是search。
最后,如果您希望将搜索限制为,只需部分全名(大多数 使用search_by_name生成器而不是search。这个 生成器还具有将搜索限制为特定分类或 部门。阅读源代码了解更多详细信息
从命令行使用
这很简单:
$ dirsearch "Jack Rosenthal" Jack Rosenthal Undergraduate Student Business Email: ...
如果要使用search_by_name或search_by_partial函数 限制输入的范围,使用--input=name或--input=partial 分别:
$ dirsearch --input=partial "jrosent" Jack Rosenthal ...
来自mutt的用法
添加到您的.muttrc:
set query_command = "dirsearch --format=mutt %s"
然后按Q使用搜索进行撰写,或在写入名称或 地址。