當前位置: 首頁>>代碼示例>>Python>>正文


Python repo.Repo類代碼示例

本文整理匯總了Python中repo.Repo的典型用法代碼示例。如果您正苦於以下問題:Python Repo類的具體用法?Python Repo怎麽用?Python Repo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Repo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的repo.Repo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。