同步操作将从 OneOS/OneOS 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import osimport sysimport shutilimport importlibimport importlib.utilimport timeimport refrom print_helper import print_debug, print_info, print_warn, print_errordef find_soc(src, soc):soc_dir = [os.path.basename(src)]#soc_dir = ['hk32-common', 'replace', 'HK32F030', 'replace', 'TEMP_HK32F030CBT6']names = os.listdir(src)for name in names:if name == soc:soc_dir.append(name)#tools.print_debug(soc_dir)return soc_dirsrcname = os.path.join(src, name)if not os.path.isdir(srcname):continuesub_soc_dir = find_soc(srcname, soc)if len(sub_soc_dir) > 1:soc_dir.extend(sub_soc_dir)#tools.print_debug(soc_dir)return soc_dir#tools.print_debug(soc_dir)return soc_dirdef copytree(src, dst, ignore, symlinks=False):names = os.listdir(src)if not os.path.isdir(dst):os.makedirs(dst)errors = []for name in names:if isinstance(ignore, list):if name in ignore:continueelif isinstance(ignore, str):if name == ignore:continuesrcname = os.path.join(src, name)dstname = os.path.join(dst, name)try:if symlinks and os.path.islink(srcname):linkto = os.readlink(srcname)os.symlink(linkto, dstname)elif os.path.isdir(srcname):copytree(srcname, dstname, ignore, symlinks)else:if os.path.isdir(dstname):os.rmdir(dstname)elif os.path.isfile(dstname):os.remove(dstname)shutil.copy2(srcname, dstname)except (IOError, os.error) as why:errors.append((srcname, dstname, str(why)))except OSError as err:errors.extend(err.args[0])def template(source_path, g):target_path = os.path.join(source_path, 'target')for item in g:if 'TEMP_' in item:soc = itemprint_info(source_path)print_info(target_path)print_info(soc)if os.path.exists(target_path):shutil.rmtree(target_path)# find soc dirsoc_dir = find_soc(source_path, soc)print_info("soc_dir")print(soc_dir)#soc_dir = ['hk32-common', 'replace', 'HK32F030', 'replace', 'TEMP_HK32F030CBT6']if len(soc_dir) < 2:print_warn("invalid soc_dir %s" % soc_dir)return None# copy replace filesreplace_path = source_pathcopytree(replace_path, target_path, ['replace', 'generate.py'])for i in range(1, len(soc_dir)):if i % 2 == 1 and soc_dir[i] != 'replace':print_warn("invalid soc_dir %s\n""soc_dir[%d] is %s, expect 'replace'"% (soc_dir, i, soc_dir[i]))return Nonereplace_path = os.path.join(replace_path, soc_dir[i])if soc_dir[i] == 'replace':continuecopytree(replace_path, target_path, ['replace', 'generate.py'])return target_path
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。