コード例 #1
0
        def operation(con):
            primary_sources = set(self.build_state.to_source_filename(x)
                                  for x in self.sources)

            seen = set()
            rows = []
            for source in chain(self.sources, dependencies or ()):
                source = self.build_state.to_source_filename(source)
                if source in seen:
                    continue
                info = self.build_state.get_file_info(source)
                rows.append(artifacts_row(
                    artifact=self.artifact_name,
                    source=source,
                    source_mtime=info.mtime,
                    source_size=info.size,
                    source_checksum=info.checksum,
                    is_dir=info.is_dir,
                    is_primary_source=source in primary_sources))

                seen.add(source)

            for v_source in virtual_dependencies or ():
                checksum = v_source.get_checksum(self.build_state.path_cache)
                mtime = v_source.get_mtime(self.build_state.path_cache)
                rows.append(artifacts_row(
                    artifact=self.artifact_name,
                    source=v_source.path,
                    source_mtime=mtime,
                    source_size=None,
                    source_checksum=checksum,
                    is_dir=False,
                    is_primary_source=False))

            reporter.report_dependencies(rows)

            cur = con.cursor()
            if not for_failure:
                cur.execute('delete from artifacts where artifact = ?',
                            [self.artifact_name])
            if rows:
                cur.executemany('''
                    insert or replace into artifacts (
                        artifact, source, source_mtime, source_size,
                        source_checksum, is_dir, is_primary_source)
                    values (?, ?, ?, ?, ?, ?, ?)
                ''', rows)

            if self.config_hash is None:
                cur.execute('''
                    delete from artifact_config_hashes
                     where artifact = ?
                ''', [self.artifact_name])
            else:
                cur.execute('''
                    insert or replace into artifact_config_hashes
                           (artifact, config_hash) values (?, ?)
                ''', [self.artifact_name, self.config_hash])

            cur.close()
コード例 #2
0
ファイル: builder.py プロジェクト: BogusCurry/lektor
        def operation(con):
            primary_sources = set(self.build_state.to_source_filename(x)
                                  for x in self.sources)

            seen = set()
            rows = []
            for source in chain(self.sources, dependencies or ()):
                source = self.build_state.to_source_filename(source)
                if source in seen:
                    continue
                info = self.build_state.get_file_info(source)
                rows.append(artifacts_row(
                    artifact=self.artifact_name,
                    source=source,
                    source_mtime=info.mtime,
                    source_size=info.size,
                    source_checksum=info.checksum,
                    is_dir=info.is_dir,
                    is_primary_source=source in primary_sources))

                seen.add(source)

            for v_source in virtual_dependencies or ():
                checksum = v_source.get_checksum(self.build_state.path_cache)
                mtime = v_source.get_mtime(self.build_state.path_cache)
                rows.append(artifacts_row(
                    artifact=self.artifact_name,
                    source=v_source.path,
                    source_mtime=mtime,
                    source_size=None,
                    source_checksum=checksum,
                    is_dir=False,
                    is_primary_source=False))

            reporter.report_dependencies(rows)

            cur = con.cursor()
            if not for_failure:
                cur.execute('delete from artifacts where artifact = ?',
                            [self.artifact_name])
            if rows:
                cur.executemany('''
                    insert or replace into artifacts (
                        artifact, source, source_mtime, source_size,
                        source_checksum, is_dir, is_primary_source)
                    values (?, ?, ?, ?, ?, ?, ?)
                ''', rows)

            if self.config_hash is None:
                cur.execute('''
                    delete from artifact_config_hashes
                     where artifact = ?
                ''', [self.artifact_name])
            else:
                cur.execute('''
                    insert or replace into artifact_config_hashes
                           (artifact, config_hash) values (?, ?)
                ''', [self.artifact_name, self.config_hash])

            cur.close()
コード例 #3
0
    def memorize_dependencies(self, dependencies=None):
        """This updates the dependencies recorded for the artifact based
        on the direct sources plus the provided dependencies.
        """
        primary_sources = set(self.build_state.to_source_filename(x)
                              for x in self.sources)

        seen = set()
        rows = []
        for source in chain(self.sources, dependencies or ()):
            source = self.build_state.to_source_filename(source)
            if source in seen:
                continue
            info = self.build_state.get_file_info(source)
            rows.append((self.artifact_name, source, info.mtime,
                         info.size, info.checksum,
                         source in primary_sources))
            seen.add(source)

        reporter.report_dependencies(rows)

        con = self.get_connection()
        cur = con.cursor()
        cur.execute('delete from artifacts where artifact = ?',
                    [self.artifact_name])
        if rows:
            cur.executemany('''
                insert into artifacts (artifact, source, source_mtime,
                                       source_size, source_checksum,
                                       is_primary_source)
                values (?, ?, ?, ?, ?, ?)
            ''', rows)
        cur.close()
コード例 #4
0
ファイル: builder.py プロジェクト: RonnyPfannschmidt/lektor
        def operation(con):
            primary_sources = set(self.build_state.to_source_filename(x) for x in self.sources)

            seen = set()
            rows = []
            for source in chain(self.sources, dependencies or ()):
                source = self.build_state.to_source_filename(source)
                if source in seen:
                    continue
                info = self.build_state.get_file_info(source)
                rows.append(
                    (self.artifact_name, source, info.mtime, info.size, info.checksum, source in primary_sources)
                )
                seen.add(source)

            reporter.report_dependencies(rows)

            cur = con.cursor()
            cur.execute("delete from artifacts where artifact = ?", [self.artifact_name])
            if rows:
                cur.executemany(
                    """
                    insert into artifacts (artifact, source, source_mtime,
                                           source_size, source_checksum,
                                           is_primary_source)
                    values (?, ?, ?, ?, ?, ?)
                """,
                    rows,
                )
            cur.close()
コード例 #5
0
ファイル: builder.py プロジェクト: jab/lektor
    def memorize_dependencies(self, dependencies=None):
        """This updates the dependencies recorded for the artifact based
        on the direct sources plus the provided dependencies.
        """
        primary_sources = set(self.build_state.to_source_filename(x) for x in self.sources)

        seen = set()
        rows = []
        for source in chain(self.sources, dependencies or ()):
            source = self.build_state.to_source_filename(source)
            if source in seen:
                continue
            info = self.build_state.get_file_info(source)
            rows.append((self.artifact_name, source, info.mtime, info.size, info.checksum, source in primary_sources))
            seen.add(source)

        reporter.report_dependencies(rows)

        con = self.get_connection()
        cur = con.cursor()
        cur.execute("delete from artifacts where artifact = ?", [self.artifact_name])
        if rows:
            cur.executemany(
                """
                insert into artifacts (artifact, source, source_mtime,
                                       source_size, source_checksum,
                                       is_primary_source)
                values (?, ?, ?, ?, ?, ?)
            """,
                rows,
            )
        cur.close()