@@ -255,8 +255,10 @@ def add_lines(self, line_data):
255255 ))
256256 self ._start_using ()
257257 self ._choose_lines_or_arcs (lines = True )
258- self ._set_context_id ()
258+ if not line_data :
259+ return
259260 with self ._connect () as con :
261+ self ._set_context_id ()
260262 for filename , linenos in iitems (line_data ):
261263 file_id = self ._file_id (filename , add = True )
262264 data = [(file_id , self ._current_context_id , lineno ) for lineno in linenos ]
@@ -279,8 +281,10 @@ def add_arcs(self, arc_data):
279281 ))
280282 self ._start_using ()
281283 self ._choose_lines_or_arcs (arcs = True )
282- self ._set_context_id ()
284+ if not arc_data :
285+ return
283286 with self ._connect () as con :
287+ self ._set_context_id ()
284288 for filename , arcs in iitems (arc_data ):
285289 file_id = self ._file_id (filename , add = True )
286290 data = [(file_id , self ._current_context_id , fromno , tono ) for fromno , tono in arcs ]
@@ -307,6 +311,10 @@ def add_file_tracers(self, file_tracers):
307311 `file_tracers` is { filename: plugin_name, ... }
308312
309313 """
314+ if self ._debug .should ('dataop' ):
315+ self ._debug .write ("Adding file tracers: %d files" % (len (file_tracers ),))
316+ if not file_tracers :
317+ return
310318 self ._start_using ()
311319 with self ._connect () as con :
312320 for filename , plugin_name in iitems (file_tracers ):
@@ -667,6 +675,12 @@ def run_infos(self):
667675
668676
669677class SqliteDb (SimpleReprMixin ):
678+ """A simple abstraction over a SQLite database.
679+
680+ Use as a context manager to get an object you can call
681+ execute or executemany on.
682+
683+ """
670684 def __init__ (self , filename , debug ):
671685 self .debug = debug if debug .should ('sql' ) else None
672686 self .filename = filename
@@ -679,7 +693,7 @@ def connect(self):
679693 filename = os .path .relpath (self .filename )
680694 # It can happen that Python switches threads while the tracer writes
681695 # data. The second thread will also try to write to the data,
682- # effectively causing a nested context. However, given the indempotent
696+ # effectively causing a nested context. However, given the idempotent
683697 # nature of the tracer operations, sharing a conenction among threads
684698 # is not a problem.
685699 if self .debug :
0 commit comments