copy framework

最近研究使用脚本copy文件


def copyFiles(sourceDir, targetDir): 

    for f in os.listdir(sourceDir):

        sourceF = os.path.join(sourceDir, f)

        targetF = os.path.join(targetDir, f)

        if os.path.isfile(sourceF):

            #创建目录

            if not os.path.exists(targetDir):

                os.makedirs(targetDir)

            print(sourceF)

            print(targetF)

            #文件不存在,或者存在但是大小不同,覆盖

            if not os.path.exists(targetF) or (os.path.exists(targetF) and (os.path.getsize(targetF) != os.path.getsize(sourceF))):

                #2进制文件

                # open(targetF, "wb").write(open(sourceF, "rb").read())

                shutil.copyfile(sourceF, targetF)

        if os.path.isdir(sourceF):

            copyFiles(sourceF, targetF)

def copyFrameworks():

addressOfFrameworks = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "/Carthage/Build/iOS/Static"

if not os.path.exists(addressOfFrameworks) :

    addressOfFrameworks = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "/Carthage/Build/iOS"

f_list = os.listdir(addressOfFrameworks)

for fileNAME in f_list:

    print(fileNAME)

    if os.path.splitext(fileNAME)[1] == '.framework':

        oldname = addressOfFrameworks + "/" + fileNAME

        print(oldname)

        newname = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "/Frameworks" + "/" + fileNAME

        print(newname)

        # shutil.copyfile(oldname, newname)

        copyFiles(oldname,newname)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 常用模块 认识模块 什么是模块 什么是模块? 常见的场景:一个模块就是一个包含了python定义和声明的文件,文...
    go以恒阅读 2,170评论 0 6
  • time模块 该模块内部使⽤的时当前平台的c库 每个平台的c库⽀持的⽅法可能略有不同 时间三种格式 1.时间戳 2...
    knot98阅读 284评论 0 0
  • python获取文件上一级目录:取文件所在目录的上一级目录 os.path.abspath(os.path.joi...
    朝畫夕拾阅读 8,024评论 0 2
  • 八月和初六,日子过得像流水。但是知道你在,就好! 八月和初六,会在某个时段,说很多的话,或者某个话题重复的说,彼此...
    搬个小板凳围观阅读 139评论 0 0
  • 01 前段时间出差,在晚上的工作聚餐上认识了一位新客户,寒暄介绍之后,就开始聊工作和之后的发展方向。 在整个饭局上...
    远近先生阅读 477评论 3 6

友情链接更多精彩内容