Commit e22d850dadbed71b1a41dbc298e80424b13ed4cf
1 parent
4a31cb1d
Exists in
master
and in
68 other branches
ADD: Compress and extract file project
Showing
1 changed file
with
17 additions
and
2 deletions
Show diff stats
invesalius/project.py
| ... | ... | @@ -17,17 +17,19 @@ |
| 17 | 17 | # detalhes. |
| 18 | 18 | #-------------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | +import glob | |
| 20 | 21 | import os |
| 21 | 22 | import plistlib |
| 23 | +import tarfile | |
| 24 | + | |
| 22 | 25 | import wx |
| 23 | 26 | import wx.lib.pubsub as ps |
| 24 | 27 | import vtk |
| 25 | 28 | |
| 26 | 29 | import data.imagedata_utils as iu |
| 27 | 30 | import data.polydata_utils as pu |
| 28 | - | |
| 29 | -from utils import Singleton | |
| 30 | 31 | from presets import Presets |
| 32 | +from utils import Singleton | |
| 31 | 33 | import version |
| 32 | 34 | |
| 33 | 35 | class Project(object): |
| ... | ... | @@ -195,3 +197,16 @@ class Project(object): |
| 195 | 197 | self.max_threshold = project['max threshold'] |
| 196 | 198 | self.window = project['window'] |
| 197 | 199 | self.level = project['level'] |
| 200 | + | |
| 201 | +def Compress(folder, filename): | |
| 202 | + file_list = glob.glob(os.path.join(folder,"*")) | |
| 203 | + tar = tarfile.open(filename, "w:gz") | |
| 204 | + for name in file_list: | |
| 205 | + tar.add(name) | |
| 206 | + tar.close() | |
| 207 | + | |
| 208 | +def Extract(filename, folder): | |
| 209 | + tar = tarfile.open(filename, "r:gz") | |
| 210 | + tar.list(verbose=True) | |
| 211 | + tar.extractall(folder) | |
| 212 | + tar.close() | |
| 198 | 213 | \ No newline at end of file | ... | ... |