Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ArchiveLibrary/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def create_zip_from_files_in_directory(cls, directory, filename, sub_directories

files = return_files_lists(directory, sub_directories)
for filepath, name in files:
the_zip.write(filepath, arcname=name)
if name != os.path.basename(filename):
the_zip.write(filepath, arcname=name)

the_zip.close()

Expand Down
2 changes: 1 addition & 1 deletion ArchiveLibrary/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.4.2'
VERSION = '0.4.3'
51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# How to contribute

## Setup a development environment

1) First of all make sure to have a 3.x python version installed
2) Clone the source code:
`[email protected]:MarketSquare/robotframework-archivelibrary.git`
3) I suggest to create a python virtual environment:
```sh
cd robotframework-requests/
python -m venv venv
source venv/bin/activate
```
4) Install the library in editing mode and all the test dependencies:
`python -m pip install -e`
5) Run acceptance tests with robot:
`robot ./atests`
6) Run unit tests wiht pytest:
`pytest ./utests`

If everything went well now you're ready to go!

## Coding guidelines

Many checks and tests are automatically performed in Continuous Integration with the
GitHub Actions.

Have a look at the file `.github/workflows/python-app.yml` to see the commands used.

#### Linting

The project uses flake8 for linting the source code.

#### Unit tests

PyTest is integrated for unit tests that located in `utests/` folder.

#### Acceptance tests

Obviously for acceptance tests Robot Framework is used, files are located in `atests/`.

#### Test Coverage

Test coverage is evaluated for unit and acceptance tests, after test execution
`coverage report` command shows you the statistics.

#### Documentation

Keywords documentation (on Linux) can be updated running the following script:

`doc/generate_doc.sh`
10 changes: 10 additions & 0 deletions atests/testcase.robot
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ Create ZIP Package from files in directory and subdirectory with no compression
Archive Should Contain File ${zipfilename} subdir${/}file3.txt
Remove File ${zipfilename}

Create ZIP Package from files in same directory as files
${zipfilename}= set variable ${CURDIR}${/}FilesToTar${/}newZipFile.zip
Remove File ${zipfilename}
Create zip from Files in directory ${CURDIR}${/}FilesToTar ${zipfilename}
Archive Should Contain File ${zipfilename} file1.txt
Archive Should Contain File ${zipfilename} file2.txt
Run Keyword And Expect Error *does not contain value 'newZipFile.zip'* Archive Should Contain File ${zipfilename} newZipFile.zip
Run Keyword And Expect Error *does not contain value 'subdir${/}file3.txt'* Archive Should Contain File ${zipfilename} subdir${/}file3.txt
Remove File ${zipfilename}

Create ZIP Package from files in directory and subdirectory with compression deflated
${zipfilename}= set variable newZipFile.zip
Remove File ${zipfilename}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@
jQuery.extend({highlight:function(e,t,n,r){if(e.nodeType===3){var i=e.data.match(t);if(i){var s=document.createElement(n||"span");s.className=r||"highlight";var o=e.splitText(i.index);o.splitText(i[0].length);var u=o.cloneNode(true);s.appendChild(u);o.parentNode.replaceChild(s,o);return 1}}else if(e.nodeType===1&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&!(e.tagName===n.toUpperCase()&&e.className===r)){for(var a=0;a<e.childNodes.length;a++){a+=jQuery.highlight(e.childNodes[a],t,n,r)}}return 0}});jQuery.fn.unhighlight=function(e){var t={className:"highlight",element:"span"};jQuery.extend(t,e);return this.find(t.element+"."+t.className).each(function(){var e=this.parentNode;e.replaceChild(this.firstChild,this);e.normalize()}).end()};jQuery.fn.highlight=function(e,t){var n={className:"highlight",element:"span",caseSensitive:false,wordsOnly:false};jQuery.extend(n,t);if(e.constructor===String){e=[e]}e=jQuery.grep(e,function(e,t){return e!=""});e=jQuery.map(e,function(e,t){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")});if(e.length==0){return this}var r=n.caseSensitive?"":"i";var i="("+e.join("|")+")";if(n.wordsOnly){i="\\b"+i+"\\b"}var s=new RegExp(i,r);return this.each(function(){jQuery.highlight(this,s,n.element,n.className)})}
</script>
<script type="text/javascript">
libdoc = {"specversion": 1, "name": "ArchiveLibrary", "doc": "<p>ArchiveLibrary is a Robot Framework keyword library to handle ZIP and possibly other archive formats.</p>", "version": "", "generated": "2022-12-22T22:07:45+00:00", "type": "LIBRARY", "scope": "GLOBAL", "docFormat": "HTML", "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/__init__.py", "lineno": 8, "tags": [], "inits": [], "keywords": [{"name": "Archive Should Contain File", "args": [{"name": "zip_file", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "zip_file"}, {"name": "filename", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "filename"}], "doc": "<p>Check if a file exists in the ZIP file without extracting it</p>\n<p><span class=\"name\">zip_file</span> the path to the ZIP file</p>\n<p><span class=\"name\">filename</span> name of the file to search for in <span class=\"name\">zip_file</span></p>", "shortdoc": "Check if a file exists in the ZIP file without extracting it", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 74}, {"name": "Create Tar From Files In Directory", "args": [{"name": "directory", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "directory"}, {"name": "filename", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "filename"}, {"name": "sub_directories", "types": [], "typedocs": {}, "defaultValue": "True", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "sub_directories=True"}, {"name": "tgz", "types": [], "typedocs": {}, "defaultValue": "False", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "tgz=False"}], "doc": "<p>Take all files in a directory and create a tar package from them</p>\n<p><span class=\"name\">directory</span> Path to the directory that holds our files</p>\n<p><span class=\"name\">filename</span> Path to our destination TAR package.</p>\n<p><span class=\"name\">sub_directories</span> Shall files in sub-directories be included - True by default.</p>\n<p><span class=\"name\">tgz</span> Creates a .tgz / .tar.gz archive (compressed tar package) instead of a regular tar - False by default.</p>", "shortdoc": "Take all files in a directory and create a tar package from them", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 90}, {"name": "Create Zip From Files In Directory", "args": [{"name": "directory", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "directory"}, {"name": "filename", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "filename"}, {"name": "sub_directories", "types": [], "typedocs": {}, "defaultValue": "False", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "sub_directories=False"}, {"name": "compression", "types": [], "typedocs": {}, "defaultValue": "stored", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "compression=stored"}], "doc": "<p>Take all files in a directory and create a zip package from them</p>\n<p><span class=\"name\">directory</span> Path to the directory that holds our files</p>\n<p><span class=\"name\">filename</span> Path to our destination ZIP package.</p>\n<p><span class=\"name\">sub_directories</span> Shall files in sub-directories be included - False by default.</p>\n<p><span class=\"name\">compression</span> stored (default; no compression), deflated, bzip2 (with python &gt;= 3.3), lzma (with python &gt;= 3.3)</p>", "shortdoc": "Take all files in a directory and create a zip package from them", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 113}, {"name": "Extract Tar File", "args": [{"name": "tar_file", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "tar_file"}, {"name": "dest", "types": [], "typedocs": {}, "defaultValue": "None", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "dest=None"}], "doc": "<p>Extract a TAR file</p>\n<p><span class=\"name\">tar_file</span> the path to the TAR file</p>\n<p><span class=\"name\">dest</span> optional destination folder. Assumes current working directory if it is none It will be created if It doesn't exist.</p>", "shortdoc": "Extract a TAR file", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 57}, {"name": "Extract Zip File", "args": [{"name": "zip_file", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "zip_file"}, {"name": "dest", "types": [], "typedocs": {}, "defaultValue": "None", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "dest=None"}], "doc": "<p>Extract a ZIP file</p>\n<p><span class=\"name\">zip_file</span> the path to the ZIP file</p>\n<p><span class=\"name\">dest</span> optional destination folder. Assumes current working directory if it is none It will be created if It doesn't exist.</p>", "shortdoc": "Extract a ZIP file", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 32}], "dataTypes": {"enums": [], "typedDicts": []}, "typedocs": []}
libdoc = {"specversion": 1, "name": "ArchiveLibrary", "doc": "<p>ArchiveLibrary is a Robot Framework keyword library to handle ZIP and possibly other archive formats.</p>", "version": "", "generated": "2024-10-26T15:41:29+00:00", "type": "LIBRARY", "scope": "GLOBAL", "docFormat": "HTML", "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/__init__.py", "lineno": 8, "tags": [], "inits": [], "keywords": [{"name": "Archive Should Contain File", "args": [{"name": "zip_file", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "zip_file"}, {"name": "filename", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "filename"}], "doc": "<p>Check if a file exists in the ZIP file without extracting it</p>\n<p><span class=\"name\">zip_file</span> the path to the ZIP file</p>\n<p><span class=\"name\">filename</span> name of the file to search for in <span class=\"name\">zip_file</span></p>", "shortdoc": "Check if a file exists in the ZIP file without extracting it", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 74}, {"name": "Create Tar From Files In Directory", "args": [{"name": "directory", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "directory"}, {"name": "filename", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "filename"}, {"name": "sub_directories", "types": [], "typedocs": {}, "defaultValue": "True", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "sub_directories=True"}, {"name": "tgz", "types": [], "typedocs": {}, "defaultValue": "False", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "tgz=False"}], "doc": "<p>Take all files in a directory and create a tar package from them</p>\n<p><span class=\"name\">directory</span> Path to the directory that holds our files</p>\n<p><span class=\"name\">filename</span> Path to our destination TAR package.</p>\n<p><span class=\"name\">sub_directories</span> Shall files in sub-directories be included - True by default.</p>\n<p><span class=\"name\">tgz</span> Creates a .tgz / .tar.gz archive (compressed tar package) instead of a regular tar - False by default.</p>", "shortdoc": "Take all files in a directory and create a tar package from them", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 90}, {"name": "Create Zip From Files In Directory", "args": [{"name": "directory", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "directory"}, {"name": "filename", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "filename"}, {"name": "sub_directories", "types": [], "typedocs": {}, "defaultValue": "False", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "sub_directories=False"}, {"name": "compression", "types": [], "typedocs": {}, "defaultValue": "stored", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "compression=stored"}], "doc": "<p>Take all files in a directory and create a zip package from them</p>\n<p><span class=\"name\">directory</span> Path to the directory that holds our files</p>\n<p><span class=\"name\">filename</span> Path to our destination ZIP package.</p>\n<p><span class=\"name\">sub_directories</span> Shall files in sub-directories be included - False by default.</p>\n<p><span class=\"name\">compression</span> stored (default; no compression), deflated, bzip2 (with python &gt;= 3.3), lzma (with python &gt;= 3.3)</p>", "shortdoc": "Take all files in a directory and create a zip package from them", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 113}, {"name": "Extract Tar File", "args": [{"name": "tar_file", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "tar_file"}, {"name": "dest", "types": [], "typedocs": {}, "defaultValue": "None", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "dest=None"}], "doc": "<p>Extract a TAR file</p>\n<p><span class=\"name\">tar_file</span> the path to the TAR file</p>\n<p><span class=\"name\">dest</span> optional destination folder. Assumes current working directory if it is none It will be created if It doesn't exist.</p>", "shortdoc": "Extract a TAR file", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 57}, {"name": "Extract Zip File", "args": [{"name": "zip_file", "types": [], "typedocs": {}, "defaultValue": null, "kind": "POSITIONAL_OR_NAMED", "required": true, "repr": "zip_file"}, {"name": "dest", "types": [], "typedocs": {}, "defaultValue": "None", "kind": "POSITIONAL_OR_NAMED", "required": false, "repr": "dest=None"}], "doc": "<p>Extract a ZIP file</p>\n<p><span class=\"name\">zip_file</span> the path to the ZIP file</p>\n<p><span class=\"name\">dest</span> optional destination folder. Assumes current working directory if it is none It will be created if It doesn't exist.</p>", "shortdoc": "Extract a ZIP file", "tags": [], "source": "/Users/luca/src/robotframework/robotframework-archivelibrary/ArchiveLibrary/keywords.py", "lineno": 32}], "dataTypes": {"enums": [], "typedDicts": []}, "typedocs": []}
</script>
<title></title>
</head>
Expand Down