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


Python GnuPG.list_keys方法代码示例

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


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

示例1: get_vcards

# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import list_keys [as 别名]
    def get_vcards(self):
        if not self.config.active:
            return []

        gnupg = GnuPG()
        keys = gnupg.list_keys()
        results = []
        vcards = {}
        for key_id, key in keys.iteritems():
            vcls = [VCardLine(name='KEY', value=self.VCL_KEY_FMT % key_id)]
            card = None
            emails = []
            for uid in key.get('uids', []):
                if uid.get('email'):
                    vcls.append(VCardLine(name='email', value=uid['email']))
                    card = card or vcards.get(uid['email'])
                    emails.append(uid['email'])
                if uid.get('name'):
                    name = uid['name']
                    vcls.append(VCardLine(name='fn', value=name))
            if card and emails:
                card.add(*vcls)
            elif emails:
                # This is us taking care to only create one card for each
                # set of e-mail addresses.
                card = MailpileVCard(*vcls)
                for email in emails:
                    vcards[email] = card
                results.append(card)

        return results
开发者ID:Bangsalina,项目名称:Mailpile,代码行数:33,代码来源:vcard_gnupg.py

示例2: get_vcards

# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import list_keys [as 别名]
    def get_vcards(self):
        if not self.config.active:
            return []

        gnupg = GnuPG()
        keys = gnupg.list_keys()
        results = []
        vcards = {}
        for key in keys.values():
            vcls = [VCardLine(name="KEY",
                              value=self.VCL_KEY_FMT % key)]
            card = None
            emails = []
            for uid in key["uids"]:
                if "email" in uid and uid["email"]:
                    vcls.append(VCardLine(name="email", value=uid["email"]))
                    card = card or vcards.get(uid['email'])
                    emails.append(uid["email"])
                if "name" in uid and uid["name"]:
                    name = uid["name"]
                    vcls.append(VCardLine(name="fn", value=name))
            if card and emails:
                card.add(*vcls)
            elif emails:
                # This is us taking care to only create one card for each
                # set of e-mail addresses.
                card = SimpleVCard(*vcls)
                for email in emails:
                    vcards[email] = card
                results.append(card)

        return results
开发者ID:Akhilan,项目名称:Mailpile,代码行数:34,代码来源:vcard_gnupg.py

示例3: lookup_crypto_keys

# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import list_keys [as 别名]
def lookup_crypto_keys(session, address):
    x = {}
    scores = []
    for handler in KEY_LOOKUP_HANDLERS:
        h = handler(session)
        r, s = h.lookup(address)
        for key, value in r.iteritems():
            if key in x:
                x[key].update(value)
            else:
                x[key] = value
                x[key]["origin"] = []
            x[key]["origin"].append(h.NAME)
        scores.append(s)

    for scoreset in scores:
        for key, value in scoreset.iteritems():
            if key not in x:
                continue
            if "score" not in x[key]:
                x[key]["score"] = 0
            x[key]["score"] += value

    g = GnuPG()
    known_keys_list = g.list_keys()
    for key in x.keys():
        x[key]["fingerprint"] = key
        x[key]["score"] += crypto_keys_scorer(known_keys_list, key)

    x = [i for i in x.values()]
    x.sort(key=lambda k: -k["score"])
    return x
开发者ID:lieblingswelt,项目名称:Mailpile,代码行数:34,代码来源:__init__.py

示例4: lookup_crypto_keys

# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import list_keys [as 别名]
def lookup_crypto_keys(session, address, event=None, allowremote=True):
    def _calc_scores(x, scores):
        for key in x.keys():
            x[key]["score"] = 0

        for scoreset in scores:
            for key, value in scoreset.iteritems():
                if key not in x:
                    continue
                if "score" not in x[key]:
                    x[key]["score"] = 0
                x[key]["score"] += value
        return x

    x = {}
    scores = []
    lastresult = {}

    for handler in KEY_LOOKUP_HANDLERS:
        h = handler(session)
        if not allowremote and not h.LOCAL:
            continue

        if event:
            m = _calc_scores(x, scores)
            m = [i for i in m.values()]
            m.sort(key=lambda k: -k["score"])
            event.private_data = {"result": m, "runningsearch": h.NAME}
            session.config.event_log.log_event(event)

        r, s = h.lookup(address)
        for key, value in r.iteritems():
            if key in x:
                x[key].update(value)
            else:
                x[key] = value
                x[key]["origin"] = []
            x[key]["origin"].append(h.NAME)
        scores.append(s)

    x = _calc_scores(x, scores)

    g = GnuPG()
    known_keys_list = g.list_keys()
    for key in x.keys():
        x[key]["fingerprint"] = key
        x[key]["score"] += crypto_keys_scorer(known_keys_list, key)

    x = [i for i in x.values()]
    x.sort(key=lambda k: -k["score"])
    if event:
        event.private_data = {"result": x, "runningsearch": None}
        session.config.event_log.log_event(event)
    return x
开发者ID:Bangsalina,项目名称:Mailpile,代码行数:56,代码来源:__init__.py

示例5: scorer_trust

# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import list_keys [as 别名]
def scorer_trust(key):
    global known_keys_list
    score = 0
    if known_keys_list == None:
        g = GnuPG()
        known_keys_list = g.list_keys()

    if key in known_keys_list:
        if "e" in known_keys_list[key]["validity"]:
            score += -100
        elif "r" in known_keys_list[key]["validity"]:
            score += -10000
        elif "d" in known_keys_list[key]["validity"]:
            score += -10000
        elif ("f" in known_keys_list[key]["validity"] 
           or "u" in known_keys_list[key]["validity"]):
            score += 50
        else:
            score += 10

    return score
开发者ID:bart-j,项目名称:Mailpile,代码行数:23,代码来源:__init__.py


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