Find all header lines matching a given header name. Look through the list of headers and find all lines matching a given header name (and their continuation lines). A list of the lines is returned, without interpretation. If the header does not occur, an empty list
(self, name)
| 193 | # issues. |
| 194 | |
| 195 | def getallmatchingheaders(self, name): |
| 196 | """Find all header lines matching a given header name. |
| 197 | |
| 198 | Look through the list of headers and find all lines matching a given |
| 199 | header name (and their continuation lines). A list of the lines is |
| 200 | returned, without interpretation. If the header does not occur, an |
| 201 | empty list is returned. If the header occurs multiple times, all |
| 202 | occurrences are returned. Case is not important in the header name. |
| 203 | |
| 204 | """ |
| 205 | name = name.lower() + ':' |
| 206 | n = len(name) |
| 207 | lst = [] |
| 208 | hit = 0 |
| 209 | for line in self.keys(): |
| 210 | if line[:n].lower() == name: |
| 211 | hit = 1 |
| 212 | elif not line[:1].isspace(): |
| 213 | hit = 0 |
| 214 | if hit: |
| 215 | lst.append(line) |
| 216 | return lst |
| 217 | |
| 218 | def _read_headers(fp): |
| 219 | """Reads potential header lines into a list from a file pointer. |