pitivi r1334 - in trunk: . docs pitivi pitivi/elements pitivi/timeline pitivi/ui



Author: edwardrv
Date: Thu Oct 16 14:21:27 2008
New Revision: 1334
URL: http://svn.gnome.org/viewvc/pitivi?rev=1334&view=rev

Log:
	* pitivi/check.py:
	* pitivi/configure.py.in:
	* pitivi/discoverer.py:
	* pitivi/effects.py:
	* pitivi/elements/imagefreeze.py:
	* pitivi/elements/singledecodebin.py:
	* pitivi/elements/smartscale.py:
	* pitivi/elements/thumbnailsink.py:
	* pitivi/elements/videofade.py:
	* pitivi/objectfactory.py:
	* pitivi/playground.py:
	* pitivi/pluginmanager.py:
	* pitivi/project.py:
	* pitivi/projectsaver.py:
	* pitivi/serializable.py:
	* pitivi/settings.py:
	* pitivi/signalgroup.py:
	* pitivi/stream.py:
	* pitivi/thumbnailer.py:
	* pitivi/timeline/composition.py:
	* pitivi/timeline/effects.py:
	* pitivi/timeline/objects.py:
	* pitivi/timeline/source.py:
	* pitivi/timeline/timeline.py:
	* pitivi/ui/complexinterface.py:
	* pitivi/ui/complexlayer.py:
	* pitivi/ui/complextimeline.py:
	* pitivi/ui/glade.py:
	* pitivi/ui/gstwidget.py:
	* pitivi/ui/mainwindow.py:
	* pitivi/ui/pluginmanagerdialog.py:
	* pitivi/ui/slider.py:
	* pitivi/ui/sourcefactories.py:
	* pitivi/ui/viewer.py:
	* pitivi/utils.py:
	Complete cleanup using pylint reporting.
	* docs/pylint.rc:
	Pylint resource file to use when checking pitivi.

Added:
   trunk/docs/pylint.rc
Modified:
   trunk/ChangeLog
   trunk/pitivi/check.py
   trunk/pitivi/configure.py.in
   trunk/pitivi/discoverer.py
   trunk/pitivi/effects.py
   trunk/pitivi/elements/imagefreeze.py
   trunk/pitivi/elements/singledecodebin.py
   trunk/pitivi/elements/smartscale.py
   trunk/pitivi/elements/thumbnailsink.py
   trunk/pitivi/elements/videofade.py
   trunk/pitivi/objectfactory.py
   trunk/pitivi/playground.py
   trunk/pitivi/pluginmanager.py
   trunk/pitivi/project.py
   trunk/pitivi/projectsaver.py
   trunk/pitivi/serializable.py
   trunk/pitivi/settings.py
   trunk/pitivi/signalgroup.py
   trunk/pitivi/stream.py
   trunk/pitivi/thumbnailer.py
   trunk/pitivi/timeline/composition.py
   trunk/pitivi/timeline/effects.py
   trunk/pitivi/timeline/objects.py
   trunk/pitivi/timeline/source.py
   trunk/pitivi/timeline/timeline.py
   trunk/pitivi/ui/complexinterface.py
   trunk/pitivi/ui/complexlayer.py
   trunk/pitivi/ui/complextimeline.py
   trunk/pitivi/ui/glade.py
   trunk/pitivi/ui/gstwidget.py
   trunk/pitivi/ui/mainwindow.py
   trunk/pitivi/ui/pluginmanagerdialog.py
   trunk/pitivi/ui/slider.py
   trunk/pitivi/ui/sourcefactories.py
   trunk/pitivi/ui/viewer.py
   trunk/pitivi/utils.py

Added: trunk/docs/pylint.rc
==============================================================================
--- (empty file)
+++ trunk/docs/pylint.rc	Thu Oct 16 14:21:27 2008
@@ -0,0 +1,309 @@
+# lint Python modules using external checkers.
+# 
+# This is the main checker controling the other ones and the reports
+# generation. It is itself both a raw checker and an astng checker in order
+# to:
+# * handle message activation / deactivation at the module level
+# * handle some basic but necessary stats'data (number of classes, methods...)
+# 
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+profile=no
+
+# Add <file or directory> to the black list. It should be a base name, not a
+# path. You may set this option multiple times.
+ignore=CVS
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# Set the cache size for astng objects.
+cache-size=500
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+
+[MESSAGES CONTROL]
+
+# Enable only checker(s) with the given id(s). This option conflicts with the
+# disable-checker option
+#enable-checker=
+
+# Enable all checker(s) except those with the given id(s). This option
+# conflicts with the enable-checker option
+#disable-checker=
+
+# Enable all messages in the listed categories.
+#enable-msg-cat=
+
+# Disable all messages in the listed categories.
+#disable-msg-cat=
+
+# Enable the message(s) with the given id(s).
+#enable-msg=
+
+# Disable the message(s) with the given id(s).
+disable-msg=E1101,W0142
+
+
+[REPORTS]
+
+# set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html
+output-format=text
+
+# Include message's id in output
+include-ids=yes
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells wether to display a full report or only the messages
+reports=yes
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note).You have access to the variables errors warning, statement which
+# respectivly contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (R0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (R0004).
+comment=no
+
+# Enable the report(s) with the given id(s).
+#enable-report=
+
+# Disable the report(s) with the given id(s).
+#disable-report=
+
+
+# checks for
+# * unused variables / imports
+# * undefined variables
+# * redefinition of variable from builtins or from an outer scope
+# * use of variable before assigment
+# 
+[VARIABLES]
+
+# Tells wether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching names used for dummy variables (i.e. not used).
+dummy-variables-rgx=_|dummy|unused_.*
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
+
+
+# try to find bugs in the code using type inference
+# 
+[TYPECHECK]
+
+# Tells wether missing members accessed in mixin class should be ignored. A
+# mixin class is detected if its name ends with "mixin" (case insensitive).
+ignore-mixin-members=yes
+
+# List of classes names for which member attributes should not be checked
+# (useful for classes with attributes dynamicaly set).
+ignored-classes=SQLObject
+
+# When zope mode is activated, consider the acquired-members option to ignore
+# access to some undefined attributes.
+zope=no
+
+# List of members which are usually get through zope's acquisition mecanism and
+# so shouldn't trigger E0201 when accessed (need zope=yes to be considered).
+acquired-members=REQUEST,acl_users,aq_parent
+
+
+# checks for :
+# * doc strings
+# * modules / classes / functions / methods / arguments / variables name
+# * number of arguments, local variables, branchs, returns and statements in
+# functions, methods
+# * required module attributes
+# * dangerous default values as arguments
+# * redefinition of function / method / class
+# * uses of the global statement
+# 
+[BASIC]
+
+# Required attributes for module, separated by a comma
+required-attributes=
+
+# Regular expression which should only match functions or classes name which do
+# not require a docstring
+no-docstring-rgx=((_.*)|(do_.*))
+
+# Regular expression which should only match correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression which should only match correct module level names
+const-rgx=(([A-Z_][A-Z1-9_]*)|(__.*__))$
+
+# Regular expression which should only match correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression which should only match correct function names
+function-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct method names
+method-rgx=[a-z_][a-zA-Z0-9_]{2,30}$
+
+# Regular expression which should only match correct instance attribute names
+attr-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct argument names
+argument-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Regular expression which should only match correct variable names
+variable-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Regular expression which should only match correct list comprehension /
+# generator expression variable names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=map,filter,apply,input
+
+
+# checks for sign of poor/misdesign:
+# * number of methods, attributes, local variables...
+# * size, complexity of functions, methods
+# 
+[DESIGN]
+
+# Maximum number of arguments for function / method
+max-args=5
+
+# Maximum number of locals for function / method body
+max-locals=15
+
+# Maximum number of return / yield for function / method body
+max-returns=6
+
+# Maximum number of branch for function / method body
+max-branchs=12
+
+# Maximum number of statements in function / method body
+max-statements=50
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=7
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+
+# checks for
+# * external modules dependencies
+# * relative / wildcard imports
+# * cyclic imports
+# * uses of deprecated modules
+# 
+[IMPORTS]
+
+# Deprecated modules which should not be used, separated by a comma
+deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
+
+# Create a graph of every (i.e. internal and external) dependencies in the
+# given file (report R0402 must not be disabled)
+import-graph=
+
+# Create a graph of external dependencies in the given file (report R0402 must
+# not be disabled)
+ext-import-graph=
+
+# Create a graph of internal dependencies in the given file (report R0402 must
+# not be disabled)
+int-import-graph=
+
+
+# checks for :
+# * methods without self as first argument
+# * overridden methods signature
+# * access only to existant members via self
+# * attributes not defined in the __init__ method
+# * supported interfaces implementation
+# * unreachable code
+# 
+[CLASSES]
+
+# List of interface methods to ignore, separated by a comma. This is used for
+# instance to not check methods defines in Zope's Interface base class.
+ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,__new__,setUp,_reset,_createUi
+
+
+# checks for similarities and duplicated code. This computation may be
+# memory / CPU intensive, so you should disable it if you experiments some
+# problems.
+# 
+[SIMILARITIES]
+
+# Minimum lines number of a similarity.
+min-similarity-lines=4
+
+# Ignore comments when computing similarities.
+ignore-comments=yes
+
+# Ignore docstrings when computing similarities.
+ignore-docstrings=yes
+
+
+# checks for:
+# * warning notes in the code like FIXME, XXX
+# * PEP 263: source code with non ascii character but no encoding declaration
+# 
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME,XXX,TODO
+
+
+# checks for :
+# * unauthorized constructions
+# * strict indentation
+# * line length
+# * use of <> instead of !=
+# 
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=120
+
+# Maximum number of lines in a module
+max-module-lines=1000
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string='    '

Modified: trunk/pitivi/check.py
==============================================================================
--- trunk/pitivi/check.py	(original)
+++ trunk/pitivi/check.py	Thu Oct 16 14:21:27 2008
@@ -83,8 +83,7 @@
         return False
 
 def _version_to_string(version):
-    import string
-    return string.join([str(x) for x in version], ".")
+    return ".".join([str(x) for x in version])
 
 def _string_to_list(version):
     return [int(x) for x in version.split(".")]

Modified: trunk/pitivi/configure.py.in
==============================================================================
--- trunk/pitivi/configure.py.in	(original)
+++ trunk/pitivi/configure.py.in	Thu Oct 16 14:21:27 2008
@@ -24,7 +24,6 @@
 """
 
 import os.path
-import string
 
 LIBDIR = '@LIBDIR@'
 PKGDATADIR = '@DATADIR@/@PACKAGE@'
@@ -48,9 +47,9 @@
 
 def get_pixmap_dir():
     """ Returns the directory for program-only pixmaps """
-    dir = os.path.dirname(os.path.abspath(__file__))
+    _dir = os.path.dirname(os.path.abspath(__file__))
     if _in_devel():
-        root = dir
+        root = _dir
     else:
         root = PKGDATADIR
     return os.path.join(root, 'pixmaps')

Modified: trunk/pitivi/discoverer.py
==============================================================================
--- trunk/pitivi/discoverer.py	(original)
+++ trunk/pitivi/discoverer.py	Thu Oct 16 14:21:27 2008
@@ -79,6 +79,7 @@
         self.extrainfo = None # extra information about the error
         self.fakesink = None
         self.isimage = False # Used to know if the file is an image
+        self.bus = None
 
     def addFile(self, filename):
         """ queue a filename to be discovered """
@@ -194,7 +195,8 @@
             gst.warning("This is not a media file : %s" % self.current)
             if not self.error:
                 self.error = _("Couldn't construct pipeline.")
-                self.extrainfo = _("GStreamer does not have an element to handle files coming from this type of file system.")
+                self.extrainfo = _("GStreamer does not have an element to "
+                                   "handle files coming from this type of file system.")
             gobject.idle_add(self._finishAnalysis)
             return False
         if os.getenv("USE_DECODEBIN2"):
@@ -232,7 +234,7 @@
         # return False so we don't get called again
         return False
 
-    def _typefindHaveTypeCb(self, typefind, perc, caps):
+    def _typefindHaveTypeCb(self, unused_typefind, unused_perc, caps):
         if caps.to_string().startswith("image/"):
             self.isimage = True
 
@@ -342,22 +344,22 @@
         if pad.get_caps().is_fixed():
             self.currentfactory.video_info = pad.get_caps()
 
-        q = gst.element_factory_make("queue")
-        q.props.max_size_bytes = 5 * 1024 * 1024
-        q.props.max_size_time = 5 * gst.SECOND
+        queue = gst.element_factory_make("queue")
+        queue.props.max_size_bytes = 5 * 1024 * 1024
+        queue.props.max_size_time = 5 * gst.SECOND
         csp = gst.element_factory_make("ffmpegcolorspace")
         pngenc = gst.element_factory_make("pngenc")
         pngsink = gst.element_factory_make("filesink")
         pngsink.set_property("location", "/tmp/" + self.currentfactory.name.encode('base64').replace('\n','') + ".png")
 
-        self.pipeline.add(q, csp, pngenc, pngsink)
-        gst.element_link_many(q, csp, pngenc, pngsink)
-        pad.link(q.get_pad("sink"))
+        self.pipeline.add(queue, csp, pngenc, pngsink)
+        gst.element_link_many(queue, csp, pngenc, pngsink)
+        pad.link(queue.get_pad("sink"))
 
         if not self.currentfactory.video_info:
             self.signalsid.append((pad, pad.connect("notify::caps", self._vcapsNotifyCb)))
 
-        for element in [q, csp, pngenc, pngsink]:
+        for element in [queue, csp, pngenc, pngsink]:
             element.set_state(gst.STATE_PAUSED)
 
         if self.currentfactory.is_audio:
@@ -383,12 +385,12 @@
             gst.debug("non-fixed caps, adding queue and fakesink")
             ##         if not self.currentfactory.is_video:
             # we need to add a fakesink
-            q = gst.element_factory_make("queue")
+            queue = gst.element_factory_make("queue")
             fakesink = gst.element_factory_make("fakesink")
-            self.pipeline.add(fakesink, q)
-            pad.link(q.get_pad("sink"))
-            q.link(fakesink)
-            q.set_state(gst.STATE_PAUSED)
+            self.pipeline.add(fakesink, queue)
+            pad.link(queue.get_pad("sink"))
+            queue.link(fakesink)
+            queue.set_state(gst.STATE_PAUSED)
             fakesink.set_state(gst.STATE_PAUSED)
 
     def _unknownTypeCb(self, unused_dbin, unused_pad, caps):

Modified: trunk/pitivi/effects.py
==============================================================================
--- trunk/pitivi/effects.py	(original)
+++ trunk/pitivi/effects.py	Thu Oct 16 14:21:27 2008
@@ -25,7 +25,6 @@
 """
 
 import gst
-from objectfactory import OperationFactory, TransitionFactory, SMPTETransitionFactory
 
 # There are different types of effects available:
 #  _ Simple Audio/Video Effects

Modified: trunk/pitivi/elements/imagefreeze.py
==============================================================================
--- trunk/pitivi/elements/imagefreeze.py	(original)
+++ trunk/pitivi/elements/imagefreeze.py	Thu Oct 16 14:21:27 2008
@@ -43,6 +43,9 @@
 
 
 class ImageFreeze(gst.Element):
+    """
+    'Image to Video' element
+    """
 
     __gstdetails__ = (
         "ImageFreeze plugin",
@@ -90,7 +93,7 @@
         # this will be set by our task
         self.last_return = gst.FLOW_OK
 
-    def _sink_setcaps(self, pad, caps):
+    def _sink_setcaps(self, unused_pad, caps):
         gst.debug("caps %s" % caps.to_string())
         downcaps = self.srcpad.peer_get_caps().copy()
         gst.debug("downcaps %s" % downcaps.to_string())
@@ -128,11 +131,11 @@
         # 5. If we can't find an accepted candidate, we return False
         return False
 
-    def _src_event(self, pad, event):
+    def _src_event(self, unused_pad, event):
         # for the moment we just push it upstream
         gst.debug("event %r" % event)
         if event.type == gst.EVENT_SEEK:
-            rate,fmt,flags,startt,start,stopt,stop = event.parse_seek()
+            flags = event.parse_seek()[2]
             gst.debug("Handling seek event %r" % flags)
             if flags & gst.SEEK_FLAG_FLUSH:
                 gst.debug("sending flush_start event")
@@ -144,19 +147,16 @@
             gst.debug("pausing task")
             self.srcpad.pause_task()
             gst.debug("task paused")
-            seek = gst.event_new_seek(1.0, gst.FORMAT_TIME, flags,
-                                      gst.SEEK_TYPE_NONE, 0,
-                                      gst.SEEK_TYPE_NONE, 0)
-            #return self.sinkpad.push_event(seek)
+
             self._needsegment = True
             if flags & gst.SEEK_FLAG_FLUSH:
                 self.srcpad.push_event(gst.event_new_flush_stop())
-            self.srcpad.start_task(self.our_task)
+            self.srcpad.start_task(self._our_task)
             return True
 
         return self.sinkpad.push_event(event)
 
-    def _sink_event(self, pad, event):
+    def _sink_event(self, unused_pad, event):
         gst.debug("event %r" % event)
         if event.type == gst.EVENT_NEWSEGMENT:
             gst.debug("dropping new segment !")
@@ -165,18 +165,18 @@
             self._reset()
         return self.srcpad.push_event(event)
 
-    def _sink_chain(self, pad, buffer):
-        gst.debug("buffer %s %s" % (gst.TIME_ARGS(buffer.timestamp),
-                                    gst.TIME_ARGS(buffer.duration)))
+    def _sink_chain(self, unused_pad, buf):
+        gst.debug("buffer %s %s" % (gst.TIME_ARGS(buf.timestamp),
+                                    gst.TIME_ARGS(buf.duration)))
         if self._buffer != None:
             gst.debug("already have a buffer ! Returning GST_FLOW_WRONG_STATE")
             return gst.FLOW_WRONG_STATE
 
-        self._buffer = buffer
-        self.srcpad.start_task(self.our_task)
+        self._buffer = buf
+        self.srcpad.start_task(self._our_task)
         return gst.FLOW_WRONG_STATE
 
-    def our_task(self, something):
+    def _our_task(self, something):
         #this is where we repeatedly output our buffer
         gst.debug("self:%r, something:%r" % (self, something))
 
@@ -233,7 +233,7 @@
 
 gobject.type_register(ImageFreeze)
 
-def dataprobe(pad, data):
+def _dataprobe(unused_pad, data):
     if isinstance(data, gst.Buffer):
         print "Buffer", gst.TIME_ARGS(data.timestamp), gst.TIME_ARGS(data.duration), data.caps.to_string()
     else:
@@ -242,8 +242,8 @@
             print data.parse_new_segment()
     return True
 
-def make_image_video_bin(location):
-    b = gst.Bin("image-video-bin-"+location)
+def _make_image_video_bin(location):
+    bin = gst.Bin("image-video-bin-"+location)
     src = gst.element_factory_make("filesrc")
     src.props.location = location
     src.props.blocksize = 1024 * 1024
@@ -252,24 +252,24 @@
     freeze = ImageFreeze()
     cfil = gst.element_factory_make("capsfilter")
     cfil.props.caps = gst.Caps("video/x-raw-yuv,framerate=25/1")
-    p.add(src, dec, vscale, freeze, cfil)
+    bin.add(src, dec, vscale, freeze, cfil)
     gst.element_link_many(src, dec, vscale)
     vscale.link(freeze, gst.Caps("video/x-raw-yuv,width=640,height=480"))
     gst.element_link_many(freeze, cfil)
 
-    b.add_pad(gst.GhostPad("src", cfil.get_pad("src")))
+    bin.add_pad(gst.GhostPad("src", cfil.get_pad("src")))
 
-    return b
+    return bin
 
-def post_link(gnls, pad, q):
-    gnls.link(q)
+def _post_link(source, unused_pad, queue):
+    source.link(queue)
 
 # filesrc ! jpegdec ! imagefreeze ! xvimagesink
 if __name__ == "__main__":
     import sys
-    p = gst.Pipeline()
+    pipe = gst.Pipeline()
 
-    b = make_image_video_bin(sys.argv[1])
+    b = _make_image_video_bin(sys.argv[1])
     gnls = gst.element_factory_make("gnlsource")
     gnls.add(b)
 
@@ -279,20 +279,20 @@
 
     toverl = gst.element_factory_make("timeoverlay")
     sink = gst.element_factory_make("xvimagesink")
-    sink.get_pad("sink").add_data_probe(dataprobe)
+    sink.get_pad("sink").add_data_probe(_dataprobe)
 
-    q = gst.element_factory_make("queue")
+    queue = gst.element_factory_make("queue")
 
-    p.add(gnls, toverl, q, sink)
+    pipe.add(gnls, toverl, queue, sink)
 
-    gst.element_link_many(q, toverl, sink)
+    gst.element_link_many(queue, toverl, sink)
     #q.link(sink)
 
-    gnls.connect("pad-added", post_link, q)
+    gnls.connect("pad-added", _post_link, queue)
 
     ml = gobject.MainLoop()
 
-    p.set_state(gst.STATE_PLAYING)
+    pipe.set_state(gst.STATE_PLAYING)
 
     ml.run()
 

Modified: trunk/pitivi/elements/singledecodebin.py
==============================================================================
--- trunk/pitivi/elements/singledecodebin.py	(original)
+++ trunk/pitivi/elements/singledecodebin.py	Thu Oct 16 14:21:27 2008
@@ -97,7 +97,7 @@
         Returns the list of demuxers, decoders and parsers available, sorted
         by rank
         """
-        def myfilter(fact):
+        def _myfilter(fact):
             if fact.get_rank() < 64 :
                 return False
             klass = fact.get_klass()
@@ -105,7 +105,7 @@
                 return False
             return True
         reg = gst.registry_get_default()
-        res = [x for x in reg.get_feature_list(gst.ElementFactory) if myfilter(x)]
+        res = [x for x in reg.get_feature_list(gst.ElementFactory) if _myfilter(x)]
         res.sort(lambda a, b: int(b.get_rank() - a.get_rank()))
         return res
 

Modified: trunk/pitivi/elements/smartscale.py
==============================================================================
--- trunk/pitivi/elements/smartscale.py	(original)
+++ trunk/pitivi/elements/smartscale.py	Thu Oct 16 14:21:27 2008
@@ -54,28 +54,28 @@
         self.add(self.videoscale, self.capsfilter, self.videobox)
         gst.element_link_many(self.videoscale, self.capsfilter, self.videobox)
 
-        self._sinkPad = gst.GhostPad("sink", self.videoscale.get_pad("sink"))
-        self._sinkPad.set_active(True)
-        self._srcPad = gst.GhostPad("src", self.videobox.get_pad("src"))
-        self._srcPad.set_active(True)
+        self._sinkpad = gst.GhostPad("sink", self.videoscale.get_pad("sink"))
+        self._sinkpad.set_active(True)
+        self._srcpad = gst.GhostPad("src", self.videobox.get_pad("src"))
+        self._srcpad.set_active(True)
 
-        self.add_pad(self._sinkPad)
-        self.add_pad(self._srcPad)
+        self.add_pad(self._sinkpad)
+        self.add_pad(self._srcpad)
 
-        self._sinkPad.set_setcaps_function(self._sinkSetCaps)
+        self._sinkpad.set_setcaps_function(self._sinkSetCaps)
 
 
         # input/output values
         self.capsin = None
         self.widthin = -1
         self.heightin = -1
-        self.parin = gst.Fraction(1,1)
-        self.darin = gst.Fraction(1,1)
+        self.parin = gst.Fraction(1, 1)
+        self.darin = gst.Fraction(1, 1)
         self.capsout = None
         self.widthout = -1
         self.heightout = -1
-        self.parout = gst.Fraction(1,1)
-        self.darout = gst.Fraction(1,1)
+        self.parout = gst.Fraction(1, 1)
+        self.darout = gst.Fraction(1, 1)
 
     def set_caps(self, caps):
         """ set the outgoing caps, because gst.BaseTransform is full of CRACK ! """
@@ -97,14 +97,14 @@
             self._computeAndSetValues()
         return res
 
-    def _sinkPadCapsNotifyCb(self, pad, unused_prop):
+    def _sinkpadCapsNotifyCb(self, pad, unused_prop):
         caps = pad.get_negotiated_caps()
         self.log("caps:%r" % caps)
         self.widthin, self.heightin, self.parin, self.darin = self._getValuesFromCaps(caps)
         self.capsin = caps
         self._computeAndSetValues()
 
-    def _srcPadCapsNotifyCb(self, pad, unused_prop):
+    def _srcpadCapsNotifyCb(self, pad, unused_prop):
         caps = pad.get_negotiated_caps()
         self.log("caps:%r" % caps)
         self.widthout, self.heightout, self.parout, self.darout = self._getValuesFromCaps(caps)
@@ -115,12 +115,12 @@
         """
         returns (width, height, par, dar) from given caps.
         If caps are None, or not negotiated, it will return
-        (-1, -1, gst.Fraction(1,1), gst.Fraction(1,1))
+        (-1, -1, gst.Fraction(1, 1), gst.Fraction(1, 1))
         """
         width = -1
         height = -1
-        par = gst.Fraction(1,1)
-        dar = gst.Fraction(1,1)
+        par = gst.Fraction(1, 1)
+        dar = gst.Fraction(1, 1)
         if force or (caps and caps.is_fixed()):
             struc = caps[0]
             width = struc["width"]

Modified: trunk/pitivi/elements/thumbnailsink.py
==============================================================================
--- trunk/pitivi/elements/thumbnailsink.py	(original)
+++ trunk/pitivi/elements/thumbnailsink.py	Thu Oct 16 14:21:27 2008
@@ -69,10 +69,10 @@
             return False
         return True
 
-    def do_render(self, buffer):
-        self.log("buffer %s %d" % (gst.TIME_ARGS(buffer.timestamp),
-                                   len(buffer.data)))
-        pixb = gtk.gdk.pixbuf_new_from_data(buffer.data,
+    def do_render(self, buf):
+        self.log("buffer %s %d" % (gst.TIME_ARGS(buf.timestamp),
+                                   len(buf.data)))
+        pixb = gtk.gdk.pixbuf_new_from_data(buf.data,
                                             gtk.gdk.COLORSPACE_RGB,
                                             False,
                                             8,
@@ -80,10 +80,10 @@
                                             self.height,
                                             self.width * 3)
 
-        self.emit('thumbnail', pixb, buffer.timestamp)
+        self.emit('thumbnail', pixb, buf.timestamp)
         return gst.FLOW_OK
 
-    def do_preroll(self, buffer):
-        return self.do_render(buffer)
+    def do_preroll(self, buf):
+        return self.do_render(buf)
 
 gobject.type_register(PixbufThumbnailSink)

Modified: trunk/pitivi/elements/videofade.py
==============================================================================
--- trunk/pitivi/elements/videofade.py	(original)
+++ trunk/pitivi/elements/videofade.py	Thu Oct 16 14:21:27 2008
@@ -41,13 +41,13 @@
         self.add(self.incsp, self.alpha, self.vmix, self.outcsp)
         gst.element_link_many(self.incsp, self.alpha, self.vmix, self.outcsp)
 
-        self._sinkPad = gst.GhostPad("sink", self.incsp.get_pad("sink"))
-        self._sinkPad.set_active(True)
-        self._srcPad = gst.GhostPad("src", self.outcsp.get_pad("src"))
-        self._srcPad.set_active(True)
+        self._sinkpad = gst.GhostPad("sink", self.incsp.get_pad("sink"))
+        self._sinkpad.set_active(True)
+        self._srcpad = gst.GhostPad("src", self.outcsp.get_pad("src"))
+        self._srcpad.set_active(True)
 
-        self.add_pad(self._sinkPad)
-        self.add_pad(self._srcPad)
+        self.add_pad(self._sinkpad)
+        self.add_pad(self._srcpad)
 
         self.startposition = position
         self.duration = duration
@@ -59,18 +59,24 @@
         self._resetControllerValues()
 
     def setStartPosition(self, position):
+        """ Set the position at which the fade should start """
         if position == self.startposition:
             return
         self.startposition = position
         self._resetControllerValues()
 
     def setDuration(self, duration):
+        """ Set the duration (in ns) of the fade """
         if self.duration == duration:
             return
         self.duration = duration
         self._resetControllerValues()
 
     def setFadeFromBlack(self, fromblack):
+        """ Set which directio we should use.
+        True : From Black
+        False : To Black
+        """
         if self.fadefromblack == fromblack:
             return
         self.fadefromblack = fromblack

Modified: trunk/pitivi/objectfactory.py
==============================================================================
--- trunk/pitivi/objectfactory.py	(original)
+++ trunk/pitivi/objectfactory.py	Thu Oct 16 14:21:27 2008
@@ -28,7 +28,6 @@
 from urllib import unquote
 import weakref
 from random import randint
-import string
 import gobject
 import gst
 
@@ -176,7 +175,7 @@
                 return "Audio Effect"
             return "Effect"
         if not self.is_video and not self.is_audio:
-            "Unknown"
+            return "Unknown"
         stl = []
         # FIXME : file is FileSourceFactory specific !
         # FIXME : and it might not be a file:// but maybe a http://
@@ -195,7 +194,7 @@
             stl.append(self.video_info_stream.markup)
         if self.is_audio and self.audio_info_stream:
             stl.append(self.audio_info_stream.markup)
-        return string.join(stl, "\n") + "</small>"
+        return '\n'.join(stl) + "</small>"
 
     # FIXME : Too limited and ugly. What if we have non-AV streams ??
     def makeAudioBin(self):

Modified: trunk/pitivi/playground.py
==============================================================================
--- trunk/pitivi/playground.py	(original)
+++ trunk/pitivi/playground.py	Thu Oct 16 14:21:27 2008
@@ -194,13 +194,16 @@
         """
         if isinstance(self.current, SmartTimelineBin):
             return True
-        p = self.getTimeline()
-        if p:
-            self.switchToPipeline(p)
+        tl = self.getTimeline()
+        if tl:
+            self.switchToPipeline(tl)
             return True
         return False
 
     def getTimeline(self):
+        """
+        Returns the Timeline if any is present in the playground
+        """
         for pipeline in self.pipelines:
             if isinstance(pipeline, SmartTimelineBin):
                 return pipeline
@@ -273,7 +276,7 @@
         # actually being displayed currently :(
         try:
             if onlyvideo and not self.current.recording:
-                cur,format = self.vsinkthread.query_position(gst.FORMAT_TIME)
+                cur, format = self.vsinkthread.query_position(gst.FORMAT_TIME)
             else:
                 cur, format = self.current.query_position(gst.FORMAT_TIME)
         except:
@@ -307,7 +310,7 @@
                           gst.SEEK_TYPE_SET, value,
                           gst.SEEK_TYPE_NONE, -1)
         if not res:
-            gst.warning ("Seeking in current failed !");
+            gst.warning ("Seeking in current failed !")
             return False
         gst.debug("Seeking to %s succeeded" % gst.TIME_ARGS (value))
 

Modified: trunk/pitivi/pluginmanager.py
==============================================================================
--- trunk/pitivi/pluginmanager.py	(original)
+++ trunk/pitivi/pluginmanager.py	Thu Oct 16 14:21:27 2008
@@ -19,6 +19,10 @@
 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
+"""
+Plugin Manager
+"""
+
 import os
 import os.path
 import stat
@@ -76,12 +80,12 @@
 
         # plugins are collected in a bag (a structure relatng 1->many)
         # {"my_plugin":{"plugin":plugin_object, "filename":"/home/luca/plugins/my_plugin.py"}}
-        self.pluginbag={}
+        self.pluginbag = {}
 
         # Store plugin repositiories in the instance ensuring they are expressed
         # as absolute paths.
         self.local_plugin_path = os.path.abspath(local_plugin_path)
-        self.plugin_paths = [self.local_plugin_path,]
+        self.plugin_paths = [ self.local_plugin_path, ]
         self.settings_path = os.path.abspath(settings_path)
         self.collect()
 
@@ -120,8 +124,7 @@
 
         plugin_filename = self.pluginbag[plugin.name]["filename"]
 
-        #split plugin filename in dirname + basename
-        plugin_dirname = os.path.dirname(plugin_filename)
+        #Extract plugin base_name
         plugin_basename = os.path.basename(plugin_filename)
 
         #strip file extension from plugin basename ("myplugin.py" -> "myplugin")
@@ -131,8 +134,8 @@
         return os.path.join(self.settings_path, plugin_basename + ".conf")
 
     def _get_settings(self, plugin):
-        """ 
-        Get the plugin settings dictionary from disk 
+        """
+        Get the plugin settings dictionary from disk
 
         @param plugin: plugin for which to retrieve settings from disk
         @return: settings dictionary, None if not found
@@ -153,7 +156,7 @@
 
     def _is_valid_plugin_class(self, plugin_class):
         """
-        Check if plugin class correctly implements the IPlugin interface 
+        Check if plugin class correctly implements the IPlugin interface
 
         @param plugin_class: class to validate
         @return: True if class is a valid plugin, False otherwise
@@ -216,10 +219,10 @@
 
         elif filename.endswith(".egg"):
             # file is an egg, ask its entry point for the plugin class
-            fullName = os.path.join(directory, filename)
+            fullname = os.path.join(directory, filename)
 
-            pkg_resources.working_set.add_entry(fullName)
-            dist_generator = pkg_resources.find_distributions(fullName)
+            pkg_resources.working_set.add_entry(fullname)
+            dist_generator = pkg_resources.find_distributions(fullname)
             for dist in dist_generator:
                 try:
                     plugin_class = dist.load_entry_point("pitivi.plugins", "plugin")
@@ -323,7 +326,7 @@
         if not (filename.endswith(".egg") or filename.endswith(".py")):
             print "File must be a .py or a .egg"
 
-        plugin_class = self.loadPluginClass(os.path.basename(filename),\
+        plugin_class = self.loadPluginClass(os.path.basename(filename), \
                                             os.path.dirname(filename))
 
         if not plugin_class:
@@ -335,7 +338,7 @@
             shutil.copy(filename, repository_path)
 
             # insert the new plugin filename entry
-            new_filename = os.path.join(os.path.abspath(repository_path),\
+            new_filename = os.path.join(os.path.abspath(repository_path), \
                                         os.path.basename(filename))
             self.pluginbag[plugin_class.name] = {\
                 "plugin": None, "filename": new_filename}
@@ -362,7 +365,7 @@
         @return: plugin if installed, None otherwise
         """
 
-        new_plugin_class = self.loadPluginClass(os.path.basename(filename),\
+        new_plugin_class = self.loadPluginClass(os.path.basename(filename), \
                                                 os.path.dirname(filename))
         old_plugin = self.alreadyLoaded(new_plugin_class)
         old_settings = self._get_settings(old_plugin)

Modified: trunk/pitivi/project.py
==============================================================================
--- trunk/pitivi/project.py	(original)
+++ trunk/pitivi/project.py	Thu Oct 16 14:21:27 2008
@@ -34,7 +34,7 @@
 from configure import APPNAME
 from gettext import gettext as _
 from serializable import Serializable, to_object_from_data_type
-from projectsaver import ProjectSaver, ProjectSaveError, ProjectLoadError
+from projectsaver import ProjectSaver, ProjectLoadError
 from signalinterface import Signallable
 
 class Project(Serializable, Signallable):
@@ -198,6 +198,7 @@
         self.emit('settings-changed')
 
     def setUri(self, uri, format=None):
+        """ Set the location to which this project will be stored """
         gst.log("uri:%s, format:%s" % (uri, format))
         if not self.uri == uri:
             gst.log("updating self.uri, previously:%s" % self.uri)
@@ -287,6 +288,7 @@
         self.timeline.fromDataFormat(obj["timeline"])
 
 def uri_is_valid(uri):
+    """ Checks if the given uri is a valid uri (of type file://) """
     return gst.uri_get_protocol(uri) == "file"
 
 def file_is_project(uri):

Modified: trunk/pitivi/projectsaver.py
==============================================================================
--- trunk/pitivi/projectsaver.py	(original)
+++ trunk/pitivi/projectsaver.py	Thu Oct 16 14:21:27 2008
@@ -30,8 +30,6 @@
 
 import gst
 from cPickle import load, dump, PicklingError, UnpicklingError
-import timeline.composition
-import settings
 
 class ProjectError(Exception):
     def __init__(self, reason):

Modified: trunk/pitivi/serializable.py
==============================================================================
--- trunk/pitivi/serializable.py	(original)
+++ trunk/pitivi/serializable.py	Thu Oct 16 14:21:27 2008
@@ -19,6 +19,10 @@
 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
+"""
+Interface for object serialization
+"""
+
 import gst
 
 class Serializable(object):
@@ -47,7 +51,8 @@
         if not obj["datatype"]:
             raise Exception("dictionnary doesn't contain the type information !!")
         if not obj["datatype"] == self.__data_type__:
-            raise Exception("Mismatch in dictionnary data-type (%s) and class data-type (%s)" % (obj["datatype"],                                                                                                 self.__data_type__))
+            raise Exception("Mismatch in dictionnary data-type (%s) and class data-type (%s)" % (obj["datatype"],
+                                                                                                 self.__data_type__))
         return
 
 
@@ -56,17 +61,17 @@
     Returns a dictionnary of serialized classes.
     Mapping is type-name (string) => class
     """
-    def get_valid_subclasses(cls):
+    def __get_valid_subclasses(cls):
         res = [(cls.__data_type__, cls)]
         for i in cls.__subclasses__():
-            res.extend(get_valid_subclasses(i))
+            res.extend(__get_valid_subclasses(i))
         return res
 
-    listclasses = get_valid_subclasses(Serializable)
+    listclasses = __get_valid_subclasses(Serializable)
 
     # add a little check for duplicates here !
     check = {}
-    for i,j in listclasses:
+    for i, j in listclasses:
         if not i in check:
             check[i] = j
         else:

Modified: trunk/pitivi/settings.py
==============================================================================
--- trunk/pitivi/settings.py	(original)
+++ trunk/pitivi/settings.py	Thu Oct 16 14:21:27 2008
@@ -26,9 +26,8 @@
 
 import os
 import gst
-import string
 
-from serializable import Serializable, to_object_from_data_type
+from serializable import Serializable
 from signalinterface import Signallable
 
 from gettext import gettext as _
@@ -83,7 +82,6 @@
         #get_bool_env("PITIVI_ADVANCED_MODE")
         #self.fileSupportEnabled = get_bool_env("PITIVI_FILE_SUPPORT")
         self.fileSupportEnabled = True
-        pass
 
     def get_local_plugin_path(self, autocreate=True):
         """
@@ -145,8 +143,8 @@
     def __init__(self, **unused_kw):
         self.videowidth = 720
         self.videoheight = 576
-        self.videorate = gst.Fraction(25,1)
-        self.videopar = gst.Fraction(1,1)
+        self.videorate = gst.Fraction(25, 1)
+        self.videopar = gst.Fraction(1, 1)
         self.audiochannels = 2
         self.audiorate = 44100
         self.audiodepth = 16
@@ -163,18 +161,23 @@
 
     def __str__(self):
         msg = _("Export Settings\n")
-        msg += _("Video :") + str(self.videowidth) + " " + str(self.videoheight) + " " + str(self.videorate) + " " + str (self.videopar)
+        msg += _("Video :") + str(self.videowidth) + " " + str(self.videoheight) +\
+               " " + str(self.videorate) + " " + str (self.videopar)
         msg += "\n\t" + str(self.vencoder) + " " +str(self.vcodecsettings)
-        msg += _("\nAudio :") + str(self.audiochannels) + " " + str(self.audiorate) + " " + str(self.audiodepth)
+        msg += _("\nAudio :") + str(self.audiochannels) + " " + str(self.audiorate) +\
+               " " + str(self.audiodepth)
         msg += "\n\t" + str(self.aencoder) + " " + str(self.acodecsettings)
         msg += _("\nMuxer :") + str(self.muxer) + " " + str(self.containersettings)
         return msg
 
     def getVideoCaps(self):
         """ Returns the GstCaps corresponding to the video settings """
-        astr = "width=%d,height=%d,pixel-aspect-ratio=%d/%d,framerate=%d/%d" % (self.videowidth, self.videoheight,
-                                                                                self.videopar.num, self.videopar.denom,
-                                                                                self.videorate.num, self.videorate.denom)
+        astr = "width=%d,height=%d,pixel-aspect-ratio=%d/%d,framerate=%d/%d" % (self.videowidth,
+                                                                                self.videoheight,
+                                                                                self.videopar.num,
+                                                                                self.videopar.denom,
+                                                                                self.videorate.num,
+                                                                                self.videorate.denom)
         vcaps = gst.caps_from_string("video/x-raw-yuv,%s;video/x-raw-rgb,%s" % (astr, astr))
         if self.vencoder:
             return get_compatible_sink_caps(self.vencoder, vcaps)
@@ -320,9 +323,9 @@
         return res[0]
     return None
 
-def list_compat(a, b):
-    for x in a:
-        if not x in b:
+def list_compat(a1, b1):
+    for x1 in a1:
+        if not x1 in b1:
             return False
     return True
 
@@ -341,7 +344,7 @@
     flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
     res = []
     for fact in flist:
-        if list_compat(["Codec", "Muxer"], string.split(fact.get_klass(), '/')):
+        if list_compat(["Codec", "Muxer"], fact.get_klass().split('/')):
             res.append(fact)
     gst.log(str(res))
     return res
@@ -351,9 +354,9 @@
     flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
     res = []
     for fact in flist:
-        if list_compat(["Codec", "Encoder", "Video"], string.split(fact.get_klass(), '/')):
+        if list_compat(["Codec", "Encoder", "Video"], fact.get_klass().split('/')):
             res.append(fact)
-        elif list_compat(["Codec", "Encoder", "Image"], string.split(fact.get_klass(), '/')):
+        elif list_compat(["Codec", "Encoder", "Image"], fact.get_klass().split('/')):
             res.append(fact)
     gst.log(str(res))
     return res
@@ -363,7 +366,7 @@
     flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
     res = []
     for fact in flist:
-        if list_compat(["Codec", "Encoder", "Audio"], string.split(fact.get_klass(), '/')):
+        if list_compat(["Codec", "Encoder", "Audio"], fact.get_klass().split('/')):
             res.append(fact)
     gst.log(str(res))
     return res
@@ -380,9 +383,11 @@
     return res
 
 def muxer_can_sink_raw_audio(muxer):
+    """ Returns True if given muxer can accept raw audio """
     return my_can_sink_caps(muxer, gst.Caps("audio/x-raw-float;audio/x-raw-int"))
 
 def muxer_can_sink_raw_video(muxer):
+    """ Returns True if given muxer can accept raw video """
     return my_can_sink_caps(muxer, gst.Caps("video/x-raw-yuv;video/x-raw-rgb"))
 
 def available_combinations(muxers, vencoders, aencoders):

Modified: trunk/pitivi/signalgroup.py
==============================================================================
--- trunk/pitivi/signalgroup.py	(original)
+++ trunk/pitivi/signalgroup.py	Thu Oct 16 14:21:27 2008
@@ -49,12 +49,10 @@
 
         if id in self.signal_handler_ids:
             old_object, handler_id = self.signal_handler_ids[id]
-            #print "Disconnecting %s" % handler_id
             old_object.disconnect(handler_id)
             del self.signal_handler_ids[id]
 
         handler_id = object.connect(signal, callback, *args)
-        #print "Connected %s to signal %s " % (handler_id, signal)
         self.signal_handler_ids[id] = (object, handler_id)
 
     def disconnect(self, id):

Modified: trunk/pitivi/stream.py
==============================================================================
--- trunk/pitivi/stream.py	(original)
+++ trunk/pitivi/stream.py	Thu Oct 16 14:21:27 2008
@@ -24,8 +24,6 @@
 """
 
 
-# FIXME : If theses streams stay, they should go in a different file/module
-
 ##
 ## Multimedia streams, used for definition of media streams
 ##
@@ -33,7 +31,7 @@
 
 import gst
 
-class MultimediaStream:
+class MultimediaStream(object):
     """
     Defines a media stream
 
@@ -140,9 +138,9 @@
         struct = self.caps[0]
         self.videotype = struct.get_name()
         if self.videotype.startswith("video/x-raw-"):
-            self._raw=True
+            self._raw = True
         else:
-            self._raw=False
+            self._raw = False
 
         try:
             self._format = struct["format"]
@@ -160,12 +158,12 @@
             self._framerate = struct["framerate"]
         except:
             # if no framerate was given, use 1fps
-            self._framerate = gst.Fraction(1,1)
+            self._framerate = gst.Fraction(1, 1)
         try:
             self._par = struct["pixel-aspect-ratio"]
         except:
             # use a default setting, None is not valid !
-            self._par = gst.Fraction(1,1)
+            self._par = gst.Fraction(1, 1)
 
         if self.width and self.height and self.par:
             self._dar = gst.Fraction(self.width * self.par.num, self.height * self.par.denom)
@@ -193,7 +191,6 @@
     Audio stream
     """
 
-
     @property
     def float(self):
         """True if the audio stream contains raw float data"""
@@ -275,13 +272,14 @@
     Returns the appropriate MediaStream corresponding to the
     given caps.
     """
+    # FIXME : we should have an 'unknow' data stream class
+    ret = None
+
     val = caps.to_string()
     if val.startswith("video/"):
-        return VideoStream(caps)
+        ret = VideoStream(caps)
     elif val.startswith("audio/"):
-        return AudioStream(caps)
+        ret = AudioStream(caps)
     elif val.startswith("text/"):
-        return TextStream(caps)
-    else:
-        # FIXME : we should have an 'unknow' data stream class
-        return None
+        ret = TextStream(caps)
+    return ret

Modified: trunk/pitivi/thumbnailer.py
==============================================================================
--- trunk/pitivi/thumbnailer.py	(original)
+++ trunk/pitivi/thumbnailer.py	Thu Oct 16 14:21:27 2008
@@ -30,6 +30,9 @@
 from elements.thumbnailsink import PixbufThumbnailSink
 
 class Thumbnailer(gst.Pipeline):
+    """
+    Convenience pipeline to quickly create thumbnails for a given uri
+    """
 
     __gsignals__ = {
         "thumbnail" : (gobject.SIGNAL_RUN_LAST,

Modified: trunk/pitivi/timeline/composition.py
==============================================================================
--- trunk/pitivi/timeline/composition.py	(original)
+++ trunk/pitivi/timeline/composition.py	Thu Oct 16 14:21:27 2008
@@ -52,8 +52,8 @@
     def __len__(self):
         return len(self._effects)
 
-    def __getitem__(self, x):
-        return self._effects.__getitem__(x)
+    def __getitem__(self, item):
+        return self._effects.__getitem__(item)
 
 class SourcesLayer(Layer):
     """
@@ -173,7 +173,7 @@
     #      _ maximum priority
     #      _ list of sources sorted by time
 
-    def __init__(self, **kw):
+    def __init__(self, **kwargs):
         self.global_effects = [] # list of effects starting from highest priority
         self.simple_effects = [] # list of layers of simple effects (order: priority, then time)
         self.complex_effects = [] # complex effect sorted by time
@@ -183,16 +183,16 @@
         # each layer contains (min priority, max priority, list objects)
         #sources = [(2048, 2060, [])]
         self.sources = [(2048, 2060, [])]
-        self.defaultSource = None
-        TimelineSource.__init__(self, **kw)
-        self.setStartDurationTime(0,0)
+        self._default_source = None
+        TimelineSource.__init__(self, **kwargs)
+        self.setStartDurationTime(0, 0)
 
     def __len__(self):
         """ return the number of sources in this composition """
-        l = 0
+        le = 0
         for mn, mx, sources in self.sources:
-            l += len(sources)
-        return l
+            le += len(sources)
+        return le
 
     def __nonzero__(self):
         """ Always returns True, else bool(object) will return False if len(object) == 0 """
@@ -383,7 +383,7 @@
 
     def _addSource(self, source, position):
         """ private version of addSource """
-        def my_add_sorted(sources, object):
+        def _my_add_sorted(sources, object):
             slist = sources[2]
             i = 0
             for item in slist:
@@ -398,7 +398,7 @@
         position = 1
 
         # add it to the correct self.sources[position]
-        my_add_sorted(self.sources[position-1], source)
+        _my_add_sorted(self.sources[position-1], source)
 
         # add it to self.gnlobject
         self.gnlobject.info("adding %s to our composition" % source.gnlobject.props.name)
@@ -466,7 +466,6 @@
 
         # pushing following
         if push_following and not position in [-1, 0]:
-            #print self.gnlobject, "pushing following", existorder, len(self.sources[position - 1][2])
             self.shiftSources(source.factory.duration, existorder, len(self.sources[position - 1][2]))
 
         self.addSource(source, position, auto_linked=auto_linked)
@@ -506,11 +505,11 @@
         If push_neighbours is True, then sources located AFTER the NEW position will be shifted
         forward in time, in order to have enough free space to insert the source.
         """
-        self.gnlobject.info("source:%s , newpos:%d, move_linked:%s, push_neighbours:%s, collapse_neighbours:%s" % (source,
-                                                                                                                   newpos,
-                                                                                                                   move_linked,
-                                                                                                                   push_neighbours,
-                                                                                                                   collapse_neighbours))
+        self.gnlobject.info("source:%s , newpos:%d, move_linked:%s" % (source,
+                                                                       newpos,
+                                                                       move_linked))
+        self.gnlobject.info("push_neighbours:%s, collapse_neighbours:%s" % (push_neighbours,
+                                                                            collapse_neighbours))
         sources = self.sources[0][2]
         oldpos = sources.index(source)
 
@@ -592,7 +591,9 @@
         """
         if collapse_neighbours and not remove_linked:
             raise Exception("You cannot use remove_linked=False and collapse_neighbourse=True")
-        self.gnlobject.info("source:%s, remove_linked:%s, collapse_neighbours:%s" % (source, remove_linked, collapse_neighbours))
+        self.gnlobject.info("source:%s, remove_linked:%s, collapse_neighbours:%s" % (source,
+                                                                                     remove_linked,
+                                                                                     collapse_neighbours))
         sources = self.sources[0]
 
         pos = sources[2].index(source)
@@ -686,17 +687,17 @@
         Adds a default TimelineSource to the composition.
         Default sources will be used for gaps within the composition.
         """
-        if self.defaultSource:
-            self.gnlobject.remove(self.defaultSource.gnlobject)
+        if self._default_source:
+            self.gnlobject.remove(self._default_source.gnlobject)
         source.gnlobject.props.priority = 2 ** 32 - 1
         self.gnlobject.add(source.gnlobject)
-        self.defaultSource = source
+        self._default_source = source
 
     def getDefaultSource(self):
         """
         Returns the default source.
         """
-        return self.defaultSource
+        return self._default_source
 
 
     # AutoSettings methods
@@ -774,8 +775,8 @@
         ret["sources"] = tmp
 
         # default source
-        if self.defaultSource:
-            ret["default-source"] = self.defaultSource.toDataFormat()
+        if self._default_source:
+            ret["default-source"] = self._default_source.toDataFormat()
         return ret
 
     def fromDataFormat(self, obj):
@@ -834,7 +835,7 @@
         for layer in layers:
             for source in layer:
                 self.addSource(source, pos, auto_linked=False)
-            pos +=1
+            pos += 1
 
         # default source
         if "default-source" in obj:

Modified: trunk/pitivi/timeline/effects.py
==============================================================================
--- trunk/pitivi/timeline/effects.py	(original)
+++ trunk/pitivi/timeline/effects.py	Thu Oct 16 14:21:27 2008
@@ -33,9 +33,9 @@
 
     __data_type__ = "timeline-effect"
 
-    def __init__(self, nbinputs=1, **kw):
+    def __init__(self, nbinputs=1, **kwargs):
         self.nbinputs = nbinputs
-        TimelineObject.__init__(self, **kw)
+        TimelineObject.__init__(self, **kwargs)
 
     def _makeGnlObject(self):
         gnlobject = gst.element_factory_make("gnloperation", "operation-" + self.name)
@@ -53,9 +53,9 @@
 
     __data_type__ = "timeline-simple-effect"
 
-    def __init__(self, factory, **kw):
+    def __init__(self, factory, **kwargs):
         self.factory = factory
-        TimelineEffect.__init__(self, **kw)
+        TimelineEffect.__init__(self, **kwargs)
 
 
 class TimelineTransition(TimelineEffect):
@@ -67,9 +67,9 @@
 
     __data_type__ = "timeline-transition"
 
-    def __init__(self, factory, source1=None, source2=None, **kw):
+    def __init__(self, factory, source1=None, source2=None, **kwargs):
         self.factory = factory
-        TimelineEffect.__init__(self, nbinputs=2, **kw)
+        TimelineEffect.__init__(self, nbinputs=2, **kwargs)
         self.setSources(source1, source2)
 
     def setSources(self, source1, source2):
@@ -85,8 +85,8 @@
 
     __data_type__ = "timeline-complex-effect"
 
-    def __init__(self, factory, **kw):
+    def __init__(self, factory, **kwargs):
         self.factory = factory
         # Find out the number of inputs
         nbinputs = 2
-        TimelineEffect.__init__(self, nbinputs=nbinputs, **kw)
+        TimelineEffect.__init__(self, nbinputs=nbinputs, **kwargs)

Modified: trunk/pitivi/timeline/objects.py
==============================================================================
--- trunk/pitivi/timeline/objects.py	(original)
+++ trunk/pitivi/timeline/objects.py	Thu Oct 16 14:21:27 2008
@@ -87,19 +87,19 @@
             self.linked = None
             self.emit("linked-changed", None)
 
-    def _linkObject(self, object):
+    def _linkObject(self, obj):
         # really do the link
-        self.linked = object
+        self.linked = obj
         self.emit("linked-changed", self.linked)
 
-    def linkObject(self, object):
+    def linkObject(self, obj):
         """
         link another object to this one.
         If there already is a linked object ,it will unlink it
         """
-        if self.linked and not self.linked == object:
+        if self.linked and not self.linked == obj:
             self.unlinkObject()
-        self._linkObject(object)
+        self._linkObject(obj)
         self.linked._linkObject(self)
 
     def getLinkedObject(self):
@@ -358,15 +358,15 @@
         if self.linked:
             self.linked._setStartDurationTime(start, duration)
 
-    def _startDurationChangedCb(self, gnlobject, property):
+    def _startDurationChangedCb(self, gnlobject, prop):
         """ start/duration time has changed """
         gst.log("self:%r , gnlobject:%r" % (self, gnlobject))
         if not gnlobject == self.gnlobject:
             gst.warning("We're receiving signals from an object we dont' control (self.gnlobject:%r, gnlobject:%r)" % (self.gnlobject, gnlobject))
-        self.gnlobject.debug("property:%s" % property.name)
+        self.gnlobject.debug("property:%s" % prop.name)
         start = gst.CLOCK_TIME_NONE
         duration = 0
-        if property.name == "start":
+        if prop.name == "start":
             start = gnlobject.get_property("start")
             gst.log("start: %s => %s" % (gst.TIME_ARGS(self.start),
                                          gst.TIME_ARGS(start)))
@@ -374,7 +374,7 @@
                 start = gst.CLOCK_TIME_NONE
             else:
                 self.start = long(start)
-        elif property.name == "duration":
+        elif prop.name == "duration":
             duration = gnlobject.get_property("duration")
             gst.log("duration: %s => %s" % (gst.TIME_ARGS(self.duration),
                                             gst.TIME_ARGS(duration)))
@@ -421,8 +421,12 @@
         else:
             BrotherObjects.pendingObjectCreated(self, obj, field)
 
+    # FIXME : Should be made into properties
+
     def isAudio(self):
+        """ Does the object provide audio """
         return self.media_type == MEDIA_TYPE_AUDIO
 
     def isVideo(self):
+        """ Does the object provide video """
         return self.media_type == MEDIA_TYPE_VIDEO

Modified: trunk/pitivi/timeline/source.py
==============================================================================
--- trunk/pitivi/timeline/source.py	(original)
+++ trunk/pitivi/timeline/source.py	Thu Oct 16 14:21:27 2008
@@ -23,7 +23,6 @@
 Timeline source objects
 """
 
-import gobject
 import gst
 from pitivi.elements.singledecodebin import SingleDecodeBin
 from objects import TimelineObject, MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO, MEDIA_TYPE_NONE
@@ -45,10 +44,10 @@
 
 
     def __init__(self, media_start=gst.CLOCK_TIME_NONE,
-                 media_duration=0, **kw):
+                 media_duration=0, **kwargs):
         self.media_start = media_start
         self.media_duration = media_duration
-        TimelineObject.__init__(self, **kw)
+        TimelineObject.__init__(self, **kwargs)
 
     def _makeGnlObject(self):
         gst.debug("Making a source for %r" % self)
@@ -122,11 +121,11 @@
         if self.linked and isinstance(self.linked, TimelineFileSource):
             self.linked._setMediaStartDurationTime(start, duration)
 
-    def _mediaStartDurationChangedCb(self, gnlobject, property):
-        gst.log("%r %s %s" % (gnlobject, property, property.name))
+    def _mediaStartDurationChangedCb(self, gnlobject, prop):
+        gst.log("%r %s %s" % (gnlobject, prop, prop.name))
         mstart = None
         mduration = None
-        if property.name == "media-start":
+        if prop.name == "media-start":
             mstart = gnlobject.get_property("media-start")
             gst.log("start: %s => %s" % (gst.TIME_ARGS(self.media_start),
                                          gst.TIME_ARGS(mstart)))
@@ -136,7 +135,7 @@
                 mstart = None
             else:
                 self.media_start = mstart
-        elif property.name == "media-duration":
+        elif prop.name == "media-duration":
             mduration = gnlobject.get_property("media-duration")
             gst.log("duration: %s => %s" % (gst.TIME_ARGS(self.media_duration),
                                          gst.TIME_ARGS(mduration)))
@@ -156,8 +155,8 @@
     __data_type__ = "timeline-blank-source"
     __requires_factory__ = False
 
-    def __init__(self, **kw):
-        TimelineSource.__init__(self, **kw)
+    def __init__(self, **kwargs):
+        TimelineSource.__init__(self, **kwargs)
 
     def makeGnlSourceContents(self):
         if self.isAudio():
@@ -213,14 +212,14 @@
             raise NameError, "media type is NONE !"
         self.decodebin = SingleDecodeBin(caps=caps, uri=self.factory.name)
         if self.isAudio():
-            self.volumeElement = gst.element_factory_make("volume", "internal-volume")
+            self.volume_element = gst.element_factory_make("volume", "internal-volume")
             self.audioconv = gst.element_factory_make("audioconvert", "audioconv")
-            self.volumeBin = gst.Bin("volumebin")
-            self.volumeBin.add(self.decodebin, self.audioconv, self.volumeElement)
-            self.audioconv.link(self.volumeElement)
+            self.volumebin = gst.Bin("volumebin")
+            self.volumebin.add(self.decodebin, self.audioconv, self.volume_element)
+            self.audioconv.link(self.volume_element)
             self.decodebin.connect('pad-added', self._decodebinPadAddedCb)
             self.decodebin.connect('pad-removed', self._decodebinPadRemovedCb)
-            bin = self.volumeBin
+            bin = self.volumebin
         else:
             bin = self.decodebin
 
@@ -228,26 +227,27 @@
 
     def _decodebinPadAddedCb(self, unused_dbin, pad):
         pad.link(self.audioconv.get_pad("sink"))
-        ghost = gst.GhostPad("src", self.volumeElement.get_pad("src"))
+        ghost = gst.GhostPad("src", self.volume_element.get_pad("src"))
         ghost.set_active(True)
-        self.volumeBin.add_pad(ghost)
+        self.volumebin.add_pad(ghost)
 
     def _decodebinPadRemovedCb(self, unused_dbin, pad):
         gst.log("pad:%s" % pad)
         # workaround for gstreamer bug ...
-        gpad = self.volumeBin.get_pad("src")
+        gpad = self.volumebin.get_pad("src")
         target = gpad.get_target()
         peer = target.get_peer()
         target.unlink(peer)
         # ... to hereeeto here
-        self.volumeBin.remove_pad(self.volumeBin.get_pad("src"))
+        self.volumebin.remove_pad(self.volumebin.get_pad("src"))
         self.decodebin.unlink(self.audioconv)
 
     def _setVolume(self, level):
-        self.volumeElement.set_property("volume", level)
+        self.volume_element.set_property("volume", level)
         #FIXME: we need a volume-changed signal, so that UI updates
 
     def setVolume(self, level):
+        """ Set the volume to the given level """
         if self.isAudio():
             self._setVolume(level)
         elif self.linked:
@@ -291,8 +291,8 @@
         ret = TimelineSource.toDataFormat(self)
         ret["media-start"] = self.media_start
         ret["media-duration"] = self.media_duration
-        if self.isAudio() and hasattr(self, "volumeElement"):
-            ret["volume"] = self.volumeElement.get_property("volume")
+        if self.isAudio() and hasattr(self, "volume_element"):
+            ret["volume"] = self.volume_element.get_property("volume")
         return ret
 
     def fromDataFormat(self, obj):
@@ -310,5 +310,5 @@
 
     __data_type__ = "timeline-live-source"
 
-    def __init__(self, **kw):
-        TimelineSource.__init__(self, **kw)
+    def __init__(self, **kwargs):
+        TimelineSource.__init__(self, **kwargs)

Modified: trunk/pitivi/timeline/timeline.py
==============================================================================
--- trunk/pitivi/timeline/timeline.py	(original)
+++ trunk/pitivi/timeline/timeline.py	Thu Oct 16 14:21:27 2008
@@ -50,6 +50,8 @@
         else:
             name = "XXX"
         self.timeline = gst.Bin("timeline-" + name)
+        self.audiocomp = None
+        self.videocomp = None
         self._fillContents()
 
     def _fillContents(self):
@@ -93,23 +95,23 @@
         self.timeline.remove_pad(self.timeline.get_pad("vsrc"))
 
     def getAutoSettings(self):
-        v = self.videocomp._getAutoSettings()
-        a = self.audiocomp._getAutoSettings()
-        if not v and not a:
+        vs = self.videocomp._getAutoSettings()
+        as = self.audiocomp._getAutoSettings()
+        if not vs and not as:
             return None
         # return an ExportSettings containing the combination of
         # the autosettings from the audio and video composition.
-        s = ExportSettings()
-        if v:
-            s.videowidth = v.videowidth
-            s.videoheight = v.videoheight
-            s.videorate = v.videorate
-            s.videopar = v.videopar
-        if a:
-            s.audiochannels = a.audiochannels
-            s.audiorate = a.audiorate
-            s.audiodepth = a.audiodepth
-        return s
+        settings = ExportSettings()
+        if vs:
+            settings.videowidth = vs.videowidth
+            settings.videoheight = vs.videoheight
+            settings.videorate = vs.videorate
+            settings.videopar = vs.videopar
+        if as:
+            settings.audiochannels = as.audiochannels
+            settings.audiorate = as.audiorate
+            settings.audiodepth = as.audiodepth
+        return settings
 
     def getDuration(self):
         return max(self.audiocomp.duration, self.videocomp.duration)

Modified: trunk/pitivi/ui/complexinterface.py
==============================================================================
--- trunk/pitivi/ui/complexinterface.py	(original)
+++ trunk/pitivi/ui/complexinterface.py	Thu Oct 16 14:21:27 2008
@@ -50,7 +50,7 @@
 # . nsToPixels(time)
 
 class Zoomable:
-    
+
     zoomratio = 0
     zoom_adj = None
 

Modified: trunk/pitivi/ui/complexlayer.py
==============================================================================
--- trunk/pitivi/ui/complexlayer.py	(original)
+++ trunk/pitivi/ui/complexlayer.py	Thu Oct 16 14:21:27 2008
@@ -92,6 +92,7 @@
         self._list = []
 
     def setTimeline(self, timeline):
+        """ Set the given timeline on this layer """
         self._clear()
         self.timeline = timeline
         if self.timeline:
@@ -160,5 +161,5 @@
     def __len__(self):
         return self._list.__len__()
 
-    def __getitem__(self, y):
-        return self._list.__getitem__(y)
+    def __getitem__(self, item):
+        return self._list.__getitem__(item)

Modified: trunk/pitivi/ui/complextimeline.py
==============================================================================
--- trunk/pitivi/ui/complextimeline.py	(original)
+++ trunk/pitivi/ui/complextimeline.py	Thu Oct 16 14:21:27 2008
@@ -33,6 +33,7 @@
 import ruler
 from complexinterface import Zoomable
 import goocanvas
+# FIXME : wildcard imports are BAD !
 from util import *
 import os.path
 from urllib import unquote
@@ -193,7 +194,7 @@
                 self.object_style = AUDIO_SOURCE
                 self.height = AUDIO_TRACK_HEIGHT
 
-    def _objectAdded(self, timeline, element):
+    def _objectAdded(self, unused_timeline, element):
         w = ComplexTimelineObject(element, self.comp, self.object_style)
         make_dragable(self.canvas, w, start=self._start_drag,
             end=self._end_drag, moved=self._move_source_cb)
@@ -211,7 +212,7 @@
             moved=self._trim_source_end_cb,
             cursor=RIGHT_SIDE)
 
-    def _objectRemoved(self, timeline, element):
+    def _objectRemoved(self, unused_timeline, element):
         w = self.widgets[element]
         self.remove_child(w)
         w.comp = None
@@ -228,7 +229,7 @@
         #self.canvas.block_size_request(True)
         self.canvas.update_editpoints()
 
-    def _end_drag(self, item):
+    def _end_drag(self, unused_item):
         self.canvas.block_size_request(False)
 
     def _move_source_cb(self, item, pos):
@@ -307,7 +308,7 @@
         self.width = self.bg.props.width
         self.height = self.bg.props.height
 
-    def _set_cursor(self, item, target, event, cursor):
+    def _set_cursor(self, unused_item, unused_target, event, cursor):
         window = event.window
         # wtf ? no get_cursor?
         #self._oldcursor = window.get_cursor()
@@ -330,7 +331,7 @@
         self.name.props.clip_path = "M%g,%g h%g v%g h-%g z" % (
             self.x, self.y, w, self.height, w)
 
-    def do_set_x(self, *args):
+    def do_set_x(self, *unused_args):
         x = self.x
         self.bg.props.x = x
         self.name.props.x = x + width(self.l_handle) + 2
@@ -338,7 +339,7 @@
         self.r_handle.props.x = x + self.width - width(self.r_handle)
         self._size_spacer()
 
-    def do_set_y(self, *args):
+    def do_set_y(self, *unused_args):
         y = self.y
         self.bg.props.y = y
         self.name.props.y = y + 2
@@ -346,13 +347,13 @@
         self.r_handle.props.y = y
         self._size_spacer()
 
-    def do_set_width(self, *args):
+    def do_set_width(self, *unused_args):
         self.bg.props.width = self.width
         self.r_handle.props.x = self.x + self.width - width(self.r_handle)
         self.name.props.width = self.width - (2 * width(self.l_handle) + 4)
         self._size_spacer()
 
-    def do_set_height(self, *args):
+    def do_set_height(self, *unused_args):
         height = self.height
         self.bg.props.height = height
         self.l_handle.props.height = height
@@ -406,7 +407,7 @@
     def _size_allocate(self, unused_layout, allocation):
         self._razor.props.height = allocation.height
 
-    def _request_size(self, unused_item, prop):
+    def _request_size(self, unused_item, unused_prop):
         #TODO: figure out why this doesn't work... (wtf?!?)
         if self._block_size_request:
             return True
@@ -416,7 +417,7 @@
         # wider than it actually needs to be.
         w = max(800, ((int(self.layers.width + 100) / 100) + 1 ) * 100)
         h = int(self.layers.height)
-        x1,y1,x2,y2 = self.get_bounds()
+        x1, y1, x2, y2 = self.get_bounds()
         pw = abs(x2 - x1)
         ph = abs(y2 - y1)
         if not (w == pw and h == ph):
@@ -473,7 +474,7 @@
 
 ## mouse callbacks
 
-    def _mouseEnterCb(self, item, target, event):
+    def _mouseEnterCb(self, unused_item, unused_target, event):
         event.window.set_cursor(self._cursor)
         return True
 
@@ -498,13 +499,13 @@
         self._razor.props.visibility = goocanvas.ITEM_VISIBLE
         return True
 
-    def _razorMovedCb(self, canvas, event):
-        x, y = event_coords(self, event)
+    def _razorMovedCb(self, unused_canvas, event):
+        x = event_coords(self, event)[0]
         self._razor.props.x = self.nsToPixel(self.snap_time_to_playhead(
             self.pixelToNs(x)))
         return True
 
-    def _razorClickedCb(self, canvas, event):
+    def _razorClickedCb(self, unused_canvas, event):
         self._cursor = ARROW
         event.window.set_cursor(ARROW)
         self.disconnect(self._razor_sigid)
@@ -608,7 +609,7 @@
             parent = item.get_parent()
             self._selected_sources.remove(parent)
 
-    def timelinePositionChanged(self, value, frame):
+    def timelinePositionChanged(self, value, unused_frame):
         self._timeline_position = value
 
 ## Zoomable Override
@@ -672,7 +673,7 @@
         self._zoom_adj.upper = self._computeZoomRatio(-1)
         self._cur_zoom = 2
         self._zoom_adj.set_value(self._computeZoomRatio(self._cur_zoom))
- 
+
         # common LayerInfoList
         self.layerInfoList = LayerInfoList()
 
@@ -740,7 +741,7 @@
 
 ## layer callbacks
 
-    def _layerStartDurationChanged(self, layer):
+    def _layerStartDurationChanged(self, unused_layer):
         self.ruler.startDurationChanged()
 
 ## ToolBar callbacks

Modified: trunk/pitivi/ui/glade.py
==============================================================================
--- trunk/pitivi/ui/glade.py	(original)
+++ trunk/pitivi/ui/glade.py	Thu Oct 16 14:21:27 2008
@@ -117,7 +117,7 @@
         wtree.signal_autoconnect(self)
 
 
-class GladeWindow(gobject.GObject):
+class GladeWindow(object):
     """
     Base class for dialogs or windows backed by glade interface definitions.
 
@@ -139,7 +139,6 @@
     window = None
 
     def __init__(self, parent=None):
-        gobject.GObject.__init__(self)
         try:
             assert self.glade_file
             filepath = os.path.join(self.glade_dir, self.glade_file)

Modified: trunk/pitivi/ui/gstwidget.py
==============================================================================
--- trunk/pitivi/ui/gstwidget.py	(original)
+++ trunk/pitivi/ui/gstwidget.py	Thu Oct 16 14:21:27 2008
@@ -23,7 +23,6 @@
 Widget for gstreamer element properties viewing/setting
 """
 
-import string
 import gobject
 import gtk
 import gst
@@ -31,10 +30,10 @@
 
 from gettext import gettext as _
 
-def get_widget_propvalue(property, widget):
+def get_widget_propvalue(prop, widget):
     """ returns the value of the given propertywidget """
     # FIXME : implement the case for flags
-    type_name = gobject.type_name(property.value_type.fundamental)
+    type_name = gobject.type_name(prop.value_type.fundamental)
 
     if (type_name == 'gchararray'):
         return widget.get_text()
@@ -45,19 +44,16 @@
     if (type_name in ['gboolean']):
         return widget.get_active()
     if type_name in ['GEnum']:
-        idx = widget.get_active()
-        model = widget.get_model()
-        name, val = model[idx]
-        return val
+        return widget.get_model()[widget.get_active()][1]
     return None
 
-def make_property_widget(unused_element, property, value=None):
+def make_property_widget(unused_element, prop, value=None):
     """ Creates a Widget for the given element property """
     # FIXME : implement the case for flags
-    type_name = gobject.type_name(property.value_type.fundamental)
+    type_name = gobject.type_name(prop.value_type.fundamental)
 
     if value == None:
-        value = property.default_value
+        value = prop.default_value
     if (type_name == 'gchararray'):
         widget = gtk.Entry()
         widget.set_text(str(value))
@@ -80,14 +76,14 @@
         if value:
             widget.set_active(True)
     elif (type_name == 'GEnum'):
-        model = gtk.ListStore(gobject.TYPE_STRING, property.value_type)
+        model = gtk.ListStore(gobject.TYPE_STRING, prop.value_type)
         widget = gtk.ComboBox(model)
         cell = gtk.CellRendererText()
         widget.pack_start(cell, True)
         widget.add_attribute(cell, 'text', 0)
 
         idx = 0
-        for key, val in property.enum_class.__enum_values__.iteritems():
+        for key, val in prop.enum_class.__enum_values__.iteritems():
             gst.log("adding %s / %s" % (val.value_name, val))
             model.append([val.value_name, val])
             if val == value:
@@ -98,16 +94,23 @@
         widget = gtk.Label(type_name)
         widget.set_alignment(1.0, 0.5)
 
-    if not property.flags & gobject.PARAM_WRITABLE:
+    if not prop.flags & gobject.PARAM_WRITABLE:
         widget.set_sensitive(False)
     return widget
 
 class GstElementSettingsWidget(gtk.VBox):
+    """
+    Widget to view/modify properties of a gst.Element
+    """
 
     def __init__(self):
         gtk.VBox.__init__(self)
+        self.element = None
+        self.ignore = None
+        self.properties = None
 
     def setElement(self, element, properties={}, ignore=['name']):
+        """ Set given element on Widget, with optional properties """
         gst.info("element:%s, properties:%s" % (element, properties))
         self.element = element
         self.ignore = ignore
@@ -150,6 +153,9 @@
 
 
 class GstElementSettingsDialog(GladeWindow):
+    """
+    Dialog window for viewing/modifying properties of a gst.Element
+    """
     glade_file = "elementsettingsdialog.glade"
 
     def __init__(self, elementfactory, properties={}):
@@ -169,7 +175,7 @@
         self.window.set_title(_("Properties for ") + self.factory.get_longname())
         self.widgets["infolabel"].set_markup("<b>" + self.factory.get_longname() + "</b>")
         self.desclabel.set_text(self.factory.get_description())
-        self.authlabel.set_text(string.join(self.factory.get_author().split(","), "\n"))
+        self.authlabel.set_text('\n'.join(self.factory.get_author().split(",")))
         self.authlabel.set_justify(gtk.JUSTIFY_RIGHT)
         self.widgets["elementsettings"].setElement(self.element, self.properties)
 

Modified: trunk/pitivi/ui/mainwindow.py
==============================================================================
--- trunk/pitivi/ui/mainwindow.py	(original)
+++ trunk/pitivi/ui/mainwindow.py	Thu Oct 16 14:21:27 2008
@@ -32,9 +32,9 @@
 try:
     import gconf
 except:
-    have_gconf=False
+    HAVE_GCONF = False
 else:
-    have_gconf=True
+    HAVE_GCONF = True
 
 import pitivi.configure as configure
 from pitivi.projectsaver import ProjectSaver
@@ -54,16 +54,29 @@
 from glade import GladeWindow
 from exportsettingswidget import ExportSettingsDialog
 
-import dbus
-import dbus.service
-import dbus.glib
-
-if have_gconf:
+if HAVE_GCONF:
     D_G_INTERFACE = "/desktop/gnome/interface"
 
-    for gconf_dir in (D_G_INTERFACE,):
+    for gconf_dir in (D_G_INTERFACE, ):
         gconf.client_get_default ().add_dir (gconf_dir, gconf.CLIENT_PRELOAD_NONE)
 
+def create_stock_icons():
+    """ Creates the pitivi-only stock icons """
+    gtk.stock_add([
+            ('pitivi-advanced-mode', 'Advanced Mode', 0, 0, 'pitivi'),
+            ('pitivi-render', 'Render', 0, 0, 'pitivi')
+            ])
+    factory = gtk.IconFactory()
+    pixbuf = gtk.gdk.pixbuf_new_from_file(
+        configure.get_pixmap_dir() + "/pitivi-advanced-24.png")
+    iconset = gtk.IconSet(pixbuf)
+    factory.add('pitivi-advanced-mode', iconset)
+    pixbuf = gtk.gdk.pixbuf_new_from_file(
+        configure.get_pixmap_dir() + "/pitivi-render-24.png")
+    iconset = gtk.IconSet(pixbuf)
+    factory.add('pitivi-render', iconset)
+    factory.add_default()
+
 
 class PitiviMainWindow(gtk.Window):
     """
@@ -75,21 +88,18 @@
         """ initialize with the Pitivi object """
         gst.log("Creating MainWindow")
         gtk.Window.__init__(self)
-
+        self.actions = None
+        self.toggleactions = None
+        self.actiongroup = None
+        self.is_fullscreen = False
+        self.error_dialogbox = None
         self.pitivi = instance
 
     def load(self):
         """ load the user interface """
-        self._createStockIcons()
+        create_stock_icons()
         self._setActions()
         self._createUi()
-        self.actions = None
-        self.toggleactions = None
-        self.actiongroup = None
-
-        self.isFullScreen = False
-        self.errorDialogBox = None
-
         self.pitivi.connect("new-project-loaded", self._newProjectLoadedCb)
         self.pitivi.connect("new-project-loading", self._newProjectLoadingCb)
         self.pitivi.connect("closing-project", self._closingProjectCb)
@@ -99,21 +109,6 @@
         self.pitivi.playground.connect("error", self._playGroundErrorCb)
         self.pitivi.current.sources.connect("file_added", self._sourcesFileAddedCb)
 
-        # Start dbus service
-        session_bus = dbus.SessionBus()
-        name = dbus.service.BusName("org.gnome.pitivi", bus=session_bus)
-        object = pitivi_dbus(name)
-
-
-        # FIXME : connect to the device probe signals to toggle the webcam
-        # features based on availability (or not) of webcams.
-
-        # if no webcams available, hide the webcam action
-        instance.PiTiVi.deviceprobe.connect("device-added", self.__deviceChangeCb)
-        instance.PiTiVi.deviceprobe.connect("device-removed", self.__deviceChangeCb)
-        if len(instance.PiTiVi.deviceprobe.getVideoSourceDevices()) < 1:
-            self.webcam_button.set_sensitive(False)
-
         self.show_all()
 
     def _encodingDialogDestroyCb(self, unused_dialog):
@@ -123,7 +118,7 @@
         # pause timeline !
         self.pitivi.playground.pause()
 
-        win = EncodingDialog(self.pitivi.current)
+        win = EncodingDialog(self.pitivi.current, self.pitivi)
         win.window.connect("destroy", self._encodingDialogDestroyCb)
         self.pitivi.gui.set_sensitive(False)
         win.show()
@@ -150,17 +145,6 @@
             else:
                 self.render_button.set_sensitive(False)
 
-    def _createStockIcons(self):
-        """ Creates the pitivi-only stock icons """
-        gtk.stock_add([
-                ('pitivi-render', 'Render', 0, 0, 'pitivi')
-                ])
-        factory = gtk.IconFactory()
-        pixbuf = gtk.gdk.pixbuf_new_from_file(
-            configure.get_pixmap_dir() + "/pitivi-render-24.png")
-        iconset = gtk.IconSet(pixbuf)
-        factory.add('pitivi-render', iconset)
-        factory.add_default()
 
 
     def _setActions(self):
@@ -296,19 +280,19 @@
 
     def toggleFullScreen(self):
         """ Toggle the fullscreen mode of the application """
-        if not self.isFullScreen:
+        if not self.is_fullscreen:
             self.viewer.window.fullscreen()
-            self.isFullScreen = True
+            self.is_fullscreen = True
         else:
             self.viewer.window.unfullscreen()
-            self.isFullScreen = False
+            self.is_fullscreen = False
 
 ## PlayGround callback
 
     def _errorMessageResponseCb(self, dialogbox, unused_response):
         dialogbox.hide()
         dialogbox.destroy()
-        self.errorDialogBox = None
+        self.error_dialogbox = None
 
     def _playGroundErrorCb(self, unused_playground, error, detail):
         # FIXME FIXME FIXME:
@@ -318,15 +302,15 @@
         # some ways of actually _dealing_ with the underlying problem:
         # install a plugin, re-conform source to some other format, or
         # maybe even disable playback of a problematic file.
-        if self.errorDialogBox:
+        if self.error_dialogbox:
             return
-        self.errorDialogBox = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
+        self.error_dialogbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
             gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, None)
-        self.errorDialogBox.set_markup("<b>%s</b>" % error)
-        self.errorDialogBox.connect("response", self._errorMessageResponseCb)
+        self.error_dialogbox.set_markup("<b>%s</b>" % error)
+        self.error_dialogbox.connect("response", self._errorMessageResponseCb)
         if detail:
-            self.errorDialogBox.format_secondary_text(detail)
-        self.errorDialogBox.show()
+            self.error_dialogbox.format_secondary_text(detail)
+        self.error_dialogbox.show()
 
 ## Project source list callbacks
 
@@ -337,18 +321,7 @@
 
 ## UI Callbacks
 
-    def _destroyCb(self, unused_widget, data=None):
-
-        # Quit connection to istanbul/switch off savemode
-        try:
-            bus = dbus.SessionBus()
-            remote_object = bus.get_object("org.gnome.istanbul", "/state")
-            self.iface = dbus.Interface(remote_object, "org.gnome.istanbul")
-            self.iface.savemode(False)
-        except:
-            pass
-
-
+    def _destroyCb(self, unused_widget, unused_data=None):
         self.pitivi.shutdown()
 
 
@@ -395,8 +368,7 @@
         self.pitivi.current.saveAs()
 
     def _projectSettingsCb(self, unused_action):
-        l = ProjectSettingsDialog(self, self.pitivi.current)
-        l.show()
+        ProjectSettingsDialog(self, self.pitivi.current).show()
 
     def _quitCb(self, unused_action):
         self.pitivi.shutdown()
@@ -412,7 +384,9 @@
         abt.set_name(APPNAME)
         abt.set_version("v%s" % pitivi_version)
         abt.set_website("http://www.pitivi.org/";)
-        authors = ["Edward Hervey <bilboed bilboed com>","",_("Contributors:"),
+        authors = ["Edward Hervey <bilboed bilboed com>",
+                   "",
+                   _("Contributors:"),
                    "Christophe Sauthier <christophe sauthier gmail com> (i18n)",
                    "Laszlo Pandy <laszlok2 gmail com> (UI)",
                    "Ernst Persson  <ernstp gmail com>",
@@ -425,7 +399,8 @@
                    "Thijs Vermeir <thijsvermeir gmail com>",
                    "Sarath Lakshman <sarathlakshman slynux org>"]
         abt.set_authors(authors)
-        abt.set_license(_("GNU Lesser General Public License\nSee http://www.gnu.org/copyleft/lesser.html for more details"))
+        abt.set_license(_("GNU Lesser General Public License\n"
+                          "See http://www.gnu.org/copyleft/lesser.html for more details"))
         abt.set_icon_from_file(configure.get_global_pixmap_dir() + "/pitivi.png")
         abt.connect("response", self._aboutResponseCb)
         abt.show()
@@ -464,17 +439,17 @@
 
     ## PiTiVi main object callbacks
 
-    def _newProjectLoadedCb(self, pitivi, project):
+    def _newProjectLoadedCb(self, unused_pitivi, unused_project):
         gst.log("A NEW project is loaded, update the UI!")
         # ungrey UI
         self.set_sensitive(True)
 
-    def _newProjectLoadingCb(self, pitivi, project):
+    def _newProjectLoadingCb(self, unused_pitivi, unused_project):
         gst.log("A NEW project is being loaded, deactivate UI")
         # grey UI
         self.set_sensitive(False)
 
-    def _closingProjectCb(self, pitivi, project):
+    def _closingProjectCb(self, unused_pitivi, project):
         if not project.hasUnsavedModifications():
             return True
 
@@ -490,7 +465,7 @@
             return True
         return False
 
-    def _notProjectCb(self, pitivi, reason, uri):
+    def _notProjectCb(self, unused_pitivi, reason, uri):
         # ungrey UI
         dialog = gtk.MessageDialog(self,
             gtk.DIALOG_MODAL,
@@ -565,23 +540,13 @@
         return ret
 
 
-# dbus object class
-class pitivi_dbus(dbus.service.Object):
-    def __init__(self, bus_name, object_path="/import"):
-        dbus.service.Object.__init__(self, bus_name, object_path)
-        self.sourcefactories = SourceFactoriesWidget()
-
-    @dbus.service.method("org.gnome.pitivi")
-    def AddFiles(self, filepath):
-        self.sourcefactories.sourcelist.addFiles(filepath)
-        return True
-
 class EncodingDialog(GladeWindow):
     """ Encoding dialog box """
     glade_file = "encodingdialog.glade"
 
-    def __init__(self, project):
+    def __init__(self, project, instance):
         GladeWindow.__init__(self)
+        self.pitivi = instance
         self.project = project
         self.bin = project.getBin()
         self.bus = self.bin.get_bus()

Modified: trunk/pitivi/ui/pluginmanagerdialog.py
==============================================================================
--- trunk/pitivi/ui/pluginmanagerdialog.py	(original)
+++ trunk/pitivi/ui/pluginmanagerdialog.py	Thu Oct 16 14:21:27 2008
@@ -299,7 +299,6 @@
                             targetType, time):
         """ handle drag&drop of new plugins into the list by installing them"""
 
-        #print "context:%s targetType:%d, selection.data:%r" % (context.targets, targetType, selection.data)
         uri_list = selection.data.strip().split()
         installed = False
 

Modified: trunk/pitivi/ui/slider.py
==============================================================================
--- trunk/pitivi/ui/slider.py	(original)
+++ trunk/pitivi/ui/slider.py	Thu Oct 16 14:21:27 2008
@@ -215,9 +215,9 @@
         else:
             self._duration = duration
         if self._displayEndpoints:
-            self._endpoints.setEndpoints(0, self._pipeline.length, start, 
+            self._endpoints.setEndpoints(0, self._pipeline.length, start,
                 duration)
-    
+
     def set_value(self, position):
         """Sets the position of the slider's cursor.
         """

Modified: trunk/pitivi/ui/sourcefactories.py
==============================================================================
--- trunk/pitivi/ui/sourcefactories.py	(original)
+++ trunk/pitivi/ui/sourcefactories.py	Thu Oct 16 14:21:27 2008
@@ -25,7 +25,6 @@
 
 import os
 import time
-import string
 import gobject
 import gtk
 import gst
@@ -44,6 +43,7 @@
 from gettext import gettext as _
 
 def beautify_length(length):
+    """ Returns a string version of a nanoseconds value """
     sec = length / gst.SECOND
     mins = sec / 60
     sec = sec % 60
@@ -104,7 +104,7 @@
 
         # Scrolled Window
         self.scrollwin = gtk.ScrolledWindow()
-        self.scrollwin.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC)
+        self.scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
         self.scrollwin.set_shadow_type(gtk.SHADOW_ETCHED_IN)
 
         # Popup Menu
@@ -131,7 +131,7 @@
 
         # import sources dialogbox
         self._importDialog = None
-        self._lastFolder = None
+        self._lastfolder = None
 
         # TreeView
         # Displays icon, name, type, length
@@ -303,6 +303,7 @@
         gobject.idle_add(self._displayTreeView, True, False)
 
     def showImportSourcesDialog(self, select_folders=False):
+        """Pop up the "Import Sources" dialog box"""
         if self._importDialog:
             return
 
@@ -321,19 +322,19 @@
         self._importDialog.set_default_response(gtk.RESPONSE_OK)
         self._importDialog.set_select_multiple(True)
         self._importDialog.set_modal(False)
-        if self._lastFolder:
-            self._importDialog.set_current_folder(self._lastFolder)
+        if self._lastfolder:
+            self._importDialog.set_current_folder(self._lastfolder)
         self._importDialog.connect('response', self._dialogBoxResponseCb, select_folders)
         self._importDialog.connect('close', self._dialogBoxCloseCb)
         self._importDialog.show()
 
-    def addFiles(self, list):
+    def addFiles(self, files):
         """ Add files to the list """
-        instance.PiTiVi.current.sources.addUris(list)
+        instance.PiTiVi.current.sources.addUris(files)
 
-    def addFolders(self, list):
+    def addFolders(self, folders):
         """ walks the trees of the folders in the list and adds the files it finds """
-        instance.PiTiVi.threads.addThread(PathWalker, list, instance.PiTiVi.current.sources.addUris)
+        instance.PiTiVi.threads.addThread(PathWalker, folders, instance.PiTiVi.current.sources.addUris)
 
     def _addFactory(self, factory):
         try:
@@ -408,7 +409,7 @@
     def _dialogBoxResponseCb(self, dialogbox, response, select_folders):
         gst.debug("response:%r" % response)
         if response == gtk.RESPONSE_OK:
-            self._lastFolder = dialogbox.get_current_folder()
+            self._lastfolder = dialogbox.get_current_folder()
             filenames = dialogbox.get_uris()
             if select_folders:
                 self.addFolders(filenames)
@@ -479,7 +480,7 @@
     ## Drag and Drop
 
     def _dndDataReceivedCb(self, unused_widget, unused_context, unused_x,
-                           unused_y, selection, targetType, unused_time):
+                           unused_y, selection, targettype, unused_time):
         def isfile(path):
             if path[:7] == "file://":
                 # either it's on local system and we know if it's a directory
@@ -490,13 +491,13 @@
             # or it's on local system with "file://"
             return os.path.isfile(path)
 
-        gst.debug("targetType:%d, selection.data:%r" % (targetType, selection.data))
+        gst.debug("targettype:%d, selection.data:%r" % (targettype, selection.data))
         directories = []
-        if targetType == dnd.TYPE_URI_LIST:
+        if targettype == dnd.TYPE_URI_LIST:
             incoming = [unquote(x.strip('\x00')) for x in selection.data.strip().split("\r\n") if x.strip('\x00')]
             filenames = [x for x in incoming if isfile(x)]
             directories = [x for x in incoming if not isfile(x)]
-        elif targetType == dnd.TYPE_TEXT_PLAIN:
+        elif targettype == dnd.TYPE_TEXT_PLAIN:
             incoming = selection.data.strip()
             if isfile(incoming):
                 filenames = [incoming]
@@ -521,17 +522,17 @@
         return [model[path][COL_URI] for path in rows]
 
     def _dndDataGetCb(self, unused_widget, unused_context, selection,
-                      targetType, unused_eventTime):
-        gst.info("data get, type:%d" % targetType)
+                      targettype, unused_eventtime):
+        gst.info("data get, type:%d" % targettype)
         uris = self.getSelectedItems()
         if len(uris) < 1:
             return
-        if targetType == dnd.TYPE_PITIVI_FILESOURCE:
+        if targettype == dnd.TYPE_PITIVI_FILESOURCE:
             selection.set(selection.target, 8,
                           uris[0])
-        elif targetType == dnd.TYPE_URI_LIST:
+        elif targettype == dnd.TYPE_URI_LIST:
             selection.set(selection.target, 8,
-                          string.join(uris, "\n"))
+                          '\n'.join(uris))
 
 class AudioFxListWidget(gtk.VBox):
     """ Widget for listing video effects """
@@ -740,7 +741,7 @@
         dbox = FileListErrorDialog(*msgs)
         dbox.connect("close", self._errorDialogBoxCloseCb)
         dbox.connect("response", self._errorDialogBoxResponseCb)
-        for uri,reason,extra in self.errors:
+        for uri, reason, extra in self.errors:
             dbox.addFailedFile(uri, reason, extra)
         dbox.show()
         # reset error list
@@ -779,11 +780,11 @@
             for path, dirs, files in os.walk(folder):
                 if self.stopme.isSet():
                     return
-                uriList = []
+                uris = []
                 for afile in files:
-                    uriList.append("file://%s" % os.path.join(path, afile))
-                if uriList:
-                    self.callback(uriList)
+                    uris.append("file://%s" % os.path.join(path, afile))
+                if uris:
+                    self.callback(uris)
 
     def abort(self):
         self.stopme.set()

Modified: trunk/pitivi/ui/viewer.py
==============================================================================
--- trunk/pitivi/ui/viewer.py	(original)
+++ trunk/pitivi/ui/viewer.py	Thu Oct 16 14:21:27 2008
@@ -295,7 +295,8 @@
         gst.info("value:%s, frame:%d" % (gst.TIME_ARGS(value), frame))
         self.current_time = value
         self.current_frame = frame
-        self.timelabel.set_markup("<tt>%s / %s</tt>" % (time_to_string(value), time_to_string(instance.PiTiVi.playground.current.length)))
+        self.timelabel.set_markup("<tt>%s / %s</tt>" % (time_to_string(value),
+                                                        time_to_string(instance.PiTiVi.playground.current.length)))
         if not self.moving_slider:
             self.posadjust.set_value(float(value))
         return False
@@ -307,7 +308,8 @@
         gst.debug("duration : %s" % gst.TIME_ARGS(duration))
         gst.debug("playground.current.length : %s" % gst.TIME_ARGS(instance.PiTiVi.playground.current.length))
         self.posadjust.upper = float(duration)
-        self.timelabel.set_markup("<tt>%s / %s</tt>" % (time_to_string(self.current_time), time_to_string(instance.PiTiVi.playground.current.length)))
+        self.timelabel.set_markup("<tt>%s / %s</tt>" % (time_to_string(self.current_time),
+                                                        time_to_string(instance.PiTiVi.playground.current.length)))
 
 
     def _backToDefaultCb(self):
@@ -403,7 +405,8 @@
                 self._timelineDurationChangedSigId = (None, None)
         else:
             if isinstance(smartbin, SmartTimelineBin):
-                gst.info("switching to Timeline, setting duration to %s" % (gst.TIME_ARGS(smartbin.project.timeline.videocomp.duration)))
+                gst.info("switching to Timeline, setting duration to %s" %
+                         (gst.TIME_ARGS(smartbin.project.timeline.videocomp.duration)))
                 self.posadjust.upper = float(smartbin.project.timeline.videocomp.duration)
                 # FIXME : we need to disconnect from this signal !
                 sigid = smartbin.project.timeline.videocomp.connect("start-duration-changed",

Modified: trunk/pitivi/utils.py
==============================================================================
--- trunk/pitivi/utils.py	(original)
+++ trunk/pitivi/utils.py	Thu Oct 16 14:21:27 2008
@@ -25,6 +25,7 @@
 import gst, bisect
 
 def time_to_string(value):
+    """ Converts the given time in nanoseconds to a human readable string """
     if value == gst.CLOCK_TIME_NONE:
         return "--:--:--.---"
     ms = value / gst.MSECOND
@@ -60,17 +61,17 @@
 # matches the list, this function returns the index of the lement closest to
 # value in the array.
 
-def binary_search(A, value):
+def binary_search(col, value):
     low = 0
-    high = len(A)
-    while (low < high): 
+    high = len(col)
+    while (low < high):
         mid = (low + high)/2
-        if (A[mid] < value):
+        if (col[mid] < value):
             low = mid + 1
         else:
-            #can't be high = mid-1: here A[mid] >= value,
-            #so high can't be < mid if A[mid] == value
-            high = mid; 
+            #can't be high = mid-1: here col[mid] >= value,
+            #so high can't be < mid if col[mid] == value
+            high = mid;
     return low
 
 # Returns the element of seq nearest to item, and the difference between them
@@ -96,10 +97,10 @@
 
 def argmax(func, seq):
     """return the element of seq that gives max(map(func, seq))"""
-    def compare(a, b):
-        if a[0] > b[0]:
-            return a
-        return b
+    def compare(a1, b1):
+        if a1[0] > b1[0]:
+            return a1
+        return b1
     # using a generator expression here should save memory
-    objs = ((func(x), x) for x in seq)
+    objs = ((func(val), val) for val in seq)
     return reduce(compare, objs)[1]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]