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
a957d588
Kaydet (Commit)
a957d588
authored
Nis 24, 2017
tarafından
Patrick Maupin
Kaydeden (comit)
GitHub
Nis 24, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Generate PEP8-compatible blank lines in output (#73)
üst
aebce9b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
code_gen.py
astor/code_gen.py
+5
-1
test_code_gen.py
tests/test_code_gen.py
+2
-0
No files found.
astor/code_gen.py
Dosyayı görüntüle @
a957d588
...
@@ -310,13 +310,15 @@ class SourceGenerator(ExplicitNodeVisitor):
...
@@ -310,13 +310,15 @@ class SourceGenerator(ExplicitNodeVisitor):
def
visit_FunctionDef
(
self
,
node
,
async
=
False
):
def
visit_FunctionDef
(
self
,
node
,
async
=
False
):
prefix
=
'async '
if
async
else
''
prefix
=
'async '
if
async
else
''
self
.
decorators
(
node
,
1
)
self
.
decorators
(
node
,
1
if
self
.
indentation
else
2
)
self
.
statement
(
node
,
'
%
sdef
%
s'
%
(
prefix
,
node
.
name
),
'('
)
self
.
statement
(
node
,
'
%
sdef
%
s'
%
(
prefix
,
node
.
name
),
'('
)
self
.
visit_arguments
(
node
.
args
)
self
.
visit_arguments
(
node
.
args
)
self
.
write
(
')'
)
self
.
write
(
')'
)
self
.
conditional_write
(
' ->'
,
self
.
get_returns
(
node
))
self
.
conditional_write
(
' ->'
,
self
.
get_returns
(
node
))
self
.
write
(
':'
)
self
.
write
(
':'
)
self
.
body
(
node
.
body
)
self
.
body
(
node
.
body
)
if
not
self
.
indentation
:
self
.
newline
(
extra
=
2
)
# introduced in Python 3.5
# introduced in Python 3.5
def
visit_AsyncFunctionDef
(
self
,
node
):
def
visit_AsyncFunctionDef
(
self
,
node
):
...
@@ -344,6 +346,8 @@ class SourceGenerator(ExplicitNodeVisitor):
...
@@ -344,6 +346,8 @@ class SourceGenerator(ExplicitNodeVisitor):
self
.
conditional_write
(
paren_or_comma
,
'**'
,
self
.
get_kwargs
(
node
))
self
.
conditional_write
(
paren_or_comma
,
'**'
,
self
.
get_kwargs
(
node
))
self
.
write
(
have_args
and
'):'
or
':'
)
self
.
write
(
have_args
and
'):'
or
':'
)
self
.
body
(
node
.
body
)
self
.
body
(
node
.
body
)
if
not
self
.
indentation
:
self
.
newline
(
extra
=
2
)
def
visit_If
(
self
,
node
):
def
visit_If
(
self
,
node
):
set_precedence
(
node
,
node
.
test
)
set_precedence
(
node
,
node
.
test
)
...
...
tests/test_code_gen.py
Dosyayı görüntüle @
a957d588
...
@@ -129,6 +129,7 @@ class CodegenTestCase(unittest.TestCase):
...
@@ -129,6 +129,7 @@ class CodegenTestCase(unittest.TestCase):
source
=
"""
source
=
"""
j = [1, 2, 3]
j = [1, 2, 3]
def test(a1, a2, b1=j, b2='123', b3={}, b4=[]):
def test(a1, a2, b1=j, b2='123', b3={}, b4=[]):
pass"""
pass"""
self
.
assertAstSourceEqual
(
source
)
self
.
assertAstSourceEqual
(
source
)
...
@@ -137,6 +138,7 @@ class CodegenTestCase(unittest.TestCase):
...
@@ -137,6 +138,7 @@ class CodegenTestCase(unittest.TestCase):
source
=
canonical
(
"""
source
=
canonical
(
"""
j = [1, 2, 3]
j = [1, 2, 3]
def test(a1, a2, b1=j, b2='123', b3={}, b4=[]):
def test(a1, a2, b1=j, b2='123', b3={}, b4=[]):
pass"""
)
pass"""
)
root_node
=
ast
.
parse
(
source
)
root_node
=
ast
.
parse
(
source
)
...
...
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