~ubuntu-branches/ubuntu/quantal/pitivi/quantal

« back to all changes in this revision

Viewing changes to pitivi/serializable.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2008-12-12 10:22:29 UTC
  • mfrom: (1.1.6 upstream)
  • mto: (3.2.2 jaunty) (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20081212102229-7c3etvaoy9ys0x28
Tags: upstream-0.11.3
Import upstream version 0.11.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
20
# Boston, MA 02111-1307, USA.
21
21
 
 
22
"""
 
23
Interface for object serialization
 
24
"""
 
25
 
22
26
import gst
23
27
 
24
28
class Serializable(object):
47
51
        if not obj["datatype"]:
48
52
            raise Exception("dictionnary doesn't contain the type information !!")
49
53
        if not obj["datatype"] == self.__data_type__:
50
 
            raise Exception("Mismatch in dictionnary data-type (%s) and class data-type (%s)" % (obj["datatype"],                                                                                                 self.__data_type__))
 
54
            raise Exception("Mismatch in dictionnary data-type (%s) and class data-type (%s)" % (obj["datatype"],
 
55
                                                                                                 self.__data_type__))
51
56
        return
52
57
 
53
58
 
56
61
    Returns a dictionnary of serialized classes.
57
62
    Mapping is type-name (string) => class
58
63
    """
59
 
    def get_valid_subclasses(cls):
 
64
    def __get_valid_subclasses(cls):
60
65
        res = [(cls.__data_type__, cls)]
61
66
        for i in cls.__subclasses__():
62
 
            res.extend(get_valid_subclasses(i))
 
67
            res.extend(__get_valid_subclasses(i))
63
68
        return res
64
69
 
65
 
    listclasses = get_valid_subclasses(Serializable)
 
70
    listclasses = __get_valid_subclasses(Serializable)
66
71
 
67
72
    # add a little check for duplicates here !
68
73
    check = {}
69
 
    for i,j in listclasses:
 
74
    for i, j in listclasses:
70
75
        if not i in check:
71
76
            check[i] = j
72
77
        else: