5 Star 27 Fork 9

Gitee 极速下载 / HBuilderX

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/dcloudio/hbuilderx-extension-docs
克隆/下载
sync.py 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
wdl 提交于 2021-08-30 14:19 . 优化 python数据同步脚本
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os
import sys
import shutil
# 当前目录
current_dir = os.path.dirname(__file__)
zh_cn_dir = os.path.join(current_dir, "zh-cn")
en_dir = os.path.join(current_dir, "en")
zh_hant_dir = os.path.join(current_dir, "zh-hant")
def findAllFile(base):
for root, ds, fs in os.walk(base):
for f in fs:
fullname = os.path.join(root, f)
yield fullname
def sync_all():
"""遍历中文目录, 如果英文目录/繁体中文目录,相应文件不存在,则复制。反之,跳过已有。
"""
zh_cn_all_files = findAllFile(zh_cn_dir)
# 同步至英文目录
for i in zh_cn_all_files:
relative_path = i.replace(zh_cn_dir + '/', '')
en_target_path = os.path.join(en_dir,relative_path)
if not os.path.exists(en_target_path):
en_target_dir = os.path.dirname(en_target_path)
if not os.path.exists(en_target_dir):
mkdir_cmd = "mkdir -p {0}".format(en_target_dir)
os.system(mkdir_cmd)
cp_cmd = "cp -pf {0} {1}".format(i,en_target_path)
os.system(cp_cmd)
# 同步至繁体中文目录
for i in zh_cn_all_files:
relative_path = i.replace(zh_cn_dir + '/', '')
zh_hant_target_path = os.path.join(zh_hant_dir,relative_path)
if not os.path.exists(zh_hant_target_path):
zh_hant_target_dir = os.path.dirname(zh_hant_target_path)
if not os.path.exists(zh_hant_target_dir):
mkdir_cmd = "mkdir -p {0}".format(zh_hant_target_dir)
os.system(mkdir_cmd)
cp_cmd = "cp -pf {0} {1}".format(i,zh_hant_target_path)
os.system(cp_cmd)
if __name__ == "__main__":
sync_all()
JavaScript
1
https://gitee.com/mirrors/HBuilderX.git
git@gitee.com:mirrors/HBuilderX.git
mirrors
HBuilderX
HBuilderX
master

搜索帮助