MCPcopy Index your code
hub / github.com/python/cpython / Group

Class Group

Lib/email/headerregistry.py:102–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102class Group:
103
104 def __init__(self, display_name=None, addresses=None):
105 """Create an object representing an address group.
106
107 An address group consists of a display_name followed by colon and a
108 list of addresses (see Address) terminated by a semi-colon. The Group
109 is created by specifying a display_name and a possibly empty list of
110 Address objects. A Group can also be used to represent a single
111 address that is not in a group, which is convenient when manipulating
112 lists that are a combination of Groups and individual Addresses. In
113 this case the display_name should be set to None. In particular, the
114 string representation of a Group whose display_name is None is the same
115 as the Address object, if there is one and only one Address object in
116 the addresses list.
117
118 """
119 self._display_name = display_name
120 self._addresses = tuple(addresses) if addresses else tuple()
121
122 @property
123 def display_name(self):
124 return self._display_name
125
126 @property
127 def addresses(self):
128 return self._addresses
129
130 def __repr__(self):
131 return "{}(display_name={!r}, addresses={!r}".format(
132 self.__class__.__name__,
133 self.display_name, self.addresses)
134
135 def __str__(self):
136 if self.display_name is None and len(self.addresses)==1:
137 return str(self.addresses[0])
138 disp = self.display_name
139 if disp is not None and not parser.SPECIALS.isdisjoint(disp):
140 disp = parser.quote_string(disp)
141 adrstr = ", ".join(str(x) for x in self.addresses)
142 adrstr = ' ' + adrstr if adrstr else adrstr
143 return "{}:{};".format(disp, adrstr)
144
145 def __eq__(self, other):
146 if not isinstance(other, Group):
147 return NotImplemented
148 return (self.display_name == other.display_name and
149 self.addresses == other.addresses)
150
151
152# Header Classes #

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…