def commitStrConst(self): """Add the code for outputting the pending strConst without chopping off any whitespace from it. """ if not self._pendingStrConstChunks: return strConst = ''.join(self._pendingStrConstChunks) self._pendingStrConstChunks = [] if not strConst: return reprstr = repr(strConst) if self.setting('future_unicode_literals'): out = [] else: out = ['u'] # If our repr starts with u, trim it off if reprstr.startswith('u'): # pragma: no cover (py2 only) reprstr = reprstr[1:] body = escapedNewlineRE.sub('\\1\n', reprstr[1:-1]) if reprstr[0] == "'": out.extend(["'''", body, "'''"]) else: out.extend(['"""', body, '"""']) self.addWriteChunk(''.join(out))
def commitStrConst(self): """Add the code for outputting the pending strConst without chopping off any whitespace from it. """ if not self._pendingStrConstChunks: return strConst = ''.join(self._pendingStrConstChunks) self._pendingStrConstChunks = [] if not strConst: return reprstr = repr(strConst) # If our repr starts with u, trim it off if reprstr.startswith('u'): # pragma: no cover (py2 only) reprstr = reprstr[1:] body = escapedNewlineRE.sub('\\1\n', reprstr[1:-1]) if reprstr[0] == "'": out = ("'''", body, "'''") else: out = ('"""', body, '"""') self.addWriteChunk(''.join(out))
def commitStrConst(self): """Add the code for outputting the pending strConst without chopping off any whitespace from it. """ if not self._pendingStrConstChunks: return strConst = self.getStrConst() self.clearStrConst() if not strConst: return reprstr = repr(strConst).lstrip('u') body = escapedNewlineRE.sub('\\1\n', reprstr[1:-1]) if reprstr[0] == "'": out = ("'''", body, "'''") else: out = ('"""', body, '"""') self.addWriteChunk(''.join(out))