Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
my2to3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
my2to3
Commits
b3bb4cea
Commit
b3bb4cea
authored
May 28, 2020
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New scripts folder to check the effectiveness of fixers
parent
a2ab7763
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
check/README.md
check/README.md
+2
-0
check/trace_division.py
check/trace_division.py
+53
-0
No files found.
check/README.md
0 → 100644
View file @
b3bb4cea
These scripts are used to manually check that the fixers have not forgotten any
special cases, i.e. the implementation of their
`match`
method is good enough.
check/trace_division.py
0 → 100644
View file @
b3bb4cea
import
ast
,
os
,
sys
class
Analyzer
(
ast
.
NodeVisitor
):
def
__init__
(
self
,
file_path
):
with
open
(
file_path
)
as
f
:
source_code
=
f
.
read
()
self
.
file_path
=
f
.
name
self
.
source_code
=
source_code
.
split
(
'
\
n
'
)
self
.
tree
=
ast
.
parse
(
source_code
)
self
.
warnings
=
0
def
__call__
(
self
):
self
.
visit
(
self
.
tree
)
return
self
.
warnings
def
visit_BinOp
(
self
,
node
):
if
isinstance
(
node
.
op
,
ast
.
Div
):
self
.
warnings
+=
1
print
(
"%s:%s |%s"
%
(
self
.
file_path
,
node
.
lineno
,
self
.
source_code
[
node
.
lineno
-
1
]))
def
analyze_file
(
file_path
):
try
:
analyzer
=
Analyzer
(
file_path
)
except
Exception
as
e
:
print
(
"Error: %s => %s"
%
(
file_path
,
e
))
return
0
,
1
return
analyzer
(),
0
def
analyze_dir
(
dir_path
):
total_warnings
=
total_errors
=
0
# Inspired by lib2to3
py_ext
=
os
.
extsep
+
"py"
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
dir_path
):
for
name
in
filenames
:
if
not
name
.
startswith
(
"."
)
and
os
.
path
.
splitext
(
name
)[
1
]
==
py_ext
:
warnings
,
errors
=
analyze_file
(
os
.
path
.
join
(
dirpath
,
name
))
total_warnings
+=
warnings
total_errors
+=
errors
return
total_warnings
,
total_errors
def
main
():
for
dir_or_file
in
sys
.
argv
[
1
:]:
f
=
analyze_dir
if
os
.
path
.
isdir
(
dir_or_file
)
else
analyze_file
print
(
"%s warning(s), %s error(s)"
%
f
(
dir_or_file
))
if
__name__
==
'__main__'
:
main
()
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