2008-02-22 Raphael Ackermann <raphael.ackermann@gmail.com>

* various (294 files)
	pep8 doc fixes & pylint fixes

svn: r10103
This commit is contained in:
Raphael Ackermann
2008-02-24 13:55:55 +00:00
parent 2180fa02cb
commit c962d5e6e1
294 changed files with 2925 additions and 2571 deletions

View File

@@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
# $Id:_Options.py 9912 2008-01-22 09:17:46Z acraphae $
# Written by Alex Roitman
@@ -38,10 +38,10 @@ import os
#
#-------------------------------------------------------------------------
try:
from xml.sax import make_parser,handler,SAXParseException
from xml.sax import make_parser, handler,SAXParseException
from xml.sax.saxutils import escape
except:
from _xmlplus.sax import make_parser,handler,SAXParseException
from _xmlplus.sax import make_parser, handler,SAXParseException
from _xmlplus.sax.saxutils import escape
#-------------------------------------------------------------------------
@@ -64,9 +64,9 @@ class OptionList:
def __init__(self):
self.options = {}
def set_options(self,options):
def set_options(self, options):
"""
Sets the whole bunch of options for the OptionList.
Set the whole bunch of options for the OptionList.
@param options: list of options to set.
@type options: list
"""
@@ -74,15 +74,15 @@ class OptionList:
def get_options(self):
"""
Returns the whole bunch of options for the OptionList.
Return the whole bunch of options for the OptionList.
@returns: list of options
@rtype: list
"""
return self.options
def set_option(self,name,value):
def set_option(self, name,value):
"""
Sets a particular option in the OptionList.
Set a particular option in the OptionList.
@param name: name of the option to set.
@type name: str
@param value: value of the option to set.
@@ -90,18 +90,18 @@ class OptionList:
"""
self.options[name] = value
def remove_option(self,name):
def remove_option(self, name):
"""
Removes a particular option from the OptionList.
Remove a particular option from the OptionList.
@param name: name of the option to remove.
@type name: str
"""
if self.options.has_key(name):
del self.options[name]
def get_option(self,name):
def get_option(self, name):
"""
Returns the value of a particular option in the OptionList.
Return the value of a particular option in the OptionList.
@param name: name of the option to retrieve
@type name: str
@returns: value associated with the passed option
@@ -121,7 +121,7 @@ class OptionListCollection:
def __init__(self,filename):
"""
Creates an OptionListCollection instance from the list defined
Create an OptionListCollection instance from the list defined
in the specified file.
@param filename: XML file that contains option definitions
@type filename: str
@@ -137,15 +137,15 @@ class OptionListCollection:
def get_option_list_map(self):
"""
Returns the map of module names to option lists.
Return the map of module names to option lists.
@returns: Returns the map of module names to option lists.
@rtype: dictionary
"""
return self.option_list_map
def get_option_list(self,name):
def get_option_list(self, name):
"""
Returns the option_list associated with the module name
Return the option_list associated with the module name
@param name: name associated with the desired module.
@type name: str
@returns: returns the option list associated with the name,
@@ -156,15 +156,15 @@ class OptionListCollection:
def get_module_names(self):
"""
Returns a list of all the module names in the OptionListCollection
Return a list of all the module names in the OptionListCollection
@returns: returns the list of module names
@rtype: list
"""
return self.option_list_map.keys()
def set_option_list(self,name,option_list):
def set_option_list(self, name, option_list):
"""
Adds or replaces an option_list in the OptionListCollection.
Add or replaces an option_list in the OptionListCollection.
@param name: name assocated with the module to add or replace.
@type name: str
@param option_list: list of options
@@ -178,7 +178,7 @@ class OptionListCollection:
"""
pass
def write_module_common(self,f,option_list):
def write_module_common(self,f, option_list):
"""
Stub function for common options. Overridden by reports.
"""
@@ -213,7 +213,7 @@ class OptionListCollection:
escape(option_name),
escape(unicode(options[option_name]))) )
self.write_module_common(f,option_list)
self.write_module_common(f, option_list)
f.write('</module>\n')
@@ -244,7 +244,7 @@ class OptionParser(handler.ContentHandler):
def __init__(self,collection):
"""
Creates a OptionParser class that populates the passed collection.
Create a OptionParser class that populates the passed collection.
collection: OptionListCollection to be loaded from the file.
"""
@@ -293,7 +293,7 @@ class OptionHandler:
Implements handling of the options for the plugins.
"""
def __init__(self,module_name,options_dict,person_id=None):
def __init__(self,module_name, options_dict,person_id=None):
self.module_name = module_name
self.default_options_dict = options_dict.copy()
self.options_dict = options_dict
@@ -324,7 +324,7 @@ class OptionHandler:
def set_options(self):
"""
Sets options to be used in this plugin according to the passed
Set options to be used in this plugin according to the passed
options dictionary.
Dictionary values are all strings, since they were read from XML.
@@ -399,13 +399,13 @@ class Options:
"""
Defines options and provides handling interface.
This is a base Options class for the modules. All modules' options
This is a base Options class for the modules. All modules, options
classes should derive from it.
"""
def __init__(self,name,person_id=None):
def __init__(self, name,person_id=None):
"""
Initializes the class, performing usual house-keeping tasks.
Initialize the class, performing usual house-keeping tasks.
Subclasses MUST call this in their __init__() method.
Modules that need custom options need to override this method.
@@ -442,7 +442,7 @@ class Options:
def add_user_options(self,dialog):
"""
Sets up UI controls (widgets) for the options specific for this modul.
Set up UI controls (widgets) for the options specific for this modul.
This method MUST be overridden by modules that define new options.
The single argument 'dialog' is the Report.BareReportDialog instance.

View File

@@ -198,17 +198,17 @@ def register_tool(
(junk,gui_task) = divmod(modes,2**_Tool.MODE_GUI)
if gui_task:
_register_gui_tool(tool_class,options_class,translated_name,
_register_gui_tool(tool_class, options_class,translated_name,
name,category,description,
status,author_name,author_email,unsupported,
require_active)
(junk,cli_task) = divmod(modes-gui_task,2**_Tool.MODE_CLI)
if cli_task:
_register_cli_tool(name,category,tool_class,options_class,
_register_cli_tool(name,category,tool_class, options_class,
translated_name,unsupported)
def _register_gui_tool(tool_class,options_class,translated_name,
def _register_gui_tool(tool_class, options_class,translated_name,
name,category,
description=_unavailable,
status=_("Unknown"),
@@ -224,11 +224,11 @@ def _register_gui_tool(tool_class,options_class,translated_name,
if del_index != -1:
del tool_list[del_index]
mod2text[tool_class.__module__] = description
tool_list.append((tool_class,options_class,translated_name,
category,name,description,status,
tool_list.append((tool_class, options_class,translated_name,
category, name,description,status,
author_name,author_email,unsupported, require_active))
def _register_cli_tool(name,category,tool_class,options_class,
def _register_cli_tool(name,category,tool_class, options_class,
translated_name,unsupported=False):
del_index = -1
for i in range(0,len(cli_tool_list)):
@@ -237,7 +237,7 @@ def _register_cli_tool(name,category,tool_class,options_class,
del_index = i
if del_index != -1:
del cli_tool_list[del_index]
cli_tool_list.append((name,category,tool_class,options_class,
cli_tool_list.append((name,category,tool_class, options_class,
translated_name,unsupported, None))
#-------------------------------------------------------------------------
@@ -269,7 +269,7 @@ def register_report(
"""
(junk,standalone_task) = divmod(modes,2**MODE_GUI)
if standalone_task:
_register_standalone(report_class,options_class,translated_name,
_register_standalone(report_class, options_class,translated_name,
name,category,description,
status,author_name,author_email,unsupported,
require_active)
@@ -278,13 +278,13 @@ def register_report(
if book_item_task:
book_item_category = book_categories[category]
register_book_item(translated_name,book_item_category,
report_class,options_class,name,unsupported,
report_class, options_class, name,unsupported,
require_active)
(junk,command_line_task) = divmod(modes-standalone_task-book_item_task,
2**MODE_CLI)
if command_line_task:
_register_cl_report(name,category,report_class,options_class,
_register_cl_report(name,category,report_class, options_class,
translated_name,unsupported, require_active)
def _register_standalone(report_class, options_class, translated_name, name,

View File

@@ -117,7 +117,7 @@ class PluginStatus(ManagedWindow.ManagedWindow):
if data:
PluginTrace(self.uistate, self.track, data, name)
def build_menu_names(self,obj):
def build_menu_names(self, obj):
return ( _('Summary'),self.title)
#-------------------------------------------------------------------------
@@ -130,7 +130,7 @@ class PluginTrace(ManagedWindow.ManagedWindow):
def __init__(self, uistate, track, data, name):
self.name = name
title = "%s: %s" % (_("Plugin Status"),name)
title = "%s: %s" % (_("Plugin Status"), name)
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
self.set_window(gtk.Dialog("",uistate.window,
@@ -150,7 +150,7 @@ class PluginTrace(ManagedWindow.ManagedWindow):
self.window.vbox.add(scrolled_window)
self.window.show_all()
def build_menu_names(self,obj):
def build_menu_names(self, obj):
return (self.name, None)
@@ -467,7 +467,7 @@ class ToolManagedWindowBatch(Tool.BatchTool, ToolManagedWindowBase):
# This constructor will ask a question, set self.fail:
self.dbstate = dbstate
self.uistate = uistate
Tool.BatchTool.__init__(self,dbstate,options_class,name)
Tool.BatchTool.__init__(self,dbstate, options_class, name)
if not self.fail:
ToolManagedWindowBase.__init__(self, dbstate, uistate,
options_class, name, callback)
@@ -476,6 +476,6 @@ class ToolManagedWindow(Tool.Tool, ToolManagedWindowBase):
def __init__(self, dbstate, uistate, options_class, name, callback=None):
self.dbstate = dbstate
self.uistate = uistate
Tool.Tool.__init__(self,dbstate,options_class,name)
Tool.Tool.__init__(self,dbstate, options_class, name)
ToolManagedWindowBase.__init__(self, dbstate, uistate, options_class,
name, callback)

View File

@@ -145,36 +145,36 @@ class PluginDialog(ManagedWindow.ManagedWindow):
# This method needs to be overridden in the subclass
assert False, "This method needs to be overridden in the subclass."
def build_menu_names(self,obj):
def build_menu_names(self, obj):
return (self.msg,None)
def on_apply_clicked(self,obj):
def on_apply_clicked(self, obj):
"""Execute the selected report"""
try:
(item_class,options_class,title,category,
(item_class, options_class,title,category,
name,require_active) = self.item
if self.content == REPORTS:
report(self.state,self.uistate,self.state.active,
item_class,options_class,title,name,category,require_active)
item_class, options_class,title, name,category,require_active)
else:
_Tool.gui_tool(self.state,self.uistate,
item_class,options_class,title,name,category,
item_class, options_class,title, name,category,
self.state.db.request_rebuild)
except TypeError:
pass # ignore pressing apply without a plugin being selected
def on_node_selected(self,obj):
def on_node_selected(self, obj):
"""Updates the informational display on the right hand side of
the dialog box with the description of the selected report"""
store,node = self.selection.get_selected()
store, node = self.selection.get_selected()
if node:
path = store.get_path(node)
if not node or not self.imap.has_key(path):
return
data = self.imap[path]
(report_class,options_class,title,category,name,
(report_class, options_class,title,category, name,
doc,status,author,email,unsupported,require_active) = data
self.description.set_text(doc)
if unsupported:
@@ -185,7 +185,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
self.title.set_use_markup(1)
self.author_name.set_text(author)
self.author_email.set_text(email)
self.item = (report_class,options_class,title,category,
self.item = (report_class, options_class,title,category,
name,require_active)
def build_plugin_tree(self,item_list,categories):
@@ -193,7 +193,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
in the lists. The list must consist of a tuples with the following
format:
(item_class,options_class,title,category,name,
(item_class, options_class,title,category, name,
doc,status,author,email)
Items in the same category are grouped under the same submenu.
@@ -230,7 +230,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
next = None
data.sort(lambda x,y: cmp(x[2],y[2]))
for item in data:
next = self.store.insert_after(node,next)
next = self.store.insert_after(node, next)
ilist.append((next,item))
self.store.set(next,0,item[2])
for key in key_list:
@@ -240,7 +240,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
next = None
data.sort(lambda x,y: cmp(x[2],y[2]))
for item in data:
next = self.store.insert_after(node,next)
next = self.store.insert_after(node, next)
ilist.append((next,item))
self.store.set(next,0,item[2])
for next,tab in ilist:
@@ -320,7 +320,7 @@ class Reload(_Tool.Tool):
Treated as a callback, causes all plugins to get reloaded.
This is useful when writing and debugging a plugin.
"""
_Tool.Tool.__init__(self,dbstate,options_class,name)
_Tool.Tool.__init__(self,dbstate, options_class, name)
pymod = re.compile(r"^(.*)\.py$")
@@ -397,8 +397,8 @@ class ReloadOptions(_Tool.ToolOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
_Tool.ToolOptions.__init__(self,name,person_id)
def __init__(self, name,person_id=None):
_Tool.ToolOptions.__init__(self, name,person_id)
#-------------------------------------------------------------------------
#

View File

@@ -152,11 +152,11 @@ class ActivePersonTool(Tool):
#------------------------------------------------------------------------
class CommandLineTool:
"""
Provides a way to run tool from the command line.
Provide a way to run tool from the command line.
"""
def __init__(self,database,name,category,option_class,options_str_dict,
def __init__(self,database, name,category, option_class, options_str_dict,
noopt=False):
self.database = database
self.category = category
@@ -254,10 +254,10 @@ def gui_tool(dbstate, uistate, tool_class, options_class, translated_name,
log.error("Failed to start tool.", exc_info=True)
# Command-line generic task
def cli_tool(dbstate,name,category,tool_class,options_class,options_str_dict):
def cli_tool(dbstate, name,category,tool_class, options_class, options_str_dict):
clt = CommandLineTool(dbstate.db,name,category,
options_class,options_str_dict)
clt = CommandLineTool(dbstate.db, name,category,
options_class, options_str_dict)
# Exit here if show option was given
if clt.show:
@@ -265,7 +265,7 @@ def cli_tool(dbstate,name,category,tool_class,options_class,options_str_dict):
# run tool
try:
tool_class(dbstate,None,options_class,name,None)
tool_class(dbstate,None, options_class, name,None)
except:
log.error("Failed to start tool.", exc_info=True)
@@ -278,8 +278,8 @@ class ToolOptionHandler(OptionHandler):
"""
Implements handling of the options for the plugins.
"""
def __init__(self,module_name,options_dict,person_id=None):
OptionHandler.__init__(self,module_name,options_dict,person_id)
def __init__(self,module_name, options_dict,person_id=None):
OptionHandler.__init__(self,module_name, options_dict,person_id)
def init_subclass(self):
self.collection_class = OptionListCollection
@@ -296,13 +296,13 @@ class ToolOptions(Options):
"""
Defines options and provides handling interface.
This is a base Options class for the tools. All tools' options
This is a base Options class for the tools. All tools, options
classes should derive from it.
"""
def __init__(self,name,person_id=None):
def __init__(self, name,person_id=None):
"""
Initializes the class, performing usual house-keeping tasks.
Initialize the class, performing usual house-keeping tasks.
Subclasses MUST call this in their __init__() method.
"""
self.name = name