Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Scons多目录复制/压缩_Python_Scons - Fatal编程技术网

Python Scons多目录复制/压缩

Python Scons多目录复制/压缩,python,scons,Python,Scons,问题: 我有两个源目录,一个在“当前”目录中,另一个在其他目录中 1:C:/somedir/dir_a/[win32,win64]/[tests,documentation,a,b] 和 2:D:/projects/project_a/api/[win32,win64]/[tests,a,b,c] sconstruct@D:/projects/project\u a/sconstruct 现在,我希望将这两个目录都放在一个zip文件中,根目录为“win32”。 目录2(D:/…)的win32文件

问题:

我有两个源目录,一个在“当前”目录中,另一个在其他目录中

1:C:/somedir/dir_a/[win32,win64]/[tests,documentation,a,b]


2:D:/projects/project_a/api/[win32,win64]/[tests,a,b,c]

sconstruct@D:/projects/project\u a/sconstruct

现在,我希望将这两个目录都放在一个zip文件中,根目录为“win32”。 目录2(D:/…)的win32文件夹+内容已复制到SCON结构中,这意味着(afaik)就SCON而言,D:/projects/project_a/api/win32(或win64)已经是目标

我的尝试:

当我尝试将目录1(c:/…)复制到目录2时,它根本不会复制,因为目标已经在那里了。所以这是第一次尝试

第二次尝试时,我使用env.Zip在一个Zip中获取了两个目录,这很有效,但是它们的根目录完全错误。Zip如下所示:

zip..somedir/dir_a/win32/[tests, documentation, a, b]
   |.api/win32/[tests, a, b, c]
在我想要的地方:

zip..win32/[tests, documentation, a, b, c]

在SCON中是否有适当的方法可以做到这一点?

找到了解决方案:

大家好

为我遇到的无根复制树问题找到了合适的解决方案

使用找到的累加器@

那么就叫它:

target = "dir where you want to copy contents of source"
basedir = "source dir containing content to be copied"
env.Accumulate(target, [os.path.join(basedir ,x) for x in os.listdir(basedir)])
希望这能帮助将来遇到类似问题的其他人:)