-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from KPMP/develop
merge for Release 3.0
- Loading branch information
Showing
58 changed files
with
1,167 additions
and
1,275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,6 @@ out | |
tokens | ||
**/node_modules | ||
globus_tokens | ||
__pycache__/ | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
scripts/dataPromotion/loadClinical/addPilotClinicalDataFile.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from zipfile import ZipFile | ||
import os | ||
|
||
EXCLUDED_TYPES = ['.jpg', 'metadata.json', '.DS_Store'] | ||
|
||
def is_not_excluded_type(filename: str, excludedTypes: list): | ||
for excludedType in excludedTypes: | ||
|
||
if filename.lower().endswith(excludedType.lower()): | ||
return False | ||
return True | ||
|
||
def zip_package_data(zipName: str, folderToZip: str, packageId: str): | ||
with ZipFile(zipName, 'w') as zippedPackage: | ||
for root, dir, files in os.walk(folderToZip): | ||
for filename in files: | ||
if is_not_excluded_type(filename, EXCLUDED_TYPES): | ||
zippedPackage.write(folderToZip+'/'+filename, 'package_'+packageId+'/'+filename) | ||
|
||
def zip_package_cleanup(zipName: str): | ||
os.remove(zipName) | ||
|
||
if __name__ == "__main__": | ||
zip_package_data('packageid_lipidomics.zip', 'folder-to-zip/', 'packageid') |
54 changes: 54 additions & 0 deletions
54
scripts/dataPromotion/package_zipper/test_packageZipper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from fileinput import filename | ||
import os | ||
import unittest | ||
import packageZipper | ||
import shutil | ||
from os.path import exists | ||
|
||
class TestZipperMethods(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(self): | ||
print('setUpClass') | ||
if os.path.isdir('test-folder-to-zip/'): | ||
shutil.rmtree('test-folder-to-zip/') | ||
os.mkdir('test-folder-to-zip/') | ||
os.mkdir('test-folder-to-zip/zip-me') | ||
os.mkdir('test-folder-to-zip/zip-me/zip-me-2') | ||
|
||
with open('test-folder-to-zip/zip-me/zip-me-2/bar.txt', 'a'): | ||
os.utime('test-folder-to-zip/zip-me/zip-me-2/bar.txt', None) | ||
|
||
with open('test-folder-to-zip/zip-me/foo.txt', 'a'): | ||
os.utime('test-folder-to-zip/zip-me/foo.txt', None) | ||
|
||
@classmethod | ||
def tearDownClass(self): | ||
shutil.rmtree('test-folder-to-zip/') | ||
os.remove('packageid_lipidomics.zip') | ||
|
||
def test_valid_file(self): | ||
filename = 'abc.test' | ||
EXCLUDED_TYPES = ['.jpg', 'metadata.json'] | ||
self.assertEqual(packageZipper.is_not_excluded_type(filename, EXCLUDED_TYPES), True) | ||
|
||
def test_valid_file_with_no_excluded(self): | ||
filename = 'abc.test' | ||
EXCLUDED_TYPES = [] | ||
self.assertEqual(packageZipper.is_not_excluded_type(filename, EXCLUDED_TYPES), True) | ||
|
||
def test_invalid_jpg(self): | ||
filename = 'abc.jpg' | ||
EXCLUDED_TYPES = ['.jpg', 'metadata.json'] | ||
self.assertEqual(packageZipper.is_not_excluded_type(filename, EXCLUDED_TYPES), False) | ||
|
||
def test_invalid_metadata(self): | ||
filename = 'metadata.json' | ||
EXCLUDED_TYPES = ['.jpg', 'metadata.json'] | ||
self.assertEqual(packageZipper.is_not_excluded_type(filename, EXCLUDED_TYPES), False) | ||
|
||
def test_zip_package_data(self): | ||
packageZipper.zip_package_data('packageid_lipidomics', 'test-folder-to-zip/') | ||
self.assertEqual(exists('packageid_lipidomics.zip'), True) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.