Changeset 3436 for pkpgcounter/trunk/pkpgpdls/zjstream.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/zjstream.py
r3410 r3436 8 8 # the Free Software Foundation, either version 3 of the License, or 9 9 # (at your option) any later version. 10 # 10 # 11 11 # This program is distributed in the hope that it will be useful, 12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 # GNU General Public License for more details. 15 # 15 # 16 16 # You should have received a copy of the GNU General Public License 17 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 28 28 class Parser(pdlparser.PDLParser) : 29 29 """A parser for ZjStream documents.""" 30 def isValid(self) : 30 def isValid(self) : 31 31 """Returns True if data is ZjStream, else False.""" 32 32 if self.firstblock[:4] == "ZJZJ" : 33 33 self.format = "Zenographics ZjStream (little endian)" 34 34 return self.littleEndian() 35 elif self.firstblock[:4] == "JZJZ" : 35 elif self.firstblock[:4] == "JZJZ" : 36 36 self.format = "Zenographics ZjStream (big endian)" 37 37 return self.bigEndian() 38 else : 38 else : 39 39 return False 40 40 41 41 def littleEndian(self) : 42 42 """Toggles to little endianness.""" 43 43 self.unpackHeader = "<IIIHH" 44 44 return True 45 45 46 46 def bigEndian(self) : 47 47 """Toggles to big endianness.""" 48 48 self.unpackHeader = ">IIIHH" 49 49 return True 50 50 51 51 def getJobSize(self) : 52 52 """Computes the number of pages in a ZjStream document.""" … … 66 66 signature) = unpack(unpackHeader, header) 67 67 self.infile.seek(totalChunkSize - len(header), 1) 68 if chunkType == 2 : 68 if chunkType == 2 : 69 69 #self.logdebug("startPage") 70 70 startpagecount += 1 … … 74 74 #elif chunkType == 0 : 75 75 # self.logdebug("startDoc") 76 #elif chunkType == 1 : 76 #elif chunkType == 1 : 77 77 # self.logdebug("endDoc") 78 # 78 # 79 79 #self.logdebug("Chunk size : %s" % totalChunkSize) 80 80 #self.logdebug("Chunk type : 0x%08x" % chunkType) … … 85 85 except struct.error : 86 86 raise pdlparser.PDLParserError, "This file doesn't seem to be valid ZjStream datas." 87 87 88 88 # Number of endpage commands should be sufficient, 89 89 # but we never know : someone could try to cheat the printer