python 3框架,用于以yaml格式构建、管理和组织电子邮件地址。
contactList的Python项目详细描述
python 3实用程序,用于以yaml格式构造、管理和组织电子邮件地址。
2 Getting Started
yaml文件的结构非常简单。将电子邮件地址组织成任意命名的组,然后组织 这些组被任意命名为“集群”。
groups:g1:-'u1@some.domain'g2:-'u3@some.other.domain'g3:-'u4@this.domain'-'u2@some.domain'clusters:c1:['g1']c2:['g1','g2']c3:['g2','g3']
没有要求将电子邮件地址仅限于一个组。
3 ^{tt1}$ utility
一旦安装了wheel包,就可以使用命令行实用程序contact-list。此实用程序可用于 从命令行管理yaml文件中的联系人列表数据。
> contact-list --help usage: contact-list [-h][--file CONTACTSFILE]{cluster,email,group} ... positional arguments: {cluster,email,group} optional arguments: -h, --help show this help message and exit --file CONTACTSFILE, -f CONTACTSFILE Contacts file to manage (default contacts.yml)
子命令允许修改文件中的各个实体,cluster,email,group。
4 Using the framework
使用contactList框架,您的应用程序可以使用集群来构建必要电子邮件的列表。由 默认情况下,from_yamlFileclassmethod尝试从当前目录中的contacts.yml加载yaml,否则 用户指定要使用的文件名。
fromcontactListimportContactsmyContacts=Contacts.from_yamlFile()# A list of the groups loaded from YAMLassertisinstance(myContacts.groups,list)# A list of the clusters loaded from YAMLassertisinstance(myContacts.clusters,list)# Check that the groups and clusters are correctly specified.myContacts.validate()# Generate a Python set of email addresses for the chosen cluster.emailList=myContacts.emails('c2')assertisinstance(emailList,set)