Skip to content

Commit eb6ab84

Browse files
authored
Merge pull request #42 from Nilsty/add-tgz-archive
add tgz support to tar creation keyword
2 parents f4b2740 + 7cc7a73 commit eb6ab84

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

ArchiveLibrary/keywords.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,21 @@ def archive_should_contain_file(self, zip_file, filename):
8787

8888
self.collections.list_should_contain_value(files, filename)
8989

90-
def create_tar_from_files_in_directory(self, directory, filename, sub_directories=True):
90+
def create_tar_from_files_in_directory(self, directory, filename, sub_directories=True, tgz=False):
9191
""" Take all files in a directory and create a tar package from them
9292
9393
`directory` Path to the directory that holds our files
9494
9595
`filename` Path to our destination TAR package.
9696
97-
`sub_directories` Shall files in sub-directories be included - True by default.
97+
`sub_directories` Shall files in sub-directories be included - True by default.
98+
99+
`tgz` Creates a .tgz / .tar.gz archive (compressed tar package) instead of a regular tar - False by default.
98100
"""
99-
tar = tarfile.open(filename, "w")
101+
if tgz:
102+
tar = tarfile.open(filename, "w:gz")
103+
else:
104+
tar = tarfile.open(filename, "w")
100105

101106
files = return_files_lists(directory, sub_directories)
102107
for filepath, name in files:

ArchiveLibrary/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '0.4.1'
1+
VERSION = '0.4.2'

atests/testcase.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ Create TAR Package from files in directory
6060
Archive Should Contain File ${tarfilename} subdir${/}file3.txt
6161
Remove File ${tarfilename}
6262

63+
Create TGZ Package from files in directory
64+
${tarfilename}= set variable newTgzFile.tgz
65+
Remove File ${tarfilename}
66+
Create tar from Files in directory ${CURDIR}${/}FilesToTar ${tarfilename} tgz=True
67+
Archive Should Contain File ${tarfilename} file1.txt
68+
Archive Should Contain File ${tarfilename} file2.txt
69+
Archive Should Contain File ${tarfilename} subdir${/}file3.txt
70+
Remove File ${tarfilename}
71+
6372
Create TAR Package from files in directory, without subdirectories
6473
${tarfilename}= set variable newTarFile.tar
6574
Remove File ${tarfilename}

dev_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest

0 commit comments

Comments
 (0)