mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 19:21:06 +00:00
python: auto-pep8 whitespace issues in overrides
Needed because the next commit edits this file. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4753>
This commit is contained in:
parent
ca4762168f
commit
62951ed379
1 changed files with 70 additions and 9 deletions
|
@ -53,9 +53,11 @@ python module to use with Gst 0.10"
|
|||
class URIHandler(Gst.URIHandler):
|
||||
pass
|
||||
|
||||
|
||||
URIHandler = override(URIHandler)
|
||||
__all__.append('URIHandler')
|
||||
|
||||
|
||||
class Element(Gst.Element):
|
||||
@staticmethod
|
||||
def link_many(*args):
|
||||
|
@ -67,6 +69,7 @@ class Element(Gst.Element):
|
|||
raise LinkError(
|
||||
'Failed to link {} and {}'.format(pair[0], pair[1]))
|
||||
|
||||
|
||||
Element = override(Element)
|
||||
__all__.append('Element')
|
||||
|
||||
|
@ -95,6 +98,7 @@ class Bin(Gst.Bin):
|
|||
Bin = override(Bin)
|
||||
__all__.append('Bin')
|
||||
|
||||
|
||||
class Caps(Gst.Caps):
|
||||
|
||||
def __nonzero__(self):
|
||||
|
@ -135,9 +139,11 @@ class Caps(Gst.Caps):
|
|||
def __len__(self):
|
||||
return self.get_size()
|
||||
|
||||
|
||||
Caps = override(Caps)
|
||||
__all__.append('Caps')
|
||||
|
||||
|
||||
class PadFunc:
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
|
@ -159,6 +165,7 @@ class PadFunc:
|
|||
|
||||
return res
|
||||
|
||||
|
||||
class Pad(Gst.Pad):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Gst.Pad, self).__init__(*args, **kwargs)
|
||||
|
@ -197,9 +204,11 @@ class Pad(Gst.Pad):
|
|||
raise LinkError(ret)
|
||||
return ret
|
||||
|
||||
|
||||
Pad = override(Pad)
|
||||
__all__.append('Pad')
|
||||
|
||||
|
||||
class GhostPad(Gst.GhostPad):
|
||||
def __init__(self, name, target=None, direction=None):
|
||||
if direction is None:
|
||||
|
@ -216,23 +225,36 @@ class GhostPad(Gst.GhostPad):
|
|||
def query_caps(self, filter=None):
|
||||
return Gst.GhostPad.query_caps(self, filter)
|
||||
|
||||
|
||||
GhostPad = override(GhostPad)
|
||||
__all__.append('GhostPad')
|
||||
|
||||
|
||||
class IteratorError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
__all__.append('IteratorError')
|
||||
|
||||
|
||||
class AddError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
__all__.append('AddError')
|
||||
|
||||
|
||||
class LinkError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
__all__.append('LinkError')
|
||||
|
||||
|
||||
class MapError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
__all__.append('MapError')
|
||||
|
||||
|
||||
|
@ -248,6 +270,7 @@ class Iterator(Gst.Iterator):
|
|||
|
||||
yield value
|
||||
|
||||
|
||||
Iterator = override(Iterator)
|
||||
__all__.append('Iterator')
|
||||
|
||||
|
@ -268,13 +291,16 @@ class ElementFactory(Gst.ElementFactory):
|
|||
def make(cls, factory_name, instance_name=None):
|
||||
return Gst.ElementFactory.make(factory_name, instance_name)
|
||||
|
||||
|
||||
class Pipeline(Gst.Pipeline):
|
||||
def __init__(self, name=None):
|
||||
Gst.Pipeline.__init__(self, name=name)
|
||||
|
||||
|
||||
Pipeline = override(Pipeline)
|
||||
__all__.append('Pipeline')
|
||||
|
||||
|
||||
class Structure(Gst.Structure):
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if not args:
|
||||
|
@ -305,6 +331,7 @@ class Structure(Gst.Structure):
|
|||
|
||||
def keys(self):
|
||||
keys = set()
|
||||
|
||||
def foreach(fid, value, unused1, udata):
|
||||
keys.add(GLib.quark_to_string(fid))
|
||||
return True
|
||||
|
@ -318,12 +345,14 @@ class Structure(Gst.Structure):
|
|||
def __str__(self):
|
||||
return self.to_string()
|
||||
|
||||
|
||||
Structure = override(Structure)
|
||||
__all__.append('Structure')
|
||||
|
||||
ElementFactory = override(ElementFactory)
|
||||
__all__.append('ElementFactory')
|
||||
|
||||
|
||||
class Fraction(Gst.Fraction):
|
||||
def __init__(self, num, denom=1):
|
||||
def __gcd(a, b):
|
||||
|
@ -377,7 +406,7 @@ class Fraction(Gst.Fraction):
|
|||
elif isinstance(other, int):
|
||||
return Fraction(self.num * other, self.denom)
|
||||
raise TypeError("%s is not supported, use Gst.Fraction or int." %
|
||||
(type(other)))
|
||||
(type(other)))
|
||||
|
||||
__rmul__ = __mul__
|
||||
|
||||
|
@ -388,7 +417,7 @@ class Fraction(Gst.Fraction):
|
|||
elif isinstance(other, int):
|
||||
return Fraction(self.num, self.denom * other)
|
||||
return TypeError("%s is not supported, use Gst.Fraction or int." %
|
||||
(type(other)))
|
||||
(type(other)))
|
||||
|
||||
__div__ = __truediv__
|
||||
|
||||
|
@ -405,6 +434,7 @@ class Fraction(Gst.Fraction):
|
|||
def __str__(self):
|
||||
return '%d/%d' % (self.num, self.denom)
|
||||
|
||||
|
||||
Fraction = override(Fraction)
|
||||
__all__.append('Fraction')
|
||||
|
||||
|
@ -427,14 +457,14 @@ class IntRange(Gst.IntRange):
|
|||
|
||||
def __repr__(self):
|
||||
return '<Gst.IntRange [%d,%d,%d]>' % (self.range.start,
|
||||
self.range.stop, self.range.step)
|
||||
self.range.stop, self.range.step)
|
||||
|
||||
def __str__(self):
|
||||
if self.range.step == 1:
|
||||
return '[%d,%d]' % (self.range.start, self.range.stop)
|
||||
else:
|
||||
return '[%d,%d,%d]' % (self.range.start, self.range.stop,
|
||||
self.range.step)
|
||||
self.range.step)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, range):
|
||||
|
@ -443,6 +473,7 @@ class IntRange(Gst.IntRange):
|
|||
return self.range == other.range
|
||||
return False
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
IntRange = override(IntRange)
|
||||
__all__.append('IntRange')
|
||||
|
@ -466,14 +497,14 @@ class Int64Range(Gst.Int64Range):
|
|||
|
||||
def __repr__(self):
|
||||
return '<Gst.Int64Range [%d,%d,%d]>' % (self.range.start,
|
||||
self.range.stop, self.range.step)
|
||||
self.range.stop, self.range.step)
|
||||
|
||||
def __str__(self):
|
||||
if self.range.step == 1:
|
||||
return '(int64)[%d,%d]' % (self.range.start, self.range.stop)
|
||||
else:
|
||||
return '(int64)[%d,%d,%d]' % (self.range.start, self.range.stop,
|
||||
self.range.step)
|
||||
self.range.step)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, range):
|
||||
|
@ -482,6 +513,7 @@ class Int64Range(Gst.Int64Range):
|
|||
return self.range == other.range
|
||||
return False
|
||||
|
||||
|
||||
class Bitmask(Gst.Bitmask):
|
||||
def __init__(self, v):
|
||||
if not isinstance(v, int):
|
||||
|
@ -540,11 +572,12 @@ class FractionRange(Gst.FractionRange):
|
|||
|
||||
def __repr__(self):
|
||||
return '<Gst.FractionRange [%s,%s]>' % (str(self.start),
|
||||
str(self.stop))
|
||||
str(self.stop))
|
||||
|
||||
def __str__(self):
|
||||
return '(fraction)[%s,%s]' % (str(self.start), str(self.stop))
|
||||
|
||||
|
||||
FractionRange = override(FractionRange)
|
||||
__all__.append('FractionRange')
|
||||
|
||||
|
@ -563,11 +596,12 @@ class ValueArray(Gst.ValueArray):
|
|||
return len(self.array)
|
||||
|
||||
def __str__(self):
|
||||
return '<' + ','.join(map(str,self.array)) + '>'
|
||||
return '<' + ','.join(map(str, self.array)) + '>'
|
||||
|
||||
def __repr__(self):
|
||||
return '<Gst.ValueArray %s>' % (str(self))
|
||||
|
||||
|
||||
ValueArray = override(ValueArray)
|
||||
__all__.append('ValueArray')
|
||||
|
||||
|
@ -586,11 +620,12 @@ class ValueList(Gst.ValueList):
|
|||
return len(self.array)
|
||||
|
||||
def __str__(self):
|
||||
return '{' + ','.join(map(str,self.array)) + '}'
|
||||
return '{' + ','.join(map(str, self.array)) + '}'
|
||||
|
||||
def __repr__(self):
|
||||
return '<Gst.ValueList %s>' % (str(self))
|
||||
|
||||
|
||||
ValueList = override(ValueList)
|
||||
__all__.append('ValueList')
|
||||
|
||||
|
@ -602,6 +637,7 @@ def pairwise(iterable):
|
|||
next(b, None)
|
||||
return zip(a, b)
|
||||
|
||||
|
||||
class MapInfo:
|
||||
def __init__(self):
|
||||
self.memory = None
|
||||
|
@ -628,8 +664,10 @@ class MapInfo:
|
|||
if not self.__parent__.unmap(self):
|
||||
raise MapError('MappingError', 'Unmapping was not successful')
|
||||
|
||||
|
||||
__all__.append("MapInfo")
|
||||
|
||||
|
||||
class Buffer(Gst.Buffer):
|
||||
|
||||
def map_range(self, idx, length, flags):
|
||||
|
@ -650,9 +688,11 @@ class Buffer(Gst.Buffer):
|
|||
mapinfo.__parent__ = None
|
||||
return _gi_gst.buffer_override_unmap(self, mapinfo)
|
||||
|
||||
|
||||
Buffer = override(Buffer)
|
||||
__all__.append('Buffer')
|
||||
|
||||
|
||||
class Memory(Gst.Memory):
|
||||
|
||||
def map(self, flags):
|
||||
|
@ -666,9 +706,11 @@ class Memory(Gst.Memory):
|
|||
mapinfo.__parent__ = None
|
||||
return _gi_gst.memory_override_unmap(self, mapinfo)
|
||||
|
||||
|
||||
Memory = override(Memory)
|
||||
__all__.append('Memory')
|
||||
|
||||
|
||||
def TIME_ARGS(time):
|
||||
if time == Gst.CLOCK_TIME_NONE:
|
||||
return "CLOCK_TIME_NONE"
|
||||
|
@ -677,6 +719,8 @@ def TIME_ARGS(time):
|
|||
(time / (Gst.SECOND * 60)) % 60,
|
||||
(time / Gst.SECOND) % 60,
|
||||
time % Gst.SECOND)
|
||||
|
||||
|
||||
__all__.append('TIME_ARGS')
|
||||
|
||||
from gi.overrides import _gi_gst
|
||||
|
@ -694,10 +738,15 @@ Gst.fixme = _gi_gst.fixme
|
|||
Gst.memdump = _gi_gst.memdump
|
||||
|
||||
# Make sure PyGst is not usable if GStreamer has not been initialized
|
||||
|
||||
|
||||
class NotInitialized(Exception):
|
||||
pass
|
||||
|
||||
|
||||
__all__.append('NotInitialized')
|
||||
|
||||
|
||||
def fake_method(*args):
|
||||
raise NotInitialized("Please call Gst.init(argv) before using GStreamer")
|
||||
|
||||
|
@ -711,6 +760,7 @@ for cname_klass in [o for o in inspect.getmembers(Gst) if isinstance(o[1], type(
|
|||
for o in cname_klass[1].__dict__
|
||||
if isinstance(cname_klass[1].__dict__[o], type(Gst.init))]))
|
||||
|
||||
|
||||
def init_pygst():
|
||||
for fname, function in real_functions:
|
||||
if fname not in ["init", "init_check", "deinit"]:
|
||||
|
@ -729,7 +779,10 @@ def deinit_pygst():
|
|||
for mname, method in methods:
|
||||
setattr(cname_class[1], mname, fake_method)
|
||||
|
||||
|
||||
real_init = Gst.init
|
||||
|
||||
|
||||
def init(argv=None):
|
||||
init_pygst()
|
||||
|
||||
|
@ -738,9 +791,12 @@ def init(argv=None):
|
|||
|
||||
return real_init(argv)
|
||||
|
||||
|
||||
Gst.init = init
|
||||
|
||||
real_init_check = Gst.init_check
|
||||
|
||||
|
||||
def init_check(argv):
|
||||
init_pygst()
|
||||
if Gst.is_initialized():
|
||||
|
@ -748,19 +804,24 @@ def init_check(argv):
|
|||
|
||||
return real_init_check(argv)
|
||||
|
||||
|
||||
Gst.init_check = init_check
|
||||
|
||||
real_deinit = Gst.deinit
|
||||
|
||||
|
||||
def deinit():
|
||||
deinit_pygst()
|
||||
return real_deinit()
|
||||
|
||||
|
||||
def init_python():
|
||||
if not Gst.is_initialized():
|
||||
raise NotInitialized("Gst.init_python should never be called before GStreamer itself is initialized")
|
||||
|
||||
init_pygst()
|
||||
|
||||
|
||||
Gst.deinit = deinit
|
||||
Gst.init_python = init_python
|
||||
|
||||
|
|
Loading…
Reference in a new issue