Skip to content

Commit

Permalink
Put brackets around prints. Start of python 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Vargol committed Mar 18, 2018
1 parent 4d52153 commit 1b0905a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion spatialmedia/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def action_open(self):

if audio_metadata:
self.var_spatial_audio.set(1)
print audio_metadata.get_metadata_string()
print (audio_metadata.get_metadata_string())

self.update_state()

Expand Down
12 changes: 6 additions & 6 deletions spatialmedia/metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def get_expected_num_audio_components(ambisonics_type, ambisonics_order):

def get_num_audio_channels(stsd, in_fh):
if stsd.name != mpeg.constants.TAG_STSD:
print "get_num_audio_channels should be given a STSD box"
print ("get_num_audio_channels should be given a STSD box")
return -1
for sample_description in stsd.contents:
if sample_description.name == mpeg.constants.TAG_MP4A:
Expand Down Expand Up @@ -415,7 +415,7 @@ def get_sample_description_num_channels(sample_description, in_fh):
audio_sample_rate = struct.unpack(">d", in_fh.read(8))[0]
num_audio_channels = struct.unpack(">i", in_fh.read(4))[0]
else:
print "Unsupported version for " + sample_description.name + " box"
print ("Unsupported version for " + sample_description.name + " box")
return -1

in_fh.seek(p)
Expand Down Expand Up @@ -443,23 +443,23 @@ def get_aac_num_channels(box, in_fh):

# Verify the read descriptor is an elementary stream descriptor
if ord(descriptor_tag) != 3: # Not an MP4 elementary stream.
print "Error: failed to read elementary stream descriptor."
print ("Error: failed to read elementary stream descriptor.")
return -1
get_descriptor_length(in_fh)
in_fh.seek(3, 1) # Seek to the decoder configuration descriptor
config_descriptor_tag = struct.unpack(">c", in_fh.read(1))[0]

# Verify the read descriptor is a decoder config. descriptor.
if ord(config_descriptor_tag) != 4:
print "Error: failed to read decoder config. descriptor."
print ("Error: failed to read decoder config. descriptor.")
return -1
get_descriptor_length(in_fh)
in_fh.seek(13, 1) # offset to the decoder specific config descriptor.
decoder_specific_descriptor_tag = struct.unpack(">c", in_fh.read(1))[0]

# Verify the read descriptor is a decoder specific info descriptor
if ord(decoder_specific_descriptor_tag) != 5:
print "Error: failed to read MP4 audio decoder specific config."
print ("Error: failed to read MP4 audio decoder specific config.")
return -1
audio_specific_descriptor_size = get_descriptor_length(in_fh)
assert audio_specific_descriptor_size >= 2
Expand All @@ -469,7 +469,7 @@ def get_aac_num_channels(box, in_fh):
if sampling_frequency_index == 0:
# TODO: If the sample rate is 96kHz an additional 24 bit offset
# value here specifies the actual sample rate.
print "Error: Greater than 48khz audio is currently not supported."
print ("Error: Greater than 48khz audio is currently not supported.");
return -1
channel_configuration = (int("0078", 16) & decoder_descriptor) >> 3
in_fh.seek(p)
Expand Down
4 changes: 2 additions & 2 deletions spatialmedia/mpeg/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def load(fh, position, end):
header_size = 16

if size < 8:
print "Error, invalid size", size, "in", name, "at", position
print ("Error, invalid size", size, "in", name, "at", position)
return None

if (position + size) > end:
Expand Down Expand Up @@ -123,7 +123,7 @@ def print_structure(self, indent=""):
"""Prints the box structure."""
size1 = self.header_size
size2 = self.content_size
print "{0} {1} [{2}, {3}]".format(indent, self.name, size1, size2)
print ("{0} {1} [{2}, {3}]".format(indent, self.name, size1, size2))


def tag_copy(in_fh, out_fh, size):
Expand Down
8 changes: 4 additions & 4 deletions spatialmedia/mpeg/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def load(fh, position, end):
header_size = 16

if size < 8:
print "Error, invalid size", size, "in", name, "at", position
print ("Error, invalid size", size, "in", name, "at", position)
return None

if (position + size) > end:
print "Error: Container box size exceeds bounds."
print ("Error: Container box size exceeds bounds.")
return None

padding = 0
Expand Down Expand Up @@ -148,7 +148,7 @@ def print_structure(self, indent=""):
"""Prints the box structure and recurses on contents."""
size1 = self.header_size
size2 = self.content_size
print "{0} {1} [{2}, {3}]".format(indent, self.name, size1, size2)
print ("{0} {1} [{2}, {3}]".format(indent, self.name, size1, size2))

size = len(self.contents)
for i in range(size):
Expand Down Expand Up @@ -188,7 +188,7 @@ def add(self, element):
if content.name == element.name:
if isinstance(content, container_leaf):
return content.merge(element)
print "Error, cannot merge leafs."
print ("Error, cannot merge leafs.")
return False

self.contents.append(element)
Expand Down
6 changes: 3 additions & 3 deletions spatialmedia/mpeg/mpeg4_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def load(fh):
contents = container.load_multiple(fh, 0, size)

if not contents:
print "Error, failed to load .mp4 file."
print ("Error, failed to load .mp4 file.")
return None
elif len(contents) == 0:
print ("Error, no boxes found.")
Expand Down Expand Up @@ -98,12 +98,12 @@ def __init__(self):

def merge(self, element):
"""Mpeg4 containers do not support merging."""
print "Cannot merge mpeg4 files"
print ("Cannot merge mpeg4 files")
exit(0)

def print_structure(self):
"""Print mpeg4 file structure recursively."""
print "mpeg4 [", self.content_size, "]"
print ("mpeg4 [", self.content_size, "]")

size = len(self.contents)
for i in range(size):
Expand Down
4 changes: 2 additions & 2 deletions spatialmedia/mpeg/sa3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def load(fh, position=None, end=None):
name = fh.read(4)

if (name != constants.TAG_SA3D):
print "Error: box is not an SA3D box."
print ("Error: box is not an SA3D box.")
return None

if (position + size > end):
print "Error: SA3D box size exceeds bounds."
print ("Error: SA3D box size exceeds bounds.")
return None

new_box.content_size = size - new_box.header_size
Expand Down

0 comments on commit 1b0905a

Please sign in to comment.