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="")
| 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 | """ |
no test coverage detected