Changeset 551
- Timestamp:
- 12/09/07 14:32:54 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/pnmascii.py
r548 r551 36 36 If it's impossible to find one we consider it's not plain text. 37 37 """ 38 if (self.firstblock [:2] in ("P1", "P2", "P3")) :38 if (self.firstblock.split()[0] in ("P1", "P2", "P3")) : 39 39 self.logdebug("DEBUG: Input file seems to be in the PNM (ascii) format.") 40 40 self.marker = self.firstblock[:2] … … 46 46 """Counts pages in a PNM (ascii) document.""" 47 47 pagecount = 0 48 linecount = 0 49 divby = 1 48 50 marker = self.marker 49 51 for line in self.infile : 52 linecount += 1 53 if (linecount == 2) and (line.find("device=pksm") != -1) : 54 # Special case of cmyk map 55 divby = 4 50 56 pagecount += line.split().count(marker) 51 return pagecount 57 58 if not (pagecount % divby) : 59 return pagecount // divby 60 else : 61 return pagecount