tarfile ve zipfile global'da import edilmeli,
veya __init__ içerisinde
import module
self.module = module
şeklinde tanımlanıp daha sonra self.module.function() şeklinde çağırılmalı. Ama bana hoş gözükmedi...
This commit is contained in:
+3
-3
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#standart lisbrary modules
|
#standart lisbrary modules
|
||||||
import os, sys
|
import os, sys
|
||||||
|
import tarfile
|
||||||
|
import zipfile
|
||||||
|
|
||||||
#pisi modules
|
#pisi modules
|
||||||
import config
|
import config
|
||||||
@@ -15,7 +17,6 @@ class ArchiveBase(object):
|
|||||||
|
|
||||||
class ArchiveTarFile(ArchiveBase):
|
class ArchiveTarFile(ArchiveBase):
|
||||||
def __init__(self, fileName, type):
|
def __init__(self, fileName, type):
|
||||||
import tarfile
|
|
||||||
super(ArchiveTarFile, self).__init__(fileName, type)
|
super(ArchiveTarFile, self).__init__(fileName, type)
|
||||||
|
|
||||||
def unpack(self):
|
def unpack(self):
|
||||||
@@ -27,11 +28,10 @@ class ArchiveTarFile(ArchiveBase):
|
|||||||
|
|
||||||
class ArchiveZip(ArchiveBase):
|
class ArchiveZip(ArchiveBase):
|
||||||
def __init__(self, fileName, type):
|
def __init__(self, fileName, type):
|
||||||
import zipfile
|
|
||||||
super(ArchiveZip, self).__init__(fileName, type)
|
super(ArchiveZip, self).__init__(fileName, type)
|
||||||
|
|
||||||
def unpack(self):
|
def unpack(self):
|
||||||
zip = zipfile.Zipfile(config.archives_dir() + '/' + self.fileName, 'r')
|
zip = zipfile.ZipFile(config.archives_dir() + '/' + self.fileName, 'r')
|
||||||
fileNames = zip.namelist()
|
fileNames = zip.namelist()
|
||||||
for file in fileNames:
|
for file in fileNames:
|
||||||
file = config.archives_dir() + '/' + file
|
file = config.archives_dir() + '/' + file
|
||||||
|
|||||||
Reference in New Issue
Block a user