[pitivi: 6/14] Remove ObjectFactory.displayname. YAGNI.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi: 6/14] Remove ObjectFactory.displayname. YAGNI.
- Date: Wed, 24 Jun 2009 13:10:45 +0000 (UTC)
commit 4215225a2f334c69bafeb846d26db2c97fbd7eb9
Author: Alessandro Decina <alessandro d gmail com>
Date: Fri Jun 19 16:51:27 2009 +0200
Remove ObjectFactory.displayname. YAGNI.
pitivi/device.py | 20 ++++++++------------
pitivi/factories/base.py | 33 +++++++++++++++------------------
pitivi/factories/file.py | 7 +++----
pitivi/factories/timeline.py | 2 +-
pitivi/ui/sourcelist.py | 2 +-
pitivi/ui/webcam_managerdialog.py | 2 +-
tests/test_factories_base.py | 14 +++++++-------
tests/test_factories_file.py | 4 ++--
8 files changed, 38 insertions(+), 46 deletions(-)
---
diff --git a/pitivi/device.py b/pitivi/device.py
index 5020f55..361aac0 100644
--- a/pitivi/device.py
+++ b/pitivi/device.py
@@ -185,8 +185,7 @@ class HalDeviceProbe(DeviceProbe):
if devobject.QueryCapability("video4linux"):
location = devobject.GetProperty("video4linux.device")
info = devobject.GetProperty("info.product")
- srcdev = V4LSourceDeviceFactory(device=location,
- displayname=info)
+ srcdev = V4LSourceDeviceFactory(name=info, device=location)
self.debug("Valid source %r", dev)
self._sources['video'][device_udi] = srcdev
self.emit("device-added", srcdev)
@@ -198,15 +197,14 @@ class HalDeviceProbe(DeviceProbe):
info = devobject.GetProperty("alsa.card_id")
if alsatype == "capture":
self.debug("Valid source %r", dev)
- self._sources['audio'][device_udi] = AlsaSourceDeviceFactory(card=card,
- device=device,
- displayname=info)
+ self._sources['audio'][device_udi] = \
+ AlsaSourceDeviceFactory(name=info, card=card,
+ device=device)
self.emit("device-added", self._sources['audio'][device_udi])
elif alsatype == "playback":
self.debug("Valid sink %r", dev)
- self._sinks[device_udi] = AlsaSinkDeviceFactory(card=card,
- device=device,
- displayname=info)
+ self._sinks[device_udi] = AlsaSinkDeviceFactory(name=info,
+ card=card, device=device)
self.emit("device-added", self._sinks[device_udi])
def _deviceAddedCb(self, device_udi, *unused_args):
@@ -254,8 +252,7 @@ class AlsaSourceDeviceFactory(SourceDeviceFactory):
return alsa
def __str__(self):
- return "<%s: %s [hw:%s,%s]>" % (self.__class__.__name__,
- self.displayname or self.name,
+ return "<%s: %s [hw:%s,%s]>" % (self.__class__.__name__, self.name,
self._card, self._device)
class AlsaSinkDeviceFactory(SinkDeviceFactory):
@@ -273,8 +270,7 @@ class AlsaSinkDeviceFactory(SinkDeviceFactory):
return alsa
def __str__(self):
- return "<%s: %s [hw:%s,%s]>" % (self.__class__.__name__,
- self.displayname or self.name,
+ return "<%s: %s [hw:%s,%s]>" % (self.__class__.__name__, self.name,
self._card, self._device)
diff --git a/pitivi/factories/base.py b/pitivi/factories/base.py
index 20aebd3..c3f0649 100644
--- a/pitivi/factories/base.py
+++ b/pitivi/factories/base.py
@@ -46,8 +46,6 @@ class ObjectFactory(Signallable, Loggable):
@ivar name: Factory name.
@type name: C{str}
- @ivar displayname: Nicer name for the factory that could be used in an UI.
- @type displayname: C{str}
@ivar input_streams: List of input streams.
@type input_streams: C{list}
@ivar output_streams: List of output streams.
@@ -65,12 +63,11 @@ class ObjectFactory(Signallable, Loggable):
@type bins: List of C{gst.Bin}
"""
- def __init__(self, name="", displayname=""):
+ def __init__(self, name=""):
Loggable.__init__(self)
self.info("name:%s", name)
self.parent = None
self.name = name
- self.displayname = displayname
self.input_streams = []
self.output_streams = []
self.duration = gst.CLOCK_TIME_NONE
@@ -191,7 +188,7 @@ class ObjectFactory(Signallable, Loggable):
"""
def __str__(self):
- return "<%s: %s>" % (self.__class__.__name__, self.displayname or self.name)
+ return "<%s: %s>" % (self.__class__.__name__, self.name)
class SourceFactory(ObjectFactory):
"""
@@ -208,8 +205,8 @@ class SourceFactory(ObjectFactory):
'bin-released': ['bin']
}
- def __init__(self, name='', displayname=''):
- ObjectFactory.__init__(self, name, displayname)
+ def __init__(self, name=''):
+ ObjectFactory.__init__(self, name)
self.max_bins = -1
self.current_bins = 0
@@ -290,8 +287,8 @@ class SinkFactory(ObjectFactory):
'bin-released': ['bin']
}
- def __init__(self, name='', displayname=''):
- ObjectFactory.__init__(self, name, displayname)
+ def __init__(self, name=''):
+ ObjectFactory.__init__(self, name)
self.max_bins = -1
self.current_bins = 0
@@ -393,8 +390,8 @@ class OperationFactory(ObjectFactory):
'bin-released': ['bin']
}
- def __init__(self, name='', displayname=''):
- ObjectFactory.__init__(self, name, displayname)
+ def __init__(self, name=''):
+ ObjectFactory.__init__(self, name)
self.max_bins = -1
self.current_bins = 0
@@ -479,8 +476,8 @@ class LiveSourceFactory(SourceFactory):
timeline.
"""
- def __init__(self, name, displayname, default_duration=None):
- SourceFactory.__init__(self, name, displayname)
+ def __init__(self, name, default_duration=None):
+ SourceFactory.__init__(self, name)
if default_duration is None:
default_duration = 5 * gst.SECOND
@@ -501,12 +498,12 @@ class RandomAccessSourceFactory(SourceFactory):
@type abs_offset_length: C{int}
"""
- def __init__(self, name='', displayname='',
+ def __init__(self, name='',
offset=0, offset_length=gst.CLOCK_TIME_NONE):
self.offset = offset
self.offset_length = offset_length
- SourceFactory.__init__(self, name, displayname)
+ SourceFactory.__init__(self, name)
def _getAbsOffset(self):
if self.parent is None:
@@ -545,7 +542,7 @@ class URISourceFactoryMixin(object):
def __init__(self, uri):
self.uri = uri
- self.displayname = os.path.basename(unquote(uri))
+ self.name = os.path.basename(unquote(uri))
def _makeBin(self, output_stream):
if output_stream is None:
@@ -640,6 +637,6 @@ class LiveURISourceFactory(URISourceFactoryMixin, LiveSourceFactory):
@see L{LiveSourceFactory}.
"""
- def __init__(self, uri, name='', displayname='', default_duration=None):
+ def __init__(self, uri, name='', default_duration=None):
URISourceFactoryMixin.__init__(self, uri)
- LiveSourceFactory.__init__(self, name, displayname, default_duration)
+ LiveSourceFactory.__init__(self, name, default_duration)
diff --git a/pitivi/factories/file.py b/pitivi/factories/file.py
index 1adc4a9..563421b 100644
--- a/pitivi/factories/file.py
+++ b/pitivi/factories/file.py
@@ -36,12 +36,11 @@ class FileSourceFactory(URISourceFactoryMixin, RandomAccessSourceFactory):
@see: L{RandomAccessSourceFactory}.
"""
- def __init__(self, filename, name='', displayname=''):
- name = name or filename
- displayname = displayname or os.path.basename(filename)
+ def __init__(self, filename, name=''):
+ name = name or os.path.basename(filename)
self.filename = filename
URISourceFactoryMixin.__init__(self, filename)
- RandomAccessSourceFactory.__init__(self, name, displayname)
+ RandomAccessSourceFactory.__init__(self, name)
def _releaseBin(self, bin):
self.debug("releasing %r", bin)
diff --git a/pitivi/factories/timeline.py b/pitivi/factories/timeline.py
index 5a8547e..18dc371 100644
--- a/pitivi/factories/timeline.py
+++ b/pitivi/factories/timeline.py
@@ -59,7 +59,7 @@ gobject.type_register(FixSeekStart)
class TimelineSourceFactory(SourceFactory):
def __init__(self, timeline):
- SourceFactory.__init__(self, 'timeline', 'timeline')
+ SourceFactory.__init__(self, 'timeline')
self.bin = gst.Bin()
self.max_bins = 1
self.timeline = timeline
diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index 40e3e78..13df07f 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -119,7 +119,7 @@ def beautify_factory(factory):
streams = factory.getOutputStreams()
streams.sort(key=stream_sort_key)
- return ("<b>" + escape(unquote(factory.displayname)) + "</b>\n" +
+ return ("<b>" + escape(unquote(factory.name)) + "</b>\n" +
"\n".join((beautify_stream(stream) for stream in streams)))
class SourceList(gtk.VBox, Loggable):
diff --git a/pitivi/ui/webcam_managerdialog.py b/pitivi/ui/webcam_managerdialog.py
index f2569c5..e66c0ba 100644
--- a/pitivi/ui/webcam_managerdialog.py
+++ b/pitivi/ui/webcam_managerdialog.py
@@ -220,7 +220,7 @@ class WebcamManagerDialog(GladeWindow):
return
model.clear()
for dev in devices:
- model.append([dev.displayname, dev])
+ model.append([dev.name, dev])
def _updateAudioCombo(self):
self._updateCombo(self._adevcombo,
diff --git a/tests/test_factories_base.py b/tests/test_factories_base.py
index 4df81a7..6a3a1b6 100644
--- a/tests/test_factories_base.py
+++ b/tests/test_factories_base.py
@@ -31,7 +31,7 @@ from common import SignalMonitor, TestCase
class TestObjectFactory(TestCase):
def setUp(self):
TestCase.setUp(self)
- self.factory = ObjectFactory('name', 'displayname')
+ self.factory = ObjectFactory('name')
def tearDown(self):
self.factory = None
@@ -47,7 +47,7 @@ class TestObjectFactory(TestCase):
self.failUnlessEqual(self.factory.icon, 'icon')
# icon is inherited from parents
- factory1 = ObjectFactory('name', 'displayname')
+ factory1 = ObjectFactory('name')
self.failUnlessEqual(factory1.icon, None)
factory1.parent = self.factory
self.failUnlessEqual(factory1.icon, 'icon')
@@ -76,7 +76,7 @@ class StubSourceFactory(SourceFactory):
class TestSourceFactory(TestCase):
def setUp(self):
TestCase.setUp(self)
- self.factory = StubSourceFactory('name', 'displayname')
+ self.factory = StubSourceFactory('name')
caps = gst.Caps('video/x-raw-rgb')
self.stream = VideoStream(caps, pad_name='src0')
# source factories can't have input streams
@@ -122,19 +122,19 @@ class TestSourceFactory(TestCase):
class TestLiveSourceFactory(TestCase):
def testDefaultDuration(self):
# pass an explicit default_duration
- factory = LiveSourceFactory('name', 'displayname', 10 * gst.SECOND)
+ factory = LiveSourceFactory('name', 10 * gst.SECOND)
self.failUnlessEqual(factory.default_duration, 10 * gst.SECOND)
# check that if a LiveSourceFactory derived class doesn't pass a
# default_duration it's still set to 5 seconds
- factory = LiveSourceFactory('name', 'displayname')
+ factory = LiveSourceFactory('name')
self.failUnlessEqual(factory.duration, gst.CLOCK_TIME_NONE)
self.failUnlessEqual(factory.default_duration, 5 * gst.SECOND)
class TestRandomAccessSourceFactory(TestCase):
def testOffsetAndLength(self):
# no offset and length
- factory = RandomAccessSourceFactory('name', 'displayname')
+ factory = RandomAccessSourceFactory('name')
self.failUnlessEqual(factory.offset, 0)
self.failUnlessEqual(factory.offset_length, gst.CLOCK_TIME_NONE)
self.failUnlessEqual(factory.abs_offset, 0)
@@ -149,7 +149,7 @@ class TestRandomAccessSourceFactory(TestCase):
self.failUnlessEqual(factory.abs_offset_length, 10 * gst.SECOND)
# parent offset
- relative = RandomAccessSourceFactory('name1', 'displayname1')
+ relative = RandomAccessSourceFactory('name1')
relative.parent = factory
self.failUnlessEqual(relative.offset, 0)
self.failUnlessEqual(relative.offset_length, gst.CLOCK_TIME_NONE)
diff --git a/tests/test_factories_file.py b/tests/test_factories_file.py
index 097517e..3393fca 100644
--- a/tests/test_factories_file.py
+++ b/tests/test_factories_file.py
@@ -48,7 +48,7 @@ class TestFileSourceFactory(TestCase):
def testFileSourceFilename(self):
self.failUnlessEqual(self.factory.filename, 'file:///path/to/file')
- self.failUnlessEqual(self.factory.displayname, 'file')
+ self.failUnlessEqual(self.factory.name, 'file')
def testDefaultMakeBin(self):
# the default bin for FileSource is a bin containing decodebin
@@ -100,7 +100,7 @@ class TestPictureFileSourceFactory(TestCase):
def testFileSourceFilename(self):
self.failUnlessEqual(self.factory.filename, 'file:///path/to/file')
- self.failUnlessEqual(self.factory.displayname, 'file')
+ self.failUnlessEqual(self.factory.name, 'file')
def testDefaultMakeBin(self):
# the default bin for FileSource is a bin containing decodebin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]