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

Class PGPUID

pgpy/pgp.py:595–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593
594
595class PGPUID(ParentRef):
596 @property
597 def __sig__(self):
598 return list(self._signatures)
599
600 def _splitstring(self):
601 '''returns name, comment email from User ID string'''
602 if not isinstance(self._uid, UserID):
603 return "", "", ""
604 if self._uid.uid == "":
605 return "", "", ""
606 rfc2822 = re.match(r"""^
607 # name should always match something
608 (?P<name>.+?)
609 # comment *optionally* matches text in parens following name
610 # this should never come after email and must be followed immediately by
611 # either the email field, or the end of the packet.
612 (\ \((?P<comment>.+?)\)(?=(\ <|$)))?
613 # email *optionally* matches text in angle brackets following name or comment
614 # this should never come before a comment, if comment exists,
615 # but can immediately follow name if comment does not exist
616 (\ <(?P<email>.+)>)?
617 $
618 """, self._uid.uid, flags=re.VERBOSE).groupdict()
619
620 return (rfc2822['name'], rfc2822['comment'] or "", rfc2822['email'] or "")
621
622 @property
623 def name(self):
624 """If this is a User ID, the stored name. If this is not a User ID, this will be an empty string."""
625 return self._splitstring()[0]
626
627 @property
628 def comment(self):
629 """
630 If this is a User ID, this will be the stored comment. If this is not a User ID, or there is no stored comment,
631 this will be an empty string.,
632 """
633 return self._splitstring()[1]
634
635 @property
636 def email(self):
637 """
638 If this is a User ID, this will be the stored email address. If this is not a User ID, or there is no stored
639 email address, this will be an empty string.
640 """
641 return self._splitstring()[2]
642
643 @property
644 def userid(self):
645 """
646 If this is a User ID, this will be the full UTF-8 string. If this is not a User ID, this will be ``None``.
647 """
648 return self._uid.uid if isinstance(self._uid, UserID) else None
649
650 @property
651 def image(self):
652 """

Callers 3

newMethod · 0.85
__copy__Method · 0.85
parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…