Decide whether a particular byte ordinal needs to be quoted. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521.
(c, quotetabs, header)
| 17 | |
| 18 | |
| 19 | def needsquoting(c, quotetabs, header): |
| 20 | """Decide whether a particular byte ordinal needs to be quoted. |
| 21 | |
| 22 | The 'quotetabs' flag indicates whether embedded tabs and spaces should be |
| 23 | quoted. Note that line-ending tabs and spaces are always encoded, as per |
| 24 | RFC 1521. |
| 25 | """ |
| 26 | assert isinstance(c, bytes) |
| 27 | if c in b' \t': |
| 28 | return quotetabs |
| 29 | # if header, we have to escape _ because _ is used to escape space |
| 30 | if c == b'_': |
| 31 | return header |
| 32 | return c == ESCAPE or not (b' ' <= c <= b'~') |
| 33 | |
| 34 | def quote(c): |
| 35 | """Quote a single character.""" |
no outgoing calls
no test coverage detected
searching dependent graphs…