MCPcopy Index your code
hub / github.com/RustPython/RustPython / TokenList

Class TokenList

Lib/email/_header_value_parser.py:125–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123#
124
125class TokenList(list):
126
127 token_type = None
128 syntactic_break = True
129 ew_combine_allowed = True
130
131 def __init__(self, *args, **kw):
132 super().__init__(*args, **kw)
133 self.defects = []
134
135 def __str__(self):
136 return ''.join(str(x) for x in self)
137
138 def __repr__(self):
139 return '{}({})'.format(self.__class__.__name__,
140 super().__repr__())
141
142 @property
143 def value(self):
144 return ''.join(x.value for x in self if x.value)
145
146 @property
147 def all_defects(self):
148 return sum((x.all_defects for x in self), self.defects)
149
150 def startswith_fws(self):
151 return self[0].startswith_fws()
152
153 @property
154 def as_ew_allowed(self):
155 """True if all top level tokens of this part may be RFC2047 encoded."""
156 return all(part.as_ew_allowed for part in self)
157
158 @property
159 def comments(self):
160 comments = []
161 for token in self:
162 comments.extend(token.comments)
163 return comments
164
165 def fold(self, *, policy):
166 return _refold_parse_tree(self, policy=policy)
167
168 def pprint(self, indent=''):
169 print(self.ppstr(indent=indent))
170
171 def ppstr(self, indent=''):
172 return '\n'.join(self._pp(indent=indent))
173
174 def _pp(self, indent=''):
175 yield '{}{}/{}('.format(
176 indent,
177 self.__class__.__name__,
178 self.token_type)
179 for token in self:
180 if not hasattr(token, '_pp'):
181 yield (indent + ' !! invalid element in token '
182 'list: {!r}'.format(token))

Callers 3

display_nameMethod · 0.85
local_partMethod · 0.85
get_local_partFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected