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 +17,19 @@ | ||
| 17 | # detalhes. | 17 | # detalhes. |
| 18 | #-------------------------------------------------------------------------- | 18 | #-------------------------------------------------------------------------- |
| 19 | 19 | ||
| 20 | +import glob | ||
| 20 | import os | 21 | import os |
| 21 | import plistlib | 22 | import plistlib |
| 23 | +import tarfile | ||
| 24 | + | ||
| 22 | import wx | 25 | import wx |
| 23 | import wx.lib.pubsub as ps | 26 | import wx.lib.pubsub as ps |
| 24 | import vtk | 27 | import vtk |
| 25 | 28 | ||
| 26 | import data.imagedata_utils as iu | 29 | import data.imagedata_utils as iu |
| 27 | import data.polydata_utils as pu | 30 | import data.polydata_utils as pu |
| 28 | - | ||
| 29 | -from utils import Singleton | ||
| 30 | from presets import Presets | 31 | from presets import Presets |
| 32 | +from utils import Singleton | ||
| 31 | import version | 33 | import version |
| 32 | 34 | ||
| 33 | class Project(object): | 35 | class Project(object): |
| @@ -195,3 +197,16 @@ class Project(object): | @@ -195,3 +197,16 @@ class Project(object): | ||
| 195 | self.max_threshold = project['max threshold'] | 197 | self.max_threshold = project['max threshold'] |
| 196 | self.window = project['window'] | 198 | self.window = project['window'] |
| 197 | self.level = project['level'] | 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 | \ No newline at end of file | 213 | \ No newline at end of file |