Removed _file_size attribute, it's unneeded.

This commit is contained in:
John Evans 2013-07-17 06:26:33 -04:00
commit b5331ce36e
2 changed files with 2 additions and 6 deletions

View file

@ -16,6 +16,7 @@ References
import copy import copy
import datetime import datetime
import math import math
import os
import pprint import pprint
import struct import struct
import sys import sys
@ -73,9 +74,6 @@ class Jp2kBox(object):
self.offset = offset self.offset = offset
self.longname = longname self.longname = longname
# should never be used except maybe for last box in file.
self._file_size = -1
def __str__(self): def __str__(self):
msg = "{0} Box ({1})".format(self.longname, self.box_id) msg = "{0} Box ({1})".format(self.longname, self.box_id)
msg += " @ ({0}, {1})".format(self.offset, self.length) msg += " @ ({0}, {1})".format(self.offset, self.length)
@ -118,7 +116,7 @@ class Jp2kBox(object):
if box_length == 0: if box_length == 0:
# The length of the box is presumed to last until the end of # The length of the box is presumed to last until the end of
# the file. Compute the effective length of the box. # the file. Compute the effective length of the box.
num_bytes = self._file_size - fptr.tell() + 8 num_bytes = os.path.getsize(fptr.name) - fptr.tell() + 8
elif box_length == 1: elif box_length == 1:
# The length of the box is in the XL field, a 64-bit value. # The length of the box is in the XL field, a 64-bit value.

View file

@ -101,7 +101,6 @@ class Jp2k(Jp2kBox):
self.mode = mode self.mode = mode
self.box = [] self.box = []
self._codec_format = None self._codec_format = None
self._file_size = 0
# Parse the file for JP2/JPX contents only if we are reading it. # Parse the file for JP2/JPX contents only if we are reading it.
if mode == 'rb': if mode == 'rb':
@ -126,7 +125,6 @@ class Jp2k(Jp2kBox):
The file was not JPEG 2000. The file was not JPEG 2000.
""" """
self.length = os.path.getsize(self.filename) self.length = os.path.getsize(self.filename)
self._file_size = os.path.getsize(self.filename)
with open(self.filename, 'rb') as fptr: with open(self.filename, 'rb') as fptr: