MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / new

Method new

pgpy/pgp.py:757–787  ·  view source on GitHub ↗

Create a new User ID or photo. :param pn: User ID name, or photo. If this is a ``bytearray``, it will be loaded as a photo. Otherwise, it will be used as the name field for a User ID. :type pn: ``bytearray``, ``str``, ``unicode`` :param comment: T

(cls, pn, comment="", email="")

Source from the content-addressed store, hash-verified

755
756 @classmethod
757 def new(cls, pn, comment="", email=""):
758 """
759 Create a new User ID or photo.
760
761 :param pn: User ID name, or photo. If this is a ``bytearray``, it will be loaded as a photo.
762 Otherwise, it will be used as the name field for a User ID.
763 :type pn: ``bytearray``, ``str``, ``unicode``
764 :param comment: The comment field for a User ID. Ignored if this is a photo.
765 :type comment: ``str``, ``unicode``
766 :param email: The email address field for a User ID. Ignored if this is a photo.
767 :type email: ``str``, ``unicode``
768 :returns: :py:obj:`PGPUID`
769 """
770 uid = PGPUID()
771 if isinstance(pn, bytearray):
772 uid._uid = UserAttribute()
773 uid._uid.image.image = pn
774 uid._uid.image.iencoding = ImageEncoding.encodingof(pn)
775 uid._uid.update_hlen()
776
777 else:
778 uid._uid = UserID()
779 uidstr = pn
780 if comment:
781 uidstr += ' (' + comment + ')'
782 if email:
783 uidstr += ' <' + email + '>'
784 uid._uid.uid = uidstr
785 uid._uid.update_hlen()
786
787 return uid
788
789 def __init__(self):
790 """

Callers 8

hasherMethod · 0.45
newMethod · 0.45
signMethod · 0.45
certifyMethod · 0.45
revokeMethod · 0.45
revokerMethod · 0.45
bindMethod · 0.45

Calls 5

PGPUIDClass · 0.85
UserIDClass · 0.85
encodingofMethod · 0.80
UserAttributeClass · 0.50
update_hlenMethod · 0.45

Tested by

no test coverage detected