当前位置: 首页>>代码示例>>Python>>正文


Python Database.statement函数代码示例

本文整理汇总了Python中pycvsanaly2.Database.statement函数的典型用法代码示例。如果您正苦于以下问题:Python statement函数的具体用法?Python statement怎么用?Python statement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了statement函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

    def run (self, repo, uri, db):
        self.db = db
        self.repo = repo

        path = uri_to_filename (uri)
        if path is not None:
            repo_uri = repo.get_uri_for_path (path)
        else:
            repo_uri = uri

        path = uri_to_filename (uri)
        self.repo_uri = path or repo.get_uri ()

        cnn = self.db.connect ()

        cursor = cnn.cursor ()
        cursor.execute (statement ("SELECT id from repositories where uri = ?", db.place_holder), (repo_uri,))
        repo_id = cursor.fetchone ()[0]

        # If table does not exist, the list of commits is empty,
        # otherwise it will be filled within the except block below
        commits = []

        try:
            self.__create_table (cnn)
        except TableAlreadyExists:
            cursor.execute (statement ("SELECT max(id) from patches", db.place_holder))
            id = cursor.fetchone ()[0]
            if id is not None:
                DBPatch.id_counter = id + 1

            commits = self.__get_patches_for_repository (repo_id, cursor)
        except Exception, e:
            raise ExtensionRunError (str (e))
开发者ID:AlertProject,项目名称:CVSAnalY,代码行数:34,代码来源:Patches.py

示例2: run

    def run(self, repo, uri, db):
        self.db = db

        path = uri_to_filename(uri)
        if path is not None:
            repo_uri = repo.get_uri_for_path(path)
        else:
            repo_uri = uri

        cnn = self.db.connect()

        cursor = cnn.cursor()
        cursor.execute(statement("SELECT id from repositories where uri = ?", db.place_holder), (repo_uri,))
        repo_id = cursor.fetchone()[0]

        files = []

        try:
            self.__create_table(cnn)
        except TableAlreadyExists:
            cursor.execute(statement("SELECT max(id) from file_types", db.place_holder))
            id = cursor.fetchone()[0]
            if id is not None:
                DBFileType.id_counter = id + 1

            files = self.__get_files_for_repository(repo_id, cursor)
        except Exception, e:
            raise ExtensionRunError(str(e))
开发者ID:rodrigoprimo,项目名称:CVSAnalY,代码行数:28,代码来源:FileTypes.py

示例3: __get_patches_for_repository

    def __get_patches_for_repository (self, repo_id, cursor):
        query = "SELECT p.commit_id from patches p, scmlog s " + \
                "WHERE p.commit_id = s.id and repository_id = ?"
        cursor.execute (statement (query, self.db.place_holder), (repo_id,))
        commits = [res[0] for res in cursor.fetchall ()]

        return commits
开发者ID:AlertProject,项目名称:CVSAnalY,代码行数:7,代码来源:Patches.py

示例4: __find_previous_commit

 def __find_previous_commit(self, file_id, commit_id):
     query = """select a.commit_id, a.action_type, c.rev from _action_files_cache a,scmlog c
         where a.commit_id=c.id and a.file_id=?
         order by c.date
     """
     cnn = self.db.connect ()
     aux_cursor = cnn.cursor()
     aux_cursor.execute(statement(query, self.db.place_holder),(file_id,))
     all_commits=aux_cursor.fetchall()
     aux_cursor.close()
     cnn.close()
     pre_commit_id = None
     pre_rev = None
     for cur_commit_id,type, cur_rev in all_commits:
         if cur_commit_id == commit_id:
             #Nothing to blame for other types
             if type != 'M' and type != 'R':
                 raise NotValidHunkWarning("Wrong commit to blame: commit type: %s"%type)
             else:
                 break
         else:
             pre_commit_id = cur_commit_id
             pre_rev = cur_rev
     else:
         raise NotValidHunkWarning("No previous commit found for file %d at commit %d"%(file_id, commit_id))
     if pre_commit_id is None or pre_rev is None:
         raise NotValidHunkWarning("No previous commit found for file %d at commit %d"%(file_id, commit_id))
     return pre_commit_id,pre_rev    
开发者ID:jsichi,项目名称:cvsanaly,代码行数:28,代码来源:HunkBlame.py

示例5: process_finished_jobs

    def process_finished_jobs(self, job_pool, write_cursor, unlocked=False):
        if unlocked:
            job = job_pool.get_next_done_unlocked()
        else:
            job = job_pool.get_next_done(0.5)

        args = []
        
        processed_jobs = 0
        while job is not None:
            if not job.failed:
                a = self.populate_insert_args(job)
                args.extend(a)
                self.id_counter += len(a)
            processed_jobs += 1
            if unlocked:
                job = job_pool.get_next_done_unlocked()
            else:
                job = job_pool.get_next_done(0)

        if len(args) > 0:
            write_cursor.executemany(statement(self.__insert__, 
                                               self.db.place_holder), args)
            del args
        return processed_jobs
开发者ID:carlsonp,项目名称:MininGit,代码行数:25,代码来源:Blame.py

示例6: _do_backout

   def _do_backout(self, repo, uri, db, backout_statement):
       connection = db.connect()
       repo_cursor = connection.cursor()
       repo_uri = get_repo_uri(uri, repo)
       
       try:
           repo_id = get_repo_id(repo_uri, repo_cursor, db)
       except RepoNotFound:
           # Repository isn't in there, so it's likely already backed out
           printerr("Repository not found, is it in the database?")
           return True
       finally:
           repo_cursor.close()
         
       update_cursor = connection.cursor()
 
       execute_statement(statement(backout_statement, db.place_holder),
                           (repo_id,),
                           update_cursor,
                           db,
                           "Couldn't backout extension",
                           exception=ExtensionBackoutError)
       update_cursor.close()
       connection.commit()
       connection.close()
开发者ID:apepper,项目名称:cvsanaly,代码行数:25,代码来源:__init__.py

示例7: __process_finished_jobs

    def __process_finished_jobs (self, job_pool, write_cursor, unlocked = False):
        if unlocked:
            job = job_pool.get_next_done_unlocked ()
        else:
            job = job_pool.get_next_done ()

        args = []

        while job is not None:
            authors = job.get_authors ()
            file_id = job.get_file_id ()
            commit_id = job.get_commit_id ()

            a = [(self.id_counter + i, file_id, commit_id, self.authors[key], authors[key]) \
                     for i, key in enumerate (authors.keys ())]
            args.extend (a)
            self.id_counter += len (a)

            if unlocked:
                job = job_pool.get_next_done_unlocked ()
            else:
                job = job_pool.get_next_done (0.5)

        if args:
            write_cursor.executemany (statement (self.__insert__, self.db.place_holder), args)
            del args
开发者ID:AlertProject,项目名称:CVSAnalY,代码行数:26,代码来源:Blame.py

示例8: get_path_from_database

 def get_path_from_database(self, file_id, commit_id):
     """Returns the last valid path for a given file_id at commit_id
        (May have been removed afterwords!)"""
     
     if config.debug:
         profiler_start("Getting full file path for file_id %d and \
                         commit_id %d", (file_id, commit_id))
     
     db = self.__dict__['db']
     cnn = db.connect()
     
     cursor = cnn.cursor()
     query = """SELECT current_file_path from actions
                WHERE file_id=? AND commit_id <= ?
                ORDER BY commit_id DESC LIMIT 1"""
     cursor.execute(statement(query, db.place_holder), (file_id, commit_id))
     try:
         file_path = cursor.fetchone()[0]
     except:
         file_path = None
     
     cursor.close()
     cnn.close()
     
     printdbg("get_path_from_database:\
               Path for file_id %d at commit_id %d: %s",
              (file_id, commit_id, file_path))
     if config.debug:
         profiler_stop("Getting full file path for file_id %d and\
                          commit_id %d", (file_id, commit_id), True)
     return file_path
开发者ID:ProjectHistory,项目名称:MininGit,代码行数:31,代码来源:FilePaths.py

示例9: __process_finished_jobs

    def __process_finished_jobs(self, job_pool, write_cursor, db):
#        start = datetime.now()
        finished_job = job_pool.get_next_done(0)
        processed_jobs = 0
        # commit_id is the commit ID. For some reason, the 
        # documentation advocates tablename_id as the reference,
        # but in the source, these are referred to as commit IDs.
        # Don't ask me why!
        while finished_job is not None:
            file_contents = None
                        
            if not Config().no_content:
                file_contents = str(finished_job.file_contents)
            
            query = """
                insert into content(commit_id, file_id, content, loc, size) 
                    values(?,?,?,?,?)"""
            insert_statement = statement(query, db.place_holder)
            parameters = (finished_job.commit_id,
                          finished_job.file_id,
                          file_contents,
                          finished_job.file_number_of_lines,
                          finished_job.file_size)
                                
            execute_statement(insert_statement, parameters, write_cursor, db,
                       "Couldn't insert, duplicate record?", 
                       exception=ExtensionRunError)
            
            processed_jobs += 1
            finished_job = job_pool.get_next_done(0)
            
        return processed_jobs
开发者ID:carlsonp,项目名称:MininGit,代码行数:32,代码来源:Content.py

示例10: get_file_id

 def get_file_id(self, file_path, commit_id):
     """Ask for the file_id for a given file_path and commit_id"""
     
     if config.debug:
         profiler_start("Getting file id for file_path %s and commit_id %d",
                         (file_path, commit_id))
     
     db = self.__dict__['db']
     cnn = db.connect()
     cursor = cnn.cursor()
     query = """SELECT file_id from actions
                WHERE binary current_file_path = ? AND commit_id = ?
                ORDER BY commit_id DESC LIMIT 1"""
     cursor.execute(statement(query, db.place_holder),
                     (file_path, commit_id))
     try:
         file_id = cursor.fetchone()[0]
     except:
         file_id = None
     
     cursor.close()
     cnn.close()
     
     if config.debug:
         profiler_stop("Getting file id for file_path %s and commit_id %d",
                        (file_path, commit_id), True)
     
     return file_id
开发者ID:ProjectHistory,项目名称:MininGit,代码行数:28,代码来源:FilePaths.py

示例11: __get_files_for_repository

    def __get_files_for_repository(self, repo_id, cursor):
        query = "SELECT ft.file_id from file_types ft, files f " + \
                "WHERE f.id = ft.file_id and f.repository_id = ?"
        cursor.execute(statement(query, self.db.place_holder), (repo_id,))
        files = [res[0] for res in cursor.fetchall()]

        return files
开发者ID:ProjectHistory,项目名称:MininGit,代码行数:7,代码来源:FileTypes.py

示例12: run

    def run(self, repo, uri, db):            
        # Start the profiler, per every other extension
        profiler_start("Running FileCount extension")
        
        # Open a connection to the database and get cursors
        self.db = db
        connection = self.db.connect()
        read_cursor = connection.cursor()
        write_cursor = connection.cursor()
        
        # Try to get the repository and get its ID from the database
        try:
            path = uri_to_filename(uri)
            if path is not None:
                repo_uri = repo.get_uri_for_path(path)
            else:
                repo_uri = uri

            read_cursor.execute(statement( \
                    "SELECT id from repositories where uri = ?", \
                    db.place_holder), (repo_uri,))
            repo_id = read_cursor.fetchone()[0]
        except NotImplementedError:
            raise ExtensionRunError( \
                    "FileCount extension is not supported for %s repos" % \
                    (repo.get_type()))
        except Exception, e:
            raise ExtensionRunError( \
                    "Error creating repository %s. Exception: %s" % \
                    (repo.get_uri(), str(e)))
开发者ID:ProjectHistory,项目名称:MininGit,代码行数:30,代码来源:FileCount.py

示例13: run

    def run(self, repo, uri, db):
        profiler_start("Running Blame extension")

        self.db = db

        cnn = self.db.connect()
        read_cursor = cnn.cursor()
        write_cursor = cnn.cursor()

        blames = []

        try:
            path = uri_to_filename(uri)
            if path is not None:
                repo_uri = repo.get_uri_for_path(path)
            else:
                repo_uri = uri

            read_cursor.execute(statement("SELECT id from repositories " + \
                                          "where uri = ?", db.place_holder), 
                                          (repo_uri,))
            repoid = read_cursor.fetchone()[0]
        except NotImplementedError:
            raise ExtensionRunError("Blame extension is not supported for " + \
                                    "%s repositories" % (repo.get_type()))
        except Exception, e:
            raise ExtensionRunError("Error creating repository %s. " + \
                                    "Exception: %s" % (repo.get_uri(), str(e)))
开发者ID:carlsonp,项目名称:MininGit,代码行数:28,代码来源:Blame.py

示例14: get_path

    def get_path(self, repo=None, repo_path=None):
        if not self.current:
            return None

        revision, commit_id, file_id, action_type, composed = self.current
        if composed:
            rev = revision.split("|")[0]
        else:
            rev = revision
        cursor = self.cnn.cursor()
        cursor.execute(statement(self.__path_query__, self.db.place_holder),
                       (file_id, commit_id))
        file_link = cursor.fetchone()
        relative_path = None
        if repo is None:
            relative_path = file_link[1]
        else:
            try:
                while file_link:
                    if repo.is_ancestor(repo_path, file_link[0], rev):
                        relative_path = file_link[1]
                        break
                    else:
                        file_link = cursor.fetchone()
            except CommandError as e:
                printerr(str(e) + '\n' + e.error)

        cursor.close()
        if relative_path is None:
            return None
        else:
            return relative_path.strip("/")
开发者ID:Lashchyk,项目名称:CVSAnalY,代码行数:32,代码来源:FileRevs.py

示例15: __get_hunk_blames

 def __get_hunk_blames(self, cursor, repoid):
     query = """select distinct b.hunk_id 
         from hunk_blames b 
         join hunks h on b.hunk_id=h.id
         join files f on h.file_id=f.id
         where f.repository_id=?"""
     cursor.execute (statement (query, self.db.place_holder), (repoid,))
     return [h[0] for h in cursor.fetchall()]
开发者ID:jsichi,项目名称:cvsanaly,代码行数:8,代码来源:HunkBlame.py


注:本文中的pycvsanaly2.Database.statement函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。