78
78
class Fraction(Value):
79
def __init__(self, num, denom):
80
Value.__init__(self, 'fraction')
84
return '<gst.Fraction %d/%d>' % (self.num, self.denom)
79
def __init__(self, num, denom=1):
80
Value.__init__(self, 'fraction')
85
return '<gst.Fraction %d/%d>' % (self.num, self.denom)
87
def __eq__(self, other):
88
if isinstance(other, Fraction):
89
return self.num * other.denom == other.num * self.denom
92
def __ne__(self, other):
93
return not self.__eq__(other)
95
def __mul__(self, other):
96
if isinstance(other, Fraction):
97
return Fraction(self.num * other.num,
98
self.denom * other.denom)
99
elif isinstance(other, int):
100
return Fraction(self.num * other, self.denom)
105
def __div__(self, other):
106
if isinstance(other, Fraction):
107
return Fraction(self.num * other.denom,
108
self.denom * other.num)
109
elif isinstance(other, int):
110
return Fraction(self.num, self.denom * other)
113
def __rdiv__(self, other):
114
if isinstance(other, int):
115
return Fraction(self.denom * other, self.num)
119
return float(self.num) / float(self.denom)
87
123
dlsave = sys.getdlopenflags()
107
143
sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL)
108
144
from _gst import *
109
145
import interfaces
111
151
version = get_gst_version
113
153
sys.setdlopenflags(dlsave)
156
# Fixes for API cleanups that would cause an API breakage.
160
if locals().has_key("parse_bin_from_description"):
161
def gst_parse_bin_from_description(*args, **kwargs):
162
warnings.warn("gst_parse_bin_from_description() is deprecated, please use parse_bin_from_description instead",
164
return parse_bin_from_description(*args, **kwargs)
166
if locals().has_key("message_new_buffering"):
167
def gst_message_new_buffering(*args, **kwargs):
168
warnings.warn("gst_message_new_buffering() is deprecated, please use message_new_buffering() instead",
170
return message_new_buffering(*args, **kwargs)
116
172
# this restores previously installed importhooks, so we don't interfere
117
173
# with other people's module importers
118
174
# it also clears out the module completely as if it were never loaded,