484 def _choose_lines_or_arcs(self, lines=False, arcs=False): |
484 def _choose_lines_or_arcs(self, lines=False, arcs=False): |
485 """Force the data file to choose between lines and arcs.""" |
485 """Force the data file to choose between lines and arcs.""" |
486 assert lines or arcs |
486 assert lines or arcs |
487 assert not (lines and arcs) |
487 assert not (lines and arcs) |
488 if lines and self._has_arcs: |
488 if lines and self._has_arcs: |
489 raise CoverageException("Can't add lines to existing arc data") |
489 raise CoverageException("Can't add line measurements to existing branch data") |
490 if arcs and self._has_lines: |
490 if arcs and self._has_lines: |
491 raise CoverageException("Can't add arcs to existing line data") |
491 raise CoverageException("Can't add branch measurements to existing line data") |
492 if not self._has_arcs and not self._has_lines: |
492 if not self._has_arcs and not self._has_lines: |
493 self._has_lines = lines |
493 self._has_lines = lines |
494 self._has_arcs = arcs |
494 self._has_arcs = arcs |
495 with self._connect() as con: |
495 with self._connect() as con: |
496 con.execute( |
496 con.execute( |
782 .. versionadded:: 5.0 |
782 .. versionadded:: 5.0 |
783 |
783 |
784 """ |
784 """ |
785 self._start_using() |
785 self._start_using() |
786 with self._connect() as con: |
786 with self._connect() as con: |
787 contexts = set(row[0] for row in con.execute("select distinct(context) from context")) |
787 contexts = {row[0] for row in con.execute("select distinct(context) from context")} |
788 return contexts |
788 return contexts |
789 |
789 |
790 def file_tracer(self, filename): |
790 def file_tracer(self, filename): |
791 """Get the plugin name of the file tracer for a file. |
791 """Get the plugin name of the file tracer for a file. |
792 |
792 |
855 self._start_using() |
855 self._start_using() |
856 if self.has_arcs(): |
856 if self.has_arcs(): |
857 arcs = self.arcs(filename) |
857 arcs = self.arcs(filename) |
858 if arcs is not None: |
858 if arcs is not None: |
859 all_lines = itertools.chain.from_iterable(arcs) |
859 all_lines = itertools.chain.from_iterable(arcs) |
860 return list(set(l for l in all_lines if l > 0)) |
860 return list({l for l in all_lines if l > 0}) |
861 |
861 |
862 with self._connect() as con: |
862 with self._connect() as con: |
863 file_id = self._file_id(filename) |
863 file_id = self._file_id(filename) |
864 if file_id is None: |
864 if file_id is None: |
865 return None |
865 return None |