(s, amount)
| 167 | |
| 168 | # Strip a given amount of excess padding from the given string |
| 169 | def _strip_padding(s, amount): |
| 170 | lpos = 0 |
| 171 | while amount and s[lpos] == ' ': |
| 172 | lpos += 1 |
| 173 | amount -= 1 |
| 174 | rpos = len(s) - 1 |
| 175 | while amount and s[rpos] == ' ': |
| 176 | rpos -= 1 |
| 177 | amount -= 1 |
| 178 | return s[lpos:rpos+1] |
| 179 | |
| 180 | _percent_re = re.compile(r'%(?:\((?P<key>.*?)\))?' |
| 181 | r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]') |