Changeset 491 for pkpgcounter/trunk/pkpgpdls/plain.py
- Timestamp:
- 11/20/07 00:04:09 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/plain.py
r463 r491 23 23 """This modules implements a page counter for plain text documents.""" 24 24 25 import sys26 import os27 28 25 import pdlparser 29 26 import version 30 31 27 32 28 class Parser(pdlparser.PDLParser) : … … 35 31 'a2ps --borders 0 --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 36 32 ] 33 openmode = "rU" 37 34 def isValid(self) : 38 35 """Returns True if data is plain text, else False. … … 57 54 linecount = 0 58 55 for line in self.infile : 59 if line.endswith("\n") or line.endswith("\r"):56 if line.endswith("\n") : 60 57 linecount += 1 61 58 if (linecount > pagesize) : … … 70 67 raise pdlparser.PDLParserError, "Unsupported file format. Please send the file to %s" % version.__authoremail__ 71 68 return pagecount + 1 # NB : empty files are catched in isValid() 72 73 if __name__ == "__main__" :74 pdlparser.test(Parser)