小编Sab*_*ick的帖子

带有子目录的Zip目录在Robot Framework中

使用Robot Framework,我正在尝试使用一个文件和三个包含文件的子目录来压缩目录.我正在使用ArchiveLibrary和关键字在目录中创建Zip From Files.结果是一个压缩目录,其中包含顶层目录中的一个文件和三个空子文件夹.

如何调整库以便包含子文件夹的内容?

这是关键字最初定义的方式:

def create_zip_from_files_in_directory(self, directory, filename):

    ''' Take all files in a directory and create a zip package from them
    `directory` Path to the directory that holds our files
    `filename` Path to our destination ZIP package.
    '''

    if not directory.endswith("/"):
        directory = directory + "/"
    zip = zipfile.ZipFile(filename, "w")
    files = os.listdir(directory)
    for name in files:
        zip.write(directory + name, arcname=name)
    zip.close()
Run Code Online (Sandbox Code Playgroud)

链接到完整的库.

我一直在尝试os.walk,没有成功.

如何在.robot文件中使用关键字:

Zip xml file
    ${zipfilename}=    set variable    komplett.zip
    Create zip …
Run Code Online (Sandbox Code Playgroud)

python robotframework

6
推荐指数
1
解决办法
935
查看次数

标签 统计

python ×1

robotframework ×1