~ubuntu-branches/ubuntu/lucid/pitivi/lucid

« back to all changes in this revision

Viewing changes to pitivi/pitivigstutils.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2009-05-27 14:22:49 UTC
  • mfrom: (1.2.1 upstream) (3.1.13 experimental)
  • Revision ID: james.westby@ubuntu.com-20090527142249-tj0qnkc37320ylml
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
"""
27
27
 
28
28
import gst
 
29
import gst.interfaces
 
30
import gst.audio
 
31
import gst.video
29
32
 
30
33
def fraction_float(frac):
 
34
    """ override for gst.Fraction.__float__ """
31
35
    return float(frac.num) / float(frac.denom)
32
36
 
33
37
def fraction_eq(frac, other):
 
38
    """ override for gst.Fraction.__eq__ """
34
39
    if isinstance(other, gst.Fraction):
35
40
        return frac.num * other.denom == frac.denom * other.num
36
41
    return False
37
42
 
38
43
def fraction_ne(frac, other):
 
44
    """ override for gst.Fraction.__ne__ """
39
45
    return not fraction_eq(frac, other)
40
46
 
41
47
def fraction_mul(frac, other):
 
48
    """ override for gst.Fraction.__mul__ """
42
49
    if isinstance(other, gst.Fraction):
43
50
        return gst.Fraction(frac.num * other.num,
44
51
                            frac.denom * other.denom)
49
56
    raise TypeError
50
57
 
51
58
def fraction_div(frac, other):
 
59
    """ override for gst.Fraction.__div__ """
52
60
    if isinstance(other, int):
53
61
        return frac.num / (frac.denom * other)
54
62
    if isinstance(other, float):
56
64
    return TypeError
57
65
 
58
66
def patch_gst_python():
 
67
    """ override gst.Fraction methods not available in all gst-python """
59
68
    gst.Fraction.__float__ = fraction_float
60
69
    gst.Fraction.__eq__ = fraction_eq
61
70
    gst.Fraction.__ne__ = fraction_ne