FilenameMapping.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:rdiff-backup 作者: sol1 项目源码 文件源码
def update_quoting(rbdir):
    """Update the quoting of a repository by renaming any
    files that should be quoted differently.
    """

    def requote(name):
        unquoted_name = unquote(name)
        quoted_name = quote(unquoted_name)
        if name != quoted_name:
            return quoted_name
        else:
            return None

    def process(dirpath_rp, name, list):
        new_name = requote(name)
        if new_name:
            if list:
                list.remove(name)
                list.append(new_name)
            name_rp = dirpath_rp.append(name)
            new_rp = dirpath_rp.append(new_name)
            log.Log("Re-quoting %s to %s" % (name_rp.path, new_rp.path), 5)
            rpath.move(name_rp, new_rp)

    assert rbdir.conn is Globals.local_connection
    mirror_rp = rbdir.get_parent_rp()
    mirror = mirror_rp.path

    log.Log("Re-quoting repository %s" % mirror_rp.path, 3)

    try:
        os_walk = os.walk
    except AttributeError:
        os_walk = walk

    for dirpath, dirs, files in os_walk(mirror):
        dirpath_rp = mirror_rp.newpath(dirpath)

        for name in dirs: process(dirpath_rp, name, dirs)
        for name in files: process(dirpath_rp, name, None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号