Beispiel #1
0
    def csv_lines(self):
        # a module with a dependency on a fortran and c file, plus a mo commented dep

        data = [
            AnalysedFile(fpath='my_mod.f90',
                         file_hash=123,
                         module_defs={'my_mod'},
                         symbol_defs={'my_mod'},
                         symbol_deps={'dep1_mod', 'dep2'},
                         mo_commented_file_deps={'mo_dep.c'}),
            AnalysedFile(fpath='dep1_mod.f90',
                         file_hash=234,
                         module_defs={'dep1_mod'},
                         symbol_defs={'dep1_mod'}),
            AnalysedFile(fpath='dep2.c', file_hash=345, symbol_defs={'dep2'}),
        ]

        lines = [','.join(AnalysedFile.field_names())]  # header row
        for af in data:
            str_dict = af.to_str_dict()
            columns = [str_dict[field_name] for field_name in af.field_names()]
            row = ','.join(columns)
            lines.append(row)

        return lines
Beispiel #2
0
    def _new_analysis_file(self, unchanged: Iterable[AnalysedFile]):
        """
        Create the analysis file from scratch, containing any content from its previous version which is still valid.

        The returned context is a csv.DictWriter.
        """
        with TimerLogger("starting analysis progress file"):
            analysis_progress_file = open(
                self._config.project_workspace / "__analysis.csv", "wt")
            analysis_dict_writer = csv.DictWriter(
                analysis_progress_file, fieldnames=AnalysedFile.field_names())
            analysis_dict_writer.writeheader()

            # re-write the progress so far
            unchanged_rows = (af.to_str_dict() for af in unchanged)
            analysis_dict_writer.writerows(unchanged_rows)
            analysis_progress_file.flush()

        yield analysis_dict_writer

        analysis_progress_file.close()