Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
A
astor
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
astor
Commits
d81b796c
Kaydet (Commit)
d81b796c
authored
May 26, 2015
tarafından
Patrick Maupin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Stop triple quoting strings embedded in function calls
üst
5d004635
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
code_gen.py
astor/code_gen.py
+3
-1
string_repr.py
astor/string_repr.py
+4
-1
No files found.
astor/code_gen.py
Dosyayı görüntüle @
d81b796c
...
...
@@ -479,10 +479,12 @@ class SourceGenerator(ExplicitNodeVisitor):
def
visit_Str
(
self
,
node
):
result
=
self
.
result
embedded
=
self
.
get__pp
(
node
)
>
Precedence
.
Expr
# Cheesy way to force a flush
self
.
write
(
'foo'
)
result
.
pop
()
result
.
append
(
self
.
pretty_string
(
node
.
s
,
result
))
result
.
append
(
self
.
pretty_string
(
node
.
s
,
embedded
,
result
))
def
visit_Bytes
(
self
,
node
):
self
.
write
(
repr
(
node
.
s
))
...
...
astor/string_repr.py
Dosyayı görüntüle @
d81b796c
...
...
@@ -76,7 +76,7 @@ def _prep_triple_quotes(s, mysplit=mysplit, replacements=replacements):
return
''
.
join
(
s
)
def
pretty_string
(
s
,
current_output
,
min_trip_str
=
20
,
max_line
=
100
):
def
pretty_string
(
s
,
embedded
,
current_output
,
min_trip_str
=
20
,
max_line
=
100
):
"""There are a lot of reasons why we might not want to or
be able to return a triple-quoted string. We can always
punt back to the default normal string.
...
...
@@ -91,6 +91,9 @@ def pretty_string(s, current_output, min_trip_str=20, max_line=100):
len_s
=
len
(
default
)
current_line
=
_get_line
(
current_output
)
if
current_line
.
strip
():
if
embedded
and
'
\n
'
not
in
s
:
return
default
if
len_s
<
min_trip_str
:
return
default
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment