Changeset 3436 for pkpgcounter/trunk/pkpgpdls/pnmascii.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/pnmascii.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/>. … … 26 26 class Parser(pdlparser.PDLParser) : 27 27 """A parser for PNM (ascii) documents.""" 28 openmode = "rU" 28 openmode = "rU" 29 29 format = "PNM (ascii)" 30 def isValid(self) : 30 def isValid(self) : 31 31 """Returns True if data is ASCII PNM, else False.""" 32 32 if self.firstblock.split()[0] in ("P1", "P2", "P3") : 33 33 self.marker = self.firstblock[:2] 34 34 return True 35 else : 35 else : 36 36 return False 37 37 38 38 def getJobSize(self) : 39 39 """Counts pages in a PNM (ascii) document.""" … … 47 47 # Special case of cmyk map 48 48 divby = 4 49 # Unfortunately any whitespace is valid, 49 # Unfortunately any whitespace is valid, 50 50 # so we do it the slow way... 51 51 pagecount += line.split().count(marker) 52 53 if not (pagecount % divby) : 52 53 if not (pagecount % divby) : 54 54 return pagecount // divby 55 else : 55 else : 56 56 return pagecount