Changeset 3436 for pkpgcounter/trunk/pkpgpdls/bj.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/bj.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/>. … … 30 30 """A parser for Canon BJ documents.""" 31 31 format = "Canon BJ/BJC" 32 def isValid(self) : 32 def isValid(self) : 33 33 """Returns True if data is BJ/BJC, else False.""" 34 34 if self.firstblock.startswith("\033[K\002\000") : 35 35 return True 36 else : 36 else : 37 37 return False 38 38 39 39 def getJobSize(self) : 40 40 """Counts pages in a Canon BJ document. 41 41 42 42 Algorithm by Jerome Alet. 43 43 44 44 The documentation used for this was : 45 45 46 46 ghostscript-8.60/src/gdevbj*.c 47 47 """ … … 57 57 # through the Set Initial Condition command 58 58 pageheader = minfile[pos:pos+7] 59 if pageheader in ("\033[K\002\000\000\017", 59 if pageheader in ("\033[K\002\000\000\017", 60 60 "\033[K\002\000\000\044", 61 61 "\033[K\002\000\004\044") : … … 65 65 except IndexError : # EOF ? 66 66 pass 67 finally : 67 finally : 68 68 minfile.close() # reached EOF 69 69 return pagecount