Commit c671076a authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

New naming convention for the database insert functions

parent b07744cc
......@@ -11,13 +11,13 @@ from my2to3.util import parse_type
# id is used to differentiate the divisions of the same line.
trace = create_table("division", "filename", "lineno", "id", "dividend_type", "divisor_type")
trace_modified = create_table("division_modified", "filename", "lineno", "id")
insert_trace = create_table("division_trace", "filename", "lineno", "id", "dividend_type", "divisor_type")
insert_modified = create_table("division_modified", "filename", "lineno", "id")
@register_tracing_function
def division_traced(filename, lineno, id_, dividend, divisor):
trace(
insert_trace(
filename,
lineno,
id_,
......@@ -70,7 +70,7 @@ class FixDivisionTrace(BaseFix):
comma.prefix = children[1].prefix
id_ = self.ids[lineno]
trace_modified(self.filename, lineno, id_)
insert_modified(self.filename, lineno, id_)
new_node = lib2to3.fixer_util.Call(
lib2to3.fixer_util.Name("division_traced"),
......
......@@ -4,7 +4,7 @@ from lib2to3.pygram import python_symbols as syms
from my2to3.trace import create_table
trace = create_table("nested_except", "filename", "lineno_parent", "lineno_child")
insert_trace = create_table("nested_except_trace", "filename", "lineno_parent", "lineno_child")
class FixNestedExceptTrace(BaseFix):
......@@ -48,6 +48,6 @@ class FixNestedExceptTrace(BaseFix):
for child in self.list_except_clause_children(body):
try:
if except_clause.children[3] == child.children[3]:
trace(self.filename, except_clause.get_lineno(), child.get_lineno())
insert_trace(self.filename, except_clause.get_lineno(), child.get_lineno())
except Exception:
pass
......@@ -12,16 +12,16 @@ class FixerTestCase(lib2to3FixerTestCase):
self.traces = []
# Wrap fixer_module.trace, to populate self.traces
self.old_trace = fixer_module.trace
self.old_insert_trace = fixer_module.insert_trace
def decorate(func):
def call(*args):
self.traces.append(args)
return func(*args)
return call
fixer_module.trace = decorate(fixer_module.trace)
fixer_module.insert_trace = decorate(fixer_module.insert_trace)
def tearDown(self, *args, **kw):
super(FixerTestCase, self).tearDown(*args, **kw)
if self.fixer.endswith('_trace'):
self.fixer_module.trace = self.old_trace
self.fixer_module.insert_trace = self.old_insert_trace
......@@ -23,7 +23,7 @@ def create_table(table, *columns):
conn.commit()
conn.close()
def trace(*values):
def insert_unique(*values):
conn = sqlite3.connect(database)
c = conn.cursor()
try:
......@@ -35,7 +35,7 @@ def create_table(table, *columns):
else:
conn.commit()
conn.close()
return trace
return insert_unique
def get_fixers():
......
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