Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support python3 #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions code/libs/dvbobjects/dvbobjects/ATSC/Descriptors.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Expand All @@ -24,60 +24,61 @@

######################################################################


class rated_dimension_loop_item(DVBobject):

def pack(self):
fmt = "!BB"
return pack(fmt,
self.rating_dimension_j,
0xF0 | self.rating_value & 0xF
)

fmt = "!BB"
return pack(fmt,
self.rating_dimension_j,
0xF0 | self.rating_value & 0xF
)

######################################################################


class rating_region_loop_item(DVBobject):

def pack(self):

self.rated_dimensions = len(self.rated_dimension_loop)

data_bytes = string.join(
map(lambda x: x.pack(),
self.rated_dimension_loop),
"")

rating_description_bytes = self.rating_description_text.pack()

fmt = "!BB%dsB%ds" % (len(data_bytes), len(rating_description_bytes))
return pack(fmt,
self.rating_region,
self.rated_dimensions,
data_bytes,
len(rating_description_bytes),
rating_description_bytes
)

self.rated_dimensions = len(self.rated_dimension_loop)

data_bytes = b"".join(
[x.pack() for x in self.rated_dimension_loop])

rating_description_bytes = self.rating_description_text.pack()

fmt = "!BB%dsB%ds" % (len(data_bytes), len(rating_description_bytes))
return pack(fmt,
self.rating_region,
self.rated_dimensions,
data_bytes,
len(rating_description_bytes),
rating_description_bytes
)

######################################################################


class content_advisory_descriptor(Descriptor):

descriptor_tag = 0x87

def bytes(self):
self.rating_region_count = len(self.rating_region_loop)
data_bytes = string.join(
map(lambda x: x.pack(),
self.rating_region_loop),
"")

fmt = "!B%ds" % len(data_bytes)
return pack(fmt,
(0x3 << 6) | (self.rating_region_count & 0x3F),
data_bytes,
)
self.rating_region_count = len(self.rating_region_loop)
data_bytes = b"".join(
[x.pack() for x in self.rating_region_loop])

fmt = "!B%ds" % len(data_bytes)
return pack(fmt,
(0x3 << 6) | (self.rating_region_count & 0x3F),
data_bytes,
)

######################################################################


class AC3_audio_stream_descriptor(Descriptor):

descriptor_tag = 0x81

74 changes: 34 additions & 40 deletions code/libs/dvbobjects/dvbobjects/ATSC/Loops.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Expand All @@ -22,59 +22,53 @@

######################################################################


class segment_loop_item(DVBobject):

def pack(self):

fmt = "!BBB%ds" % len(self.compressed_string)
return pack(fmt,
self.compression_type,
self.mode,
len(self.compressed_string),
self.compressed_string,
)

fmt = "!BBB%ds" % len(self.compressed_string)
return pack(fmt,
self.compression_type,
self.mode,
len(self.compressed_string),
self.compressed_string,
)


######################################################################

class string_loop_item(DVBobject):

def pack(self):
assert len(self.ISO639_language_code) == 3

data_bytes = string.join(
map(lambda x: x.pack(),
self.segment_loop),
"")

self.number_segments = len(self.segment_loop)

fmt = "!%dsB%ds" % (len(self.ISO639_language_code), len(data_bytes))
return pack(fmt,
self.ISO639_language_code,
self.number_segments,
data_bytes
)
assert len(self.ISO639_language_code) == 3

data_bytes = b"".join(
[x.pack() for x in self.segment_loop])

self.number_segments = len(self.segment_loop)

fmt = "!%dsB%ds" % (len(self.ISO639_language_code), len(data_bytes))
return pack(fmt,
self.ISO639_language_code,
self.number_segments,
data_bytes
)


######################################################################

class multiple_string_structure(DVBobject):

def pack(self):


data_bytes = string.join(
map(lambda x: x.pack(),
self.string_loop),
"")

self.number_strings = len(self.string_loop)

fmt = "!B%ds" % len(data_bytes)
return pack(fmt,
self.number_strings,
data_bytes,
)


data_bytes = b"".join(
[x.pack() for x in self.string_loop])

self.number_strings = len(self.string_loop)

fmt = "!B%ds" % len(data_bytes)
return pack(fmt,
self.number_strings,
data_bytes,
)
3 changes: 1 addition & 2 deletions code/libs/dvbobjects/dvbobjects/ATSC/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

# This file is part of the dvbobjects library.
#
#
# Copyright 2013, [email protected] Lorenzo Pallara
#
# This program is free software; you can redistribute it and/or modify
Expand All @@ -17,4 +17,3 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

57 changes: 32 additions & 25 deletions code/libs/dvbobjects/dvbobjects/DSMCC/BIOP/Binding.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#! /usr/bin/env python

# This file is part of the dvbobjects library.
#
#
# Copyright 2000-2001, GMD, Sankt Augustin
# -- German National Research Center for Information Technology
# -- German National Research Center for Information Technology
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -21,18 +21,20 @@

from dvbobjects.utils import *

BINDING_TYPE_NOBJECT = 0x01
BINDING_TYPE_NOBJECT = 0x01
BINDING_TYPE_NCONTEXT = 0x02

######################################################################


class Binding(DVBobject):

nameComponents_count = 1 # DVB

def __init__(self, **kwargs):

# Initialize SuperClass
apply(DVBobject.__init__, (self,), kwargs)
DVBobject.__init__(*(self,), **kwargs)

assert self.bindingType in ( # DVB
BINDING_TYPE_NOBJECT,
Expand All @@ -50,49 +52,53 @@ def pack(self):
"B" # bindingType
"%ds" # IOP::IOR()
"H%ds" # objectInfo
) % (
) % (
len(self.nameId),
len(self.nameKind),
len(ior),
len(self.objectInfo),
)
)

return pack(
FMT,
self.nameComponents_count,
len(self.nameId),
self.nameId,
len(self.nameKind),
self.nameKind,
len(self.nameId),
self.nameId,
len(self.nameKind),
self.nameKind,
self.bindingType,
ior,
len(self.objectInfo),
self.objectInfo,
)
len(self.objectInfo),
self.objectInfo,
)

def __repr__(self):
"""Overrides DVBobject.__repr_, which is noooiiisy"""
loc = self.IOR.profile.objectLocation
mod = loc.moduleId
key = loc.objectKey
return `(self.nameId,
(mod, key),
)`
return repr((self.nameId,
(mod, key),
))

######################################################################


class ObjectFileBinding(Binding):

bindingType = BINDING_TYPE_NOBJECT
nameKind = CDR("fil")

def __init__(self, **kwargs):

# Initialize SuperClass
apply(Binding.__init__, (self,), kwargs)
Binding.__init__(*(self,), **kwargs)

self.objectInfo = pack("!LL", 0, self.contentSize)

self.objectInfo = pack("!LL", 0, self.contentSize)

######################################################################


class ObjectStreamEventBinding(Binding):

bindingType = BINDING_TYPE_NOBJECT
Expand All @@ -102,17 +108,18 @@ class ObjectStreamEventBinding(Binding):
def __init__(self, **kwargs):

# Initialize SuperClass
apply(Binding.__init__, (self,), kwargs)
Binding.__init__(*(self,), **kwargs)

######################################################################


class ContextBinding(Binding):

bindingType = BINDING_TYPE_NCONTEXT
nameKind = CDR("dir") # MHP
objectInfo = "" # MHP
nameKind = CDR("dir") # MHP
objectInfo = "" # MHP

def __init__(self, **kwargs):

# Initialize SuperClass
apply(Binding.__init__, (self,), kwargs)

Binding.__init__(*(self,), **kwargs)
Loading