• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python repo.Repo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_load_config_from_disk

    def test_load_config_from_disk(self):
        r = Repo(index={}, config={}, connector=self.connector)
        r.load_config_from_disk()

        self.assertEqual(r.config, self.conf)
        self.assertIsNot(r.config, self.conf)
        self.assertEqual(r.index, {})
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:7,代码来源:test_repo.py


示例2: GitBackend

class GitBackend(Backend):

    def __init__(self, gitdir=None):
        self.gitdir = gitdir

        if not self.gitdir:
            self.gitdir = tempfile.mkdtemp()
            Repo.create(self.gitdir)

        self.repo = Repo(self.gitdir)
        self.fetch_objects = self.repo.fetch_objects
        self.get_refs = self.repo.get_refs

    def apply_pack(self, refs, read):
        fd, commit = self.repo.object_store.add_thin_pack()
        fd.write(read())
        fd.close()
        commit()

        for oldsha, sha, ref in refs:
            if ref == "0" * 40:
                self.repo.remove_ref(ref)
            else:
                self.repo.set_ref(ref, sha)

        print "pack applied"
开发者ID:SRabbelier,项目名称:hg-git,代码行数:26,代码来源:server.py


示例3: update

    def update(self):
        if not self.isValid():
            return False

        Repo.destroy(Game, self)
        Repo.create(Game, self)
        return True
开发者ID:riseshia,项目名称:small_toys,代码行数:7,代码来源:game.py


示例4: find

	def find(query, components):
		conn = DB.getConn()
		c = conn.cursor()
		
		c.execute(query, components)
                commitrows = c.fetchall()
                commitfiles = []

                if commitrows:
                        allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])

                        #This is poor practice, but we assured ourselves the value is composed only of ints first
                        DB.execute(c, "SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
                        commitfiles = c.fetchall()

                        DB.execute(c, "SELECT * from " + DB.commitkeyword._table + " WHERE commitid IN (" + allcommitids + ")")
                        commitkeywords = c.fetchall()

                commits = []
                for i in commitrows:
                        r = Repo()
                        r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2],
                                i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])

                        files = [file[DB.commitfile.file] for file in commitfiles
                                if file[DB.commitfile.commitid] == i[DB.commit.id]]
                        keywords = [keyword[DB.commitkeyword.keyword] for keyword in commitkeywords
                                    if keyword[DB.commitkeyword.commitid] == i[DB.commit.id]]

                        c = Commit()
                        c.loadFromDatabase(r, i, files, keywords)

                        commits.append(c)

                return commits
开发者ID:deepcell,项目名称:code-audit-feed,代码行数:35,代码来源:databaseQueries.py


示例5: test_load_version_mismatch_error

    def test_load_version_mismatch_error(self):
        r = Repo(index={}, config=self.conf, connector=self.connector)

        with self.assertRaises(VersionMismatchError) as cm:
            r.load_index_from_disk(99)
        self.assertEqual(cm.exception.actual, 99)
        self.assertEqual(cm.exception.expected, repo.INDEX_FORMAT_VERSION)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:7,代码来源:test_repo.py


示例6: setUp

 def setUp(self):
     self.connector = MockConnector(urlparse.urlparse('/baseurl/repo/'))
     self.connector.connect()
     self.pi = index.PictureIndex()
     self.pi.add(MockPicture.create_many(10))
     self.conf = repo.new_repo_config()
     self.conf['index.file'] = 'mock-index-path'
     Repo.create_on_disk(self.connector, self.conf, self.pi)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:8,代码来源:test_repo.py


示例7: test_save_index_to_disk

    def test_save_index_to_disk(self):
        r = Repo(self.pi, self.conf, self.connector)
        r.save_index_to_disk()

        self.assertTrue(self.connector.opened('mock-index-path'))
        index_on_disk = index.PictureIndex()
        index_on_disk.read(self.connector.get_file('mock-index-path'))
        self.assertEqual(index_on_disk, self.pi)
        self.assertIsNot(index_on_disk, self.pi)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:9,代码来源:test_repo.py


示例8: test_save_config_to_disk

    def test_save_config_to_disk(self):
        r = Repo(self.pi, self.conf, self.connector)
        r.save_config_to_disk()

        self.assertTrue(self.connector.opened(repo.CONFIG_FILE))
        config_on_disk = config.Config()
        config_on_disk.read(self.connector.get_file(repo.CONFIG_FILE))
        self.assertEqual(config_on_disk, self.conf)
        self.assertIsNot(config_on_disk, self.conf)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:9,代码来源:test_repo.py


示例9: __init__

    def __init__(self, gitdir=None):
        self.gitdir = gitdir

        if not self.gitdir:
            self.gitdir = tempfile.mkdtemp()
            Repo.create(self.gitdir)

        self.repo = Repo(self.gitdir)
        self.fetch_objects = self.repo.fetch_objects
        self.get_refs = self.repo.get_refs
开发者ID:SRabbelier,项目名称:hg-git,代码行数:10,代码来源:server.py


示例10: test_load_from_disk

    def test_load_from_disk(self):
        repo_created = Repo.create_on_disk(self.connector, self.conf, self.pi)
        repo_loaded = Repo.load_from_disk(self.connector)

        self.assertIsInstance(repo_loaded, Repo)
        self.assertEqual(repo_loaded.config, repo_created.config)
        self.assertIsNot(repo_loaded.config, repo_created.config)
        self.assertEqual(repo_loaded.index, repo_created.index)
        self.assertIsNot(repo_loaded.index, repo_created.index)
        self.assertIsNot(repo_loaded, repo_created)
        self.assertIs(repo_loaded.connector, self.connector)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:11,代码来源:test_repo.py


示例11: test_clone

    def test_clone(self):
        src_repo = Repo.create_on_disk(self.connector, self.conf, self.pi)
        dest_connector = MockConnector(urlparse.urlparse('/destrepo/baseurl/'))
        dest_connector.connect()
        dest_repo = Repo.clone(repo=src_repo, dest=dest_connector)

        self.assertIsInstance(dest_repo, Repo)
        self.assertEqual(dest_repo.config, src_repo.config)
        self.assertIsNot(dest_repo.config, src_repo.config)
        self.assertEqual(dest_repo.index, src_repo.index)
        self.assertIsNot(dest_repo.index, src_repo.index)
        self.assertIsNot(dest_repo, src_repo)
        self.assertTrue(dest_connector.opened(repo.CONFIG_FILE))
        self.assertTrue(dest_connector.opened('mock-index-path'))
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:14,代码来源:test_repo.py


示例12: _related_args

 def _related_args(self, record, related_class):
     # Both records are already persisted (have ids), so we can
     # set up the relating record fully now. One of the ids comes
     # from the constraint on the query, the other comes from
     # the foreign key logic below:
     # What we do is we get the singular table name of the record.
     # With that, we can look into the related class description for
     # the correct foreign key, which is set to the passed record's
     # id.
     record_class_name = inflector.singularize(Repo.table_name(record.__class__))
     related_args = self.where_query.get(Repo.table_name(related_class), {})
     related_key = associations.foreign_keys_for(related_class)[record_class_name]
     related_args[related_key] = record.id
     return related_args
开发者ID:ECESeniorDesign,项目名称:lazy_record,代码行数:14,代码来源:query.py


示例13: test_it_should_replace_a_given_string_in_repo_conf

  def test_it_should_replace_a_given_string_in_repo_conf(self):
    mocked_re = MagicMock()
    path = 'tests/fixtures/config.conf'

    mocked_re.sub.return_value = 'another_text'

    with patch.multiple('repo', re=mocked_re):
      repo = Repo(path)
      repo.replace('pattern', 'string')

      with open('tests/fixtures/config.conf') as f:
        eq_(f.read(), 'another_text')

      mocked_re.sub.assert_called_once_with('pattern', 'string',
                                            'another_text')
开发者ID:bcersows,项目名称:pyolite,代码行数:15,代码来源:test_repo.py


示例14: RepoServer

class RepoServer(object):
    def __init__(self, keyChain, certificateName):
        self._keyChain = keyChain
        self._certificateName = certificateName
        self.repo = Repo()

    def onInterest(self, prefix, interest, transport, registeredPrefixId):
        print 'Interest received: %s' % interest.getName().toUri()

        # Make and sign a Data packet.
        encoded_data = self.repo.extract_from_repo(interest)
        if not encoded_data:
            data = Data(interest.getName())
            content = "No match found"
            data.setContent(content)
            self._keyChain.sign(data, self._certificateName)
            encoded_data = data.wireEncode().toBuffer()
        else:
            dumpData(encoded_data)
            encoded_data = encoded_data.wireEncode().toBuffer()

        transport.send(encoded_data)
        print 'sent'

    def onRegisterFailed(self, prefix):
        dump("Register failed for prefix", prefix.toUri())
开发者ID:remap,项目名称:BMS-REPO,代码行数:26,代码来源:server.py


示例15: find

    def find(query, components):
        conn = DB.getConn()
        c = conn.cursor()
        
        c.execute(query, components)
        commitrows = c.fetchall()
        commitfiles = []

        if commitrows:
                allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])

                #This is poor practice, but we assured ourselves the value is composed only of ints first
                DB.execute(c, "SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
                commitfiles = c.fetchall()

                DB.execute(c, "SELECT * from " + DB.commitkeyword._table + " WHERE commitid IN (" + allcommitids + ")")
                commitkeywords = c.fetchall()
                
                DB.execute(c, "SELECT commitid, case when length(data) < 307200 then data else 'TOOLARGE' end as data from " + DB.commitdiffs._table + " WHERE commitid IN (" + allcommitids + ")")
                commitdata = c.fetchall()
                

        commits = []
        for i in commitrows:
                r = Repo()
                r.loadFromValues(i[DB.commit._numColumns + DB.repo.id], i[DB.commit._numColumns + DB.repo.name], i[DB.commit._numColumns + DB.repo.repotypeid], i[DB.commit._numColumns + DB.repo.url],
                        i[DB.commit._numColumns + DB.repo.viewlink], i[DB.commit._numColumns + DB.repo.tagname], i[DB.commit._numColumns + DB.repo.tagmaturity])

                files = [file[DB.commitfile.file] for file in commitfiles
                        if file[DB.commitfile.commitid] == i[DB.commit.id]]
                keywords = [keyword[DB.commitkeyword.keyword] for keyword in commitkeywords
                            if keyword[DB.commitkeyword.commitid] == i[DB.commit.id]]
                data = [cdata[DB.commitdiffs.data] for cdata in commitdata
                            if cdata[DB.commitdiffs.commitid] == i[DB.commit.id]][0]

                if i[DB.commit._numColumns + DB.repo.repotypeid] == Repo.Type.GIT:
                    c = GitCommit()
                elif i[DB.commit._numColumns + DB.repo.repotypeid] == Repo.Type.SVN:
                    c = SVNCommit()
                else:
                    c = Commit()
                c.loadFromDatabase(r, i, files, keywords, data)

                commits.append(c)

        return commits
开发者ID:abeluck,项目名称:code-peer-review,代码行数:46,代码来源:databaseQueries.py


示例16: findByKeywords

	def findByKeywords(keywords):
		conn = DB.getConn()
		c = conn.cursor()
		
		getcommitsSQL = "SELECT c.*, r.* " + \
				"FROM " + DB.commit._table + " c " + \
				"INNER JOIN " + DB.repo._table + " r " + \
				"	ON r.id = c.repoid "
		
		whereClause = " 1=1 "
		components = []
		if keywords:
			keywordsTree = KeywordsParser(keywords)
			getcommitsSQL += "LEFT OUTER JOIN " + DB.commitkeyword._table + " ck " + \
							 "	ON c.id = ck.commitid "
			whereClause, components = keywordsTree.getWhereClause("ck.keyword", "r.tagname", "r.maturity")
		
		getcommitsSQL += "WHERE " + whereClause
		getcommitsSQL += "ORDER BY c.date DESC "
		
		c.execute(getcommitsSQL, components)
		commitrows = c.fetchall()
		commitfiles = []
		
		if commitrows:
			allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])
		
			#This is poor practice, but we assured ourselves the value is composed only of ints first
			c.execute("SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
			commitfiles = c.fetchall()

		commits = []
		for i in commitrows:
			r = Repo()
			r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2], 
				i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])
			
			files = [file[DB.commitfile.file] for file in commitfiles 
				if file[DB.commitfile.commitid] == i[DB.commit.id]]
			
			c = Commit()
			c.loadFromDatabase(r, i, files)
			
			commits.append(c)

		return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:46,代码来源:databaseQueries.py


示例17: findByIDs

	def findByIDs(project, uniqueid):
		conn = DB.getConn()
		c = conn.cursor()
		
		getcommitsSQL = "SELECT c.*, r.* " + \
				"FROM " + DB.commit._table + " c " + \
				"INNER JOIN " + DB.repo._table + " r " + \
				"	ON r.id = c.repoid "
		
		whereClause = " 1=1 "
		components = []
		if project and uniqueid:
			whereClause += "AND r.tagname = %s AND c.uniqueid = %s "
			components = [project, uniqueid]
		
		getcommitsSQL += "WHERE " + whereClause
		getcommitsSQL += "ORDER BY c.date DESC "
		
		DB.execute(c, getcommitsSQL, components)
		commitrows = c.fetchall()
		commitfiles = []
		
		if commitrows:
			allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])
		
			#This is poor practice, but we assured ourselves the value is composed only of ints first
			DB.execute(c, "SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
			commitfiles = c.fetchall()

		commits = []
		for i in commitrows:
			r = Repo()
			r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2], 
				i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])
			
			files = [file[DB.commitfile.file] for file in commitfiles 
				if file[DB.commitfile.commitid] == i[DB.commit.id]]
			
			c = Commit()
			c.loadFromDatabase(r, i, files)
			
			commits.append(c)

		return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:44,代码来源:databaseQueries.py


示例18: get_repos

def get_repos(handle):
    if handle == USERNAME:
        repo_url = URL + '/user/repos'

    else:
        repo_url = URL + '/users/' + handle + '/repos'

    repo_response = requests.get(repo_url, headers=HEADERS, auth=(USERNAME, PASSWORD)).json()
    repos = [Repo.from_Repository(repo) for repo in repo_response]
    return repos
开发者ID:kshitij10496,项目名称:gh-scrapper,代码行数:10,代码来源:userclass.py


示例19: create_site

def create_site(repo_path, target_dir):
    """ Записывает извлекаемые из репозитория данные в виде статического
        HTML-сайта в каталог target_dir """
            
    r = Repo.open(repo_path)
    print "Repo loaded."
    print "Blaming the authors..."
    r.compute_blame()
    print "Done."
    print "Saving data..."
    r.save()
    print "Done."
    print "Stats for the latest revision:"
    print r.commits[r.head].snapshot_blame
    print "Plotting..."
    
    if not os.path.isdir(target_dir):
        os.makedirs(target_dir)
    copy_common_files(target_dir)
        
    longest_path = r.get_longest_path()
    print "Found longest_path, len = ", len(longest_path)
    png, commit_coords = commitgraph.commit_network(r, set(longest_path))
    f = open(os.path.join(target_dir, 'graph.png'), 'wb')
    f.write(png)
    f.close()
    print "Plotting blame..."
    png = plot.plot_snapshot_blame(r, longest_path, commit_coords, relative=False)
    f = open(os.path.join(target_dir, 'blame-abs.png'), 'wb')
    f.write(png)
    f.close()
    print "Plotting blame (relative)..."
    png = plot.plot_snapshot_blame(r, longest_path, commit_coords, relative=True)
    f = open(os.path.join(target_dir, 'blame-rel.png'), 'wb')
    f.write(png)
    f.close()
    print "Done"

    print "Writing commit information..."
    f = open(os.path.join(target_dir, 'commits-data.js'), 'w')
    r.dump_commit_info_js(f, commit_coords)
    f.close()
    print "Done"

    root = dirtree.Directory.from_revision_blames(r.commits[r.head].snapshot_file_blames)

    print "Writing dirtree information..."
    f = open(os.path.join(target_dir, 'dirtree-data.js'), 'w')
    root.dump_to_js(f)
    f.close()
    print "Done"
开发者ID:a-kr,项目名称:git-blamer,代码行数:51,代码来源:git-blamer.py


示例20: __init__

 def __init__(self, **kwargs):
     """
     Instantiate a new object, mass-assigning the values in +kwargs+.
     Cannot mass-assign id or created_at.
     """
     if set(["id", "created_at", "updated_at"]) & set(kwargs):
         raise AttributeError("Cannot set 'id', 'created_at', "
                              "or 'updated_at'")
     for attr in self.__class__.__all_attributes__:
         setattr(self, "_" + attr, None)
     self.update(**kwargs)
     self._id = None
     self.__table = Repo.table_name(self.__class__)
     self._related_records = []
     self._delete_related_records = []
开发者ID:ECESeniorDesign,项目名称:lazy_record,代码行数:15,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python repository.Repository类代码示例发布时间:2022-05-26
下一篇:
Python models.Reply类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap