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
Emmy Vouriot
my2to3
Commits
f65e0858
Commit
f65e0858
authored
Jul 10, 2020
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track the modified code in a more fine-grained fashion
parent
9ef4a74b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
my2to3/fixes/fix_division_trace.py
my2to3/fixes/fix_division_trace.py
+6
-1
my2to3/trace.py
my2to3/trace.py
+6
-12
No files found.
my2to3/fixes/fix_division_trace.py
View file @
f65e0858
...
@@ -12,6 +12,8 @@ from my2to3.util import parse_type
...
@@ -12,6 +12,8 @@ from my2to3.util import parse_type
trace
=
create_table
(
"division"
,
"filename"
,
"lineno"
,
"id"
,
"dividend_type"
,
"divisor_type"
)
trace
=
create_table
(
"division"
,
"filename"
,
"lineno"
,
"id"
,
"dividend_type"
,
"divisor_type"
)
trace_modified
=
create_table
(
"division_modified"
,
"filename"
,
"lineno"
,
"id"
)
@
register_tracing_function
@
register_tracing_function
def
division_traced
(
id
,
dividend
,
divisor
):
def
division_traced
(
id
,
dividend
,
divisor
):
...
@@ -72,10 +74,13 @@ class FixDivisionTrace(BaseFix):
...
@@ -72,10 +74,13 @@ class FixDivisionTrace(BaseFix):
comma
=
lib2to3
.
fixer_util
.
Comma
()
comma
=
lib2to3
.
fixer_util
.
Comma
()
comma
.
prefix
=
children
[
1
].
prefix
comma
.
prefix
=
children
[
1
].
prefix
id_
=
self
.
ids
[
lineno
]
trace_modified
(
self
.
filename
,
lineno
,
id_
)
new_node
=
lib2to3
.
fixer_util
.
Call
(
new_node
=
lib2to3
.
fixer_util
.
Call
(
lib2to3
.
fixer_util
.
Name
(
"division_traced"
),
lib2to3
.
fixer_util
.
Name
(
"division_traced"
),
args
=
(
args
=
(
lib2to3
.
fixer_util
.
Number
(
self
.
ids
[
lineno
]
),
lib2to3
.
fixer_util
.
Number
(
id_
),
lib2to3
.
fixer_util
.
Comma
(),
lib2to3
.
fixer_util
.
Comma
(),
dividend
,
dividend
,
comma
,
comma
,
...
...
my2to3/trace.py
View file @
f65e0858
...
@@ -43,23 +43,17 @@ def get_fixers():
...
@@ -43,23 +43,17 @@ def get_fixers():
f
for
f
in
get_fixers_from_package
(
"my2to3.fixes"
)
if
f
.
endswith
(
"_trace"
)
f
for
f
in
get_fixers_from_package
(
"my2to3.fixes"
)
if
f
.
endswith
(
"_trace"
)
]
]
trace_modified
=
create_table
(
"modified"
,
"fixer"
,
"filename"
)
def
apply_fixers
(
string
,
name
):
def
apply_fixers
(
string
,
name
):
# This function is inspired by refactoring_tool.refactor_file
# This function is inspired by refactoring_tool.refactor_file
encoding
=
tokenize
.
detect_encoding
(
lambda
:
string
)[
0
]
refactoring_tool
=
RefactoringTool
(
fixer_names
=
get_fixers
())
string
=
string
.
decode
(
encoding
)
+
u"
\
n
"
# '\n' to silence certain parse errors
for
fixer
in
get_fixers
():
refactoring_tool
=
RefactoringTool
(
fixer_names
=
[
fixer
])
tree
=
refactoring_tool
.
refactor_string
(
string
,
name
)
if
tree
.
was_changed
:
trace_modified
(
fixer
[
17
:
-
6
],
name
)
string
=
unicode
(
tree
)
s
=
string
+
"
\
n
"
# Silence certain parse errors
encoding
=
tokenize
.
detect_encoding
(
lambda
:
s
)[
0
]
s
=
s
.
decode
(
encoding
)
s
=
unicode
(
refactoring_tool
.
refactor_string
(
s
,
name
))
# The [:-1] is to take off the \n we added earlier
# The [:-1] is to take off the \n we added earlier
return
s
tring
[:
-
1
].
encode
(
encoding
)
return
s
[:
-
1
].
encode
(
encoding
)
init_py
=
'__init__'
+
os
.
extsep
+
'py'
init_py
=
'__init__'
+
os
.
extsep
+
'py'
...
...
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