Changeset 3436 for pkpgcounter/trunk/pkpgpdls/hbp.py
- Timestamp:
- 10/06/08 00:22:07 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/hbp.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/>. … … 32 32 """A parser for HBP documents.""" 33 33 format = "Brother HBP" 34 def isValid(self) : 34 def isValid(self) : 35 35 """Returns True if data is HBP, else False.""" 36 36 if self.firstblock.find("@PJL ENTER LANGUAGE = HBP\n") != -1 : 37 37 return True 38 else : 38 else : 39 39 return False 40 40 41 41 def getJobSize(self) : 42 42 """Counts pages in a HBP document. 43 43 44 44 Algorithm by Jerome Alet. 45 45 46 46 The documentation used for this was : 47 47 48 48 http://sf.net/projects/hbp-for-brother/ 49 49 50 50 IMPORTANT : this may not work since @F should be sufficient, 51 51 but the documentation really is unclear and I don't know … … 55 55 minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED) 56 56 pagecount = 0 57 57 58 58 formfeed = "@G" + chr(0) + chr(0) + chr(1) + chr(0xff) + "@F" 59 59 fflen = len(formfeed) … … 66 66 pagecount += 1 67 67 pos += fflen 68 else : 68 else : 69 69 pos += 1 70 70 except IndexError : # EOF ? 71 71 pass 72 finally : 72 finally : 73 73 minfile.close() # reached EOF 74 74 return pagecount