Kaydet (Commit) f87ae3b5 authored tarafından Radomír Bosák's avatar Radomír Bosák Kaydeden (comit) Berker Peksag

Create a separate function for triplequote string representation

üst 524d525e
......@@ -22,7 +22,7 @@ import sys
from .op_util import get_op_symbol, get_op_precedence, Precedence
from .node_util import ExplicitNodeVisitor
from .string_repr import pretty_string, _prep_triple_quotes
from .string_repr import pretty_string, string_triplequote_repr
from .source_repr import pretty_source
......@@ -249,7 +249,7 @@ class SourceGenerator(ExplicitNodeVisitor):
self.newline()
self.indentation += indent
self.write('"""%s"""' % _prep_triple_quotes(value))
self.write(string_triplequote_repr(value))
self.indentation -= indent
def visit_arguments(self, node):
......
......@@ -55,6 +55,12 @@ def _prep_triple_quotes(s, mysplit=mysplit, replacements=replacements):
return ''.join(s)
def string_triplequote_repr(s):
"""Return string's python representation in triple quotes.
"""
return '"""%s"""' % _prep_triple_quotes(s)
def pretty_string(s, embedded, current_line, uni_lit=False,
min_trip_str=20, max_line=100):
"""There are a lot of reasons why we might not want to or
......@@ -91,7 +97,7 @@ def pretty_string(s, embedded, current_line, uni_lit=False,
if total_len < max_line and not _properly_indented(s, line_indent):
return default
fancy = '"""%s"""' % _prep_triple_quotes(s)
fancy = string_triplequote_repr(s)
# Sometimes this doesn't work. One reason is that
# the AST has no understanding of whether \r\n was
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment