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


Python config.ConfigFile类代码示例

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


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

示例1: get_config

    def get_config(self):
        """Retrieve the config object.

        :return: `ConfigFile` object for the ``.git/config`` file.
        """
        from dulwich.config import ConfigFile
        path = os.path.join(self._controldir, 'config')
        try:
            return ConfigFile.from_path(path)
        except (IOError, OSError) as e:
            if e.errno != errno.ENOENT:
                raise
            ret = ConfigFile()
            ret.path = path
            return ret
开发者ID:akbargumbira,项目名称:qgis_resources_sharing,代码行数:15,代码来源:repo.py

示例2: testSubmodules

    def testSubmodules(self):
        cf = ConfigFile.from_file(BytesIO(b"""\
[submodule "core/lib"]
	path = core/lib
	url = https://github.com/phhusson/QuasselC.git
"""))
        got = list(parse_submodules(cf))
        self.assertEqual([
            (b'core/lib', b'https://github.com/phhusson/QuasselC.git', b'core/lib')], got)
开发者ID:stevegt,项目名称:dulwich,代码行数:9,代码来源:test_config.py

示例3: fetch_refs

def fetch_refs(remote_name = 'origin', local='.'):
    """
    Fetch references from a Git remote repository
    :param remote_name: <str> git name of remote repository, _default='origin'_
    :param local: <str> full path to local repository, _default='.'_
    :return entries: <TreeEntry> named tuples
    """
    #import rpdb; rpdb.set_trace()
    # **Fetch refs from remote**
    # create a dulwich Repo object from path to local repo
    r = Repo(local)  # local repository
    objsto = r.object_store  # create a ObjectStore object from the local repo
    determine_wants = objsto.determine_wants_all  # built in dulwich function
    gitdir = os.path.join(local, r.controldir())  # the git folder
    cnf_file = os.path.join(gitdir, 'config')  # path to config
    cnf = ConfigFile.from_path(cnf_file)  # config
    remote = cnf.get(('remote', remote_name), 'url')  # url of remote
    # correctly parse host path and create dulwich Client object from it
    client, host_path = get_transport_and_path(remote)
    remote_refs = client.fetch(host_path, r, determine_wants, sys.stdout.write)

    # **Store refs fetched by dulwich**
    dulwich_refs = os.path.join(gitdir, DULWICH_REFS)
    with open(dulwich_refs, 'wb') as file:
        writer = csv.writer(file, delimiter=' ')
        for key, value in remote_refs.items():
            writer.writerow([key, value])

    # **save remote refs shas for future checkout**
    remote_dir = os.path.join(gitdir, 'refs', 'remotes', remote_name)  # .git/refs/remotes
    ensure_dir_exists(remote_dir)  # built in dulwich function
    headref = 0
    # head branch ref
    if remote_refs.has_key('HEAD'):
        headref = remote_refs.pop('HEAD')  # sha of HEAD
        i_head = remote_refs.values().index(headref)  # index of head ref
        head_branch = remote_refs.keys()[i_head]  # name of head branch
        branch_key = head_branch.rsplit('/',1)[-1]  # branch
        head_file = os.path.join(remote_dir, 'HEAD')  # path to branch shas file
        head_ref = '/'.join(['refs','remotes',remote_name,branch_key])
        with open(head_file, 'wb') as GitFile:
            GitFile.write('ref: ' + head_ref + '\n')
    # remote branch refs
    for key, value in remote_refs.items():
        key = key.rsplit('/',1)[-1]  # get just the remote's branch
        reffile = os.path.join(remote_dir, key)  # path to branch shas file
        with open(reffile, 'wb') as GitFile:
            GitFile.write(value + '\n')
    if headref:
        remote_refs['HEAD'] = headref  # restore HEAD sha

    return remote_refs
开发者ID:TDC-bob,项目名称:dulwichPorcelain,代码行数:52,代码来源:fetch_refs.py

示例4: from_file

 def from_file(self, text):
     return ConfigFile.from_file(StringIO(text))
开发者ID:kankri,项目名称:dulwich,代码行数:2,代码来源:test_config.py

示例5: test_write_to_file_subsection

 def test_write_to_file_subsection(self):
     c = ConfigFile()
     c.set(("branch", "blie"), "foo", "bar")
     f = StringIO()
     c.write_to_file(f)
     self.assertEquals("[branch \"blie\"]\nfoo = bar\n", f.getvalue())
开发者ID:kankri,项目名称:dulwich,代码行数:6,代码来源:test_config.py

示例6: test_write_to_file_section

 def test_write_to_file_section(self):
     c = ConfigFile()
     c.set(("core", ), "foo", "bar")
     f = StringIO()
     c.write_to_file(f)
     self.assertEquals("[core]\nfoo = bar\n", f.getvalue())
开发者ID:kankri,项目名称:dulwich,代码行数:6,代码来源:test_config.py

示例7: test_write_to_file_empty

 def test_write_to_file_empty(self):
     c = ConfigFile()
     f = StringIO()
     c.write_to_file(f)
     self.assertEquals("", f.getvalue())
开发者ID:kankri,项目名称:dulwich,代码行数:5,代码来源:test_config.py

示例8: _init_files

    def _init_files(self, bare):
        """Initialize a default set of named files."""
        from dulwich.config import ConfigFile
        self._put_named_file('description', b"Unnamed repository")
        f = BytesIO()
        cf = ConfigFile()
        cf.set(b"core", b"repositoryformatversion", b"0")
        if self._determine_file_mode():
            cf.set(b"core", b"filemode", True)
        else:
            cf.set(b"core", b"filemode", False)

        cf.set(b"core", b"bare", bare)
        cf.set(b"core", b"logallrefupdates", True)
        cf.write_to_file(f)
        self._put_named_file('config', f.getvalue())
        self._put_named_file(os.path.join('info', 'exclude'), b'')
开发者ID:akbargumbira,项目名称:qgis_resources_sharing,代码行数:17,代码来源:repo.py

示例9: from_file

 def from_file(self, text):
     return ConfigFile.from_file(BytesIO(text))
开发者ID:stevegt,项目名称:dulwich,代码行数:2,代码来源:test_config.py

示例10: test_write_to_file_subsection

 def test_write_to_file_subsection(self):
     c = ConfigFile()
     c.set((b"branch", b"blie"), b"foo", b"bar")
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"[branch \"blie\"]\n\tfoo = bar\n", f.getvalue())
开发者ID:stevegt,项目名称:dulwich,代码行数:6,代码来源:test_config.py

示例11: test_write_to_file_section

 def test_write_to_file_section(self):
     c = ConfigFile()
     c.set((b"core", ), b"foo", b"bar")
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"[core]\n\tfoo = bar\n", f.getvalue())
开发者ID:stevegt,项目名称:dulwich,代码行数:6,代码来源:test_config.py

示例12: test_write_to_file_empty

 def test_write_to_file_empty(self):
     c = ConfigFile()
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"", f.getvalue())
开发者ID:stevegt,项目名称:dulwich,代码行数:5,代码来源:test_config.py

示例13: test_set_hash_gets_quoted

 def test_set_hash_gets_quoted(self):
     c = ConfigFile()
     c.set(b"xandikos", b"color", b"#665544")
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"[xandikos]\n\tcolor = \"#665544\"\n", f.getvalue())
开发者ID:jelmer,项目名称:dulwich,代码行数:6,代码来源:test_config.py

示例14: gen_configs

 def gen_configs():
     for path in config_file + self._config_files:
         try:
             yield ConfigFile.from_path(path)
         except (IOError, OSError, ValueError):
             continue
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:6,代码来源:repository.py

示例15: _init_files

 def _init_files(self, bare):
     """Initialize a default set of named files."""
     from dulwich.config import ConfigFile
     self._put_named_file('description', "Unnamed repository")
     f = StringIO()
     cf = ConfigFile()
     cf.set("core", "repositoryformatversion", "0")
     cf.set("core", "filemode", "true")
     cf.set("core", "bare", str(bare).lower())
     cf.set("core", "logallrefupdates", "true")
     cf.write_to_file(f)
     self._put_named_file('config', f.getvalue())
     self._put_named_file(os.path.join('info', 'exclude'), '')
开发者ID:rodcloutier,项目名称:dulwich,代码行数:13,代码来源:repo.py


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