Changeset 3436 for pkpgcounter/trunk/pkpgpdls/dvi.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/dvi.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/>. … … 34 34 required = [ "dvips", "gs" ] 35 35 format = "DVI" 36 def isValid(self) : 36 def isValid(self) : 37 37 """Returns True if data is DVI, else False.""" 38 38 try : … … 40 40 and (ord(self.lastblock[-1]) == 0xdf) : 41 41 return True 42 else : 42 else : 43 43 return False 44 except IndexError : 44 except IndexError : 45 45 return False 46 46 47 47 def getJobSize(self) : 48 48 """Counts pages in a DVI document. 49 49 50 50 Algorithm by Jerome Alet. 51 51 52 52 The documentation used for this was : 53 53 54 54 http://www.math.umd.edu/~asnowden/comp-cont/dvi.html 55 55 """ … … 64 64 while minfile[pos] == eofchar : 65 65 pos -= 1 66 idbyte = minfile[pos] 66 idbyte = minfile[pos] 67 67 if idbyte != minfile[1] : 68 68 raise IndexError, "Invalid DVI file." … … 73 73 except IndexError : # EOF ? 74 74 pass 75 finally : 75 finally : 76 76 minfile.close() # reached EOF 77 77 return pagecount