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