|
a/src/filters/rclzip |
|
b/src/filters/rclzip |
|
... |
|
... |
65 |
ipath = ipath.encode("utf-8")
|
65 |
ipath = ipath.encode("utf-8")
|
66 |
return (ok, docdata, ipath, iseof)
|
66 |
return (ok, docdata, ipath, iseof)
|
67 |
|
67 |
|
68 |
###### File type handler api, used by rclexecm ---------->
|
68 |
###### File type handler api, used by rclexecm ---------->
|
69 |
def openfile(self, params):
|
69 |
def openfile(self, params):
|
70 |
self.currentindex = 0
|
70 |
self.currentindex = -1
|
71 |
try:
|
71 |
try:
|
72 |
self.zip = ZipFile(params["filename:"])
|
72 |
self.zip = ZipFile(params["filename:"])
|
73 |
return True
|
73 |
return True
|
74 |
except:
|
74 |
except:
|
75 |
return False
|
75 |
return False
|
|
... |
|
... |
85 |
return self.extractone(ipath)
|
85 |
return self.extractone(ipath)
|
86 |
except Exception, err:
|
86 |
except Exception, err:
|
87 |
return (ok, data, ipath, eof)
|
87 |
return (ok, data, ipath, eof)
|
88 |
|
88 |
|
89 |
def getnext(self, params):
|
89 |
def getnext(self, params):
|
|
|
90 |
if self.currentindex == -1:
|
|
|
91 |
# Return "self" doc
|
|
|
92 |
self.currentindex = 0
|
|
|
93 |
self.em.setmimetype('text/plain')
|
|
|
94 |
if len(self.zip.namelist()) == 0:
|
|
|
95 |
eof = rclexecm.RclExecM.eofnext
|
|
|
96 |
else:
|
|
|
97 |
eof = rclexecm.RclExecM.noteof
|
|
|
98 |
return (True, "", "", eof)
|
|
|
99 |
|
90 |
if self.currentindex >= len(self.zip.namelist()):
|
100 |
if self.currentindex >= len(self.zip.namelist()):
|
91 |
#self.em.rclog("getnext: EOF hit")
|
101 |
#self.em.rclog("getnext: EOF hit")
|
92 |
return (False, "", "", rclexecm.RclExecM.eofnow)
|
102 |
return (False, "", "", rclexecm.RclExecM.eofnow)
|
93 |
else:
|
103 |
else:
|
94 |
ret= self.extractone(self.zip.namelist()[self.currentindex])
|
104 |
ret= self.extractone(self.zip.namelist()[self.currentindex])
|