当前位置: 首页>>代码示例>>Python>>正文


Python Target.email_count方法代码示例

本文整理汇总了Python中crits.targets.target.Target.email_count方法的典型用法代码示例。如果您正苦于以下问题:Python Target.email_count方法的具体用法?Python Target.email_count怎么用?Python Target.email_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在crits.targets.target.Target的用法示例。


在下文中一共展示了Target.email_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: target_user_stats

# 需要导入模块: from crits.targets.target import Target [as 别名]
# 或者: from crits.targets.target.Target import email_count [as 别名]
def target_user_stats():
    """
    Generate targets from email To/CC fields, then generate divisions from
    targets list.
    No cleanup or logic is being done on the To/CC fields. If they are not
    valid email addresses ([email protected]), they do not get added as a target.
    """

    mapcode = """
        function () {
            try {
                this.to.forEach(function(z) {
                    emit(z, {count: 1});
                });
            } catch(err) {}
        }
    """
    reducecode = """
        function(k,v) {
            var count = 0;
            v.forEach(function(v) {
                count += v["count"];
            });
            return {count: count};
        }
    """
    m = Code(mapcode)
    r = Code(reducecode)
    results = Email.objects(to__exists=True).map_reduce(m, r, 'inline')
    for result in results:
        try:
            targ = Target.objects(email_address__iexact=result.key).first()
            if not targ:
                targ = Target()
                targ.email_address = result.key
            targ.email_count = result.value['count']
            targ.save()
        except:
            pass
    mapcode = """
        function() {
            if ("division" in this) {
                emit(this.division, {count: this.email_count})
            }
        }
    """
    m = Code(mapcode)
    try:
        results = Target.objects().map_reduce(m, r, 'inline')
        for result in results:
            div = Division.objects(division__iexact=result.key).first()
            if not div:
                div = Division()
                div.division = result.key
            div.email_count = result.value['count']
            div.save()
    except:
        raise
开发者ID:AInquel,项目名称:crits,代码行数:60,代码来源:handlers.py


注:本文中的crits.targets.target.Target.email_count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。