Changeset 3436 for pkpgcounter/trunk/pkpgpdls/escpages03.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/escpages03.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/>. … … 33 33 """A parser for ESC/PageS03 documents.""" 34 34 format = "ESC/PageS03" 35 def isValid(self) : 35 def isValid(self) : 36 36 """Returns True if data is TIFF, else False.""" 37 37 if self.firstblock.startswith("\033\1@EJL") and \ 38 38 (self.firstblock.find("=ESC/PAGES03\n") != -1) : 39 39 return True 40 else : 40 else : 41 41 return False 42 42 43 43 def getJobSize(self) : 44 44 """Counts pages in an ESC/PageS03 document. 45 45 46 46 Algorithm by Jerome Alet. 47 47 Reverse engineered the file format. … … 61 61 lgendsequence = len(endsequence) 62 62 try : 63 try : 63 try : 64 64 while True : 65 65 if minfile[startpos] == startsequence : … … 82 82 if pagecount.startswith('"') and pagecount.endswith('"') : 83 83 pagecount = pagecount[1:-1] 84 pagecount = int(pagecount) 84 pagecount = int(pagecount) 85 85 if pagecount <= 0 : 86 86 pagecount = 1 # TODO : 0 or 1000000 ??? ;-) 87 87 break 88 startpos += 1 89 except IndexError : 88 startpos += 1 89 except IndexError : 90 90 pass 91 finally : 91 finally : 92 92 minfile.close() 93 93 return pagecount