Misc PEP8 cleanup.
svn: r12610
This commit is contained in:
parent
0aedf53b6b
commit
aa800b3ad6
@ -78,7 +78,7 @@ class DocReportDialog(ReportDialog):
|
||||
# Functions related to selecting/changing the current file format.
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def make_doc_menu(self,active=None):
|
||||
def make_doc_menu(self, active=None):
|
||||
"""Build a menu of document types that are appropriate for
|
||||
this report. This menu will be generated based upon the type
|
||||
of document (text, draw, graph, etc. - a subclass), whether or
|
||||
@ -118,12 +118,12 @@ class DocReportDialog(ReportDialog):
|
||||
if docgen_plugin.get_paper_used():
|
||||
self.paper_label = gtk.Label('<b>%s</b>'%_("Paper Options"))
|
||||
self.paper_label.set_use_markup(True)
|
||||
self.notebook.insert_page(self.paper_frame,self.paper_label,0)
|
||||
self.notebook.insert_page(self.paper_frame, self.paper_label, 0)
|
||||
self.paper_frame.show_all()
|
||||
else:
|
||||
self.html_label = gtk.Label('<b>%s</b>' % _("HTML Options"))
|
||||
self.html_label.set_use_markup(True)
|
||||
self.notebook.insert_page(self.html_table,self.html_label,0)
|
||||
self.notebook.insert_page(self.html_table, self.html_label, 0)
|
||||
self.html_table.show_all()
|
||||
|
||||
ext_val = docgen_plugin.get_extension()
|
||||
@ -150,11 +150,11 @@ class DocReportDialog(ReportDialog):
|
||||
work."""
|
||||
|
||||
self.make_doc_menu(self.options.handler.get_format_name())
|
||||
self.format_menu.connect('changed',self.doc_type_changed)
|
||||
self.format_menu.connect('changed', self.doc_type_changed)
|
||||
label = gtk.Label("%s:" % _("Output Format"))
|
||||
label.set_alignment(0.0,0.5)
|
||||
self.tbl.attach(label,1,2,self.row,self.row+1,gtk.SHRINK|gtk.FILL)
|
||||
self.tbl.attach(self.format_menu,2,4,self.row,self.row+1,
|
||||
label.set_alignment(0.0, 0.5)
|
||||
self.tbl.attach(label, 1, 2, self.row, self.row+1, gtk.SHRINK|gtk.FILL)
|
||||
self.tbl.attach(self.format_menu, 2, 4, self.row, self.row+1,
|
||||
yoptions=gtk.SHRINK)
|
||||
self.row += 1
|
||||
|
||||
@ -199,13 +199,13 @@ class DocReportDialog(ReportDialog):
|
||||
this function is to grab a pointer for later use in the parse
|
||||
html frame function."""
|
||||
|
||||
self.html_table = gtk.Table(3,3)
|
||||
self.html_table = gtk.Table(3, 3)
|
||||
self.html_table.set_col_spacings(12)
|
||||
self.html_table.set_row_spacings(6)
|
||||
self.html_table.set_border_width(0)
|
||||
|
||||
label = gtk.Label("%s:" % _("Template"))
|
||||
label.set_alignment(0.0,0.5)
|
||||
label.set_alignment(0.0, 0.5)
|
||||
self.html_table.attach(label, 1, 2, 1, 2, gtk.SHRINK|gtk.FILL,
|
||||
yoptions=gtk.SHRINK)
|
||||
|
||||
@ -223,11 +223,12 @@ class DocReportDialog(ReportDialog):
|
||||
active_index = template_index
|
||||
self.template_combo.append_text(_user_template)
|
||||
|
||||
self.template_combo.connect('changed',self.html_file_enable)
|
||||
self.template_combo.connect('changed', self.html_file_enable)
|
||||
|
||||
self.html_table.attach(self.template_combo,2,3,1,2, yoptions=gtk.SHRINK)
|
||||
self.html_table.attach(self.template_combo, 2, 3, 1, 2,
|
||||
yoptions=gtk.SHRINK)
|
||||
label = gtk.Label("%s:" % _("User Template"))
|
||||
label.set_alignment(0.0,0.5)
|
||||
label.set_alignment(0.0, 0.5)
|
||||
self.html_table.attach(label, 1, 2, 2, 3, gtk.SHRINK|gtk.FILL,
|
||||
yoptions=gtk.SHRINK)
|
||||
self.html_fileentry = FileEntry("HTML_Template",
|
||||
@ -242,7 +243,8 @@ class DocReportDialog(ReportDialog):
|
||||
|
||||
if os.path.isfile(user_template):
|
||||
self.html_fileentry.set_filename(user_template)
|
||||
self.html_table.attach(self.html_fileentry,2,3,2,3, yoptions=gtk.SHRINK)
|
||||
self.html_table.attach(self.html_fileentry, 2, 3, 2, 3,
|
||||
yoptions=gtk.SHRINK)
|
||||
self.template_combo.set_active(active_index)
|
||||
|
||||
def parse_format_frame(self):
|
||||
@ -267,7 +269,8 @@ class DocReportDialog(ReportDialog):
|
||||
if text == _user_template:
|
||||
self.template_name = self.html_fileentry.get_full_path(0)
|
||||
else:
|
||||
self.template_name = "%s%s%s" % (const.TEMPLATE_DIR, os.path.sep,
|
||||
self.template_name = "%s%s%s" % (const.TEMPLATE_DIR,
|
||||
os.path.sep,
|
||||
_template_map[text])
|
||||
else:
|
||||
self.template_name = ""
|
||||
|
@ -27,7 +27,7 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
from types import ClassType, InstanceType
|
||||
from types import ClassType
|
||||
from gettext import gettext as _
|
||||
|
||||
import logging
|
||||
@ -99,7 +99,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
|
||||
def init_options(self, option_class):
|
||||
try:
|
||||
if (issubclass(option_class, object) or # New-style class
|
||||
isinstance(options_class, ClassType)): # Old-style class
|
||||
isinstance(option_class, ClassType)): # Old-style class
|
||||
self.options = option_class(self.raw_name, self.db)
|
||||
except TypeError:
|
||||
self.options = option_class
|
||||
@ -205,7 +205,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
|
||||
appended to the Options section of the dialog. The text string
|
||||
is used to create a label for the passed widget. This allows the
|
||||
subclass to extend the Options section with its own widgets. The
|
||||
subclass is reponsible for all managing of the widgets, including
|
||||
subclass is responsible for all managing of the widgets, including
|
||||
extracting the final value before the report executes. This task
|
||||
should only be called in the add_user_options task."""
|
||||
self.widgets.append((label_text, widget))
|
||||
@ -215,7 +215,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
|
||||
text string and a Gtk Widget. When the interface is built,
|
||||
all widgets with the same frame_name are grouped into a
|
||||
GtkFrame. This allows the subclass to create its own sections,
|
||||
filling them with its own widgets. The subclass is reponsible for
|
||||
filling them with its own widgets. The subclass is responsible for
|
||||
all managing of the widgets, including extracting the final value
|
||||
before the report executes. This task should only be called in
|
||||
the add_user_options task."""
|
||||
|
@ -79,7 +79,7 @@ class OptionList(_Options.OptionList):
|
||||
self.template_name = None
|
||||
self.format_name = None
|
||||
|
||||
def set_style_name(self,style_name):
|
||||
def set_style_name(self, style_name):
|
||||
"""
|
||||
Set the style name for the OptionList.
|
||||
@param style_name: name of the style to set.
|
||||
@ -95,7 +95,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
return self.style_name
|
||||
|
||||
def set_paper_metric(self,paper_metric):
|
||||
def set_paper_metric(self, paper_metric):
|
||||
"""
|
||||
Set the paper metric for the OptionList.
|
||||
@param paper_metric: whether to use metric.
|
||||
@ -111,7 +111,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
return self.paper_metric
|
||||
|
||||
def set_paper_name(self,paper_name):
|
||||
def set_paper_name(self, paper_name):
|
||||
"""
|
||||
Set the paper name for the OptionList.
|
||||
@param paper_name: name of the paper to set.
|
||||
@ -145,7 +145,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
return self.orientation
|
||||
|
||||
def set_custom_paper_size(self,paper_size):
|
||||
def set_custom_paper_size(self, paper_size):
|
||||
"""
|
||||
Set the custom paper size for the OptionList.
|
||||
@param paper_size: paper size to set in cm.
|
||||
@ -161,7 +161,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
return self.custom_paper_size
|
||||
|
||||
def set_margins(self,margins):
|
||||
def set_margins(self, margins):
|
||||
"""
|
||||
Set the margins for the OptionList.
|
||||
@param margins: margins to set. Possible values are floats in cm
|
||||
@ -177,7 +177,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
return copy.copy(self.margins)
|
||||
|
||||
def set_margin(self,pos,value):
|
||||
def set_margin(self, pos, value):
|
||||
"""
|
||||
Set a margin for the OptionList.
|
||||
@param pos: Position of margin [left, right, top, bottom]
|
||||
@ -187,7 +187,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
self.margins[pos] = value
|
||||
|
||||
def get_margin(self,pos):
|
||||
def get_margin(self, pos):
|
||||
"""
|
||||
Return a margin for the OptionList.
|
||||
@param pos: Position of margin [left, right, top, bottom]
|
||||
@ -197,7 +197,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
return self.margins[pos]
|
||||
|
||||
def set_template_name(self,template_name):
|
||||
def set_template_name(self, template_name):
|
||||
"""
|
||||
Set the template name for the OptionList.
|
||||
@param template_name: name of the template to set.
|
||||
@ -213,7 +213,7 @@ class OptionList(_Options.OptionList):
|
||||
"""
|
||||
return self.template_name
|
||||
|
||||
def set_format_name(self,format_name):
|
||||
def set_format_name(self, format_name):
|
||||
"""
|
||||
Set the format name for the OptionList.
|
||||
@param format_name: name of the format to set.
|
||||
@ -238,8 +238,8 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
Implements a collection of option lists.
|
||||
"""
|
||||
def __init__(self,filename):
|
||||
_Options.OptionListCollection.__init__(self,filename)
|
||||
def __init__(self, filename):
|
||||
_Options.OptionListCollection.__init__(self, filename)
|
||||
|
||||
def init_common(self):
|
||||
# Default values for common options
|
||||
@ -261,7 +261,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
self.last_format_name = self.default_format_name
|
||||
self.option_list_map = {}
|
||||
|
||||
def set_last_paper_metric(self,paper_metric):
|
||||
def set_last_paper_metric(self, paper_metric):
|
||||
"""
|
||||
Set the last paper metric used for the any report in this collection.
|
||||
@param paper_metric: whether to use metric.
|
||||
@ -277,7 +277,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
return self.last_paper_metric
|
||||
|
||||
def set_last_paper_name(self,paper_name):
|
||||
def set_last_paper_name(self, paper_name):
|
||||
"""
|
||||
Set the last paper name used for the any report in this collection.
|
||||
@param paper_name: name of the paper to set.
|
||||
@ -310,7 +310,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
return self.last_orientation
|
||||
|
||||
def set_last_custom_paper_size(self,custom_paper_size):
|
||||
def set_last_custom_paper_size(self, custom_paper_size):
|
||||
"""
|
||||
Set the last custom paper size used for the any report in this collection.
|
||||
@param custom_paper_size: size to set in cm (width, height)
|
||||
@ -327,7 +327,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
return copy.copy(self.last_custom_paper_size)
|
||||
|
||||
def set_last_margins(self,margins):
|
||||
def set_last_margins(self, margins):
|
||||
"""
|
||||
Set the last margins used for the any report in this collection.
|
||||
@param margins: margins to set in cm (left, right, top, bottom)
|
||||
@ -344,7 +344,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
return copy.copy(self.last_margins)
|
||||
|
||||
def set_last_margin(self,pos,value):
|
||||
def set_last_margin(self, pos, value):
|
||||
"""
|
||||
Set the last margin used for the any report in this collection.
|
||||
@param pos: pos to set (0-4) (left, right, top, bottom)
|
||||
@ -354,7 +354,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
self.last_margins[pos] = value
|
||||
|
||||
def get_last_margin(self,pos):
|
||||
def get_last_margin(self, pos):
|
||||
"""
|
||||
Return the last margins used for the any report in this
|
||||
collection.
|
||||
@ -365,7 +365,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
return self.last_margins[pos]
|
||||
|
||||
def set_last_template_name(self,template_name):
|
||||
def set_last_template_name(self, template_name):
|
||||
"""
|
||||
Set the last template used for the any report in this collection.
|
||||
|
||||
@ -379,7 +379,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
return self.last_template_name
|
||||
|
||||
def set_last_format_name(self,format_name):
|
||||
def set_last_format_name(self, format_name):
|
||||
"""
|
||||
Set the last format used for the any report in this collection.
|
||||
|
||||
@ -393,7 +393,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
"""
|
||||
return self.last_format_name
|
||||
|
||||
def write_common(self,f):
|
||||
def write_common(self, f):
|
||||
f.write('<last-common>\n')
|
||||
if self.get_last_paper_metric() != self.default_paper_metric:
|
||||
f.write(' <metric value="%d"/>\n' % self.get_last_paper_metric() )
|
||||
@ -410,7 +410,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
f.write(' <orientation value="%d"/>\n' % self.get_last_orientation() )
|
||||
f.write('</last-common>\n')
|
||||
|
||||
def write_module_common(self,f, option_list):
|
||||
def write_module_common(self, f, option_list):
|
||||
if option_list.get_style_name() \
|
||||
and option_list.get_style_name() != self.default_style_name:
|
||||
f.write(' <style name="%s"/>\n' % escxml(option_list.get_style_name()) )
|
||||
@ -450,7 +450,7 @@ class OptionListCollection(_Options.OptionListCollection):
|
||||
the_file = open(self.filename)
|
||||
p.parse(the_file)
|
||||
the_file.close()
|
||||
except (IOError,OSError,SAXParseException):
|
||||
except (IOError, OSError, SAXParseException):
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -463,17 +463,17 @@ class OptionParser(_Options.OptionParser):
|
||||
SAX parsing class for the OptionListCollection XML file.
|
||||
"""
|
||||
|
||||
def __init__(self,collection):
|
||||
def __init__(self, collection):
|
||||
"""
|
||||
Create a OptionParser class that populates the passed collection.
|
||||
|
||||
collection: BookList to be loaded from the file.
|
||||
"""
|
||||
_Options.OptionParser.__init__(self,collection)
|
||||
_Options.OptionParser.__init__(self, collection)
|
||||
self.common = False
|
||||
self.list_class = OptionList
|
||||
|
||||
def startElement(self,tag,attrs):
|
||||
def startElement(self, tag, attrs):
|
||||
"""
|
||||
Overridden class that handles the start of a XML element
|
||||
"""
|
||||
@ -524,16 +524,16 @@ class OptionParser(_Options.OptionParser):
|
||||
self.option_list.set_margin(pos, value)
|
||||
else:
|
||||
# Tag is not report-specific, so we let the base class handle it.
|
||||
_Options.OptionParser.startElement(self,tag,attrs)
|
||||
_Options.OptionParser.startElement(self, tag, attrs)
|
||||
|
||||
def endElement(self,tag):
|
||||
def endElement(self, tag):
|
||||
"Overridden class that handles the end of a XML element"
|
||||
# First we try report-specific tags
|
||||
if tag == "last-common":
|
||||
self.common = False
|
||||
else:
|
||||
# Tag is not report-specific, so we let the base class handle it.
|
||||
_Options.OptionParser.endElement(self,tag)
|
||||
_Options.OptionParser.endElement(self, tag)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -564,7 +564,7 @@ class OptionHandler(_Options.OptionHandler):
|
||||
"""
|
||||
Implements handling of the options for the plugins.
|
||||
"""
|
||||
def __init__(self,module_name, options_dict):
|
||||
def __init__(self, module_name, options_dict):
|
||||
_Options.OptionHandler.__init__(self, module_name, options_dict, None)
|
||||
|
||||
def init_subclass(self):
|
||||
@ -639,25 +639,25 @@ class OptionHandler(_Options.OptionHandler):
|
||||
def get_default_stylesheet_name(self):
|
||||
return self.style_name
|
||||
|
||||
def set_default_stylesheet_name(self,style_name):
|
||||
def set_default_stylesheet_name(self, style_name):
|
||||
self.style_name = style_name
|
||||
|
||||
def get_format_name(self):
|
||||
return self.format_name
|
||||
|
||||
def set_format_name(self,format_name):
|
||||
def set_format_name(self, format_name):
|
||||
self.format_name = format_name
|
||||
|
||||
def get_paper_metric(self):
|
||||
return self.paper_metric
|
||||
|
||||
def set_paper_metric(self,paper_metric):
|
||||
def set_paper_metric(self, paper_metric):
|
||||
self.paper_metric = paper_metric
|
||||
|
||||
def get_paper_name(self):
|
||||
return self.paper_name
|
||||
|
||||
def set_paper_name(self,paper_name):
|
||||
def set_paper_name(self, paper_name):
|
||||
self.paper_name = paper_name
|
||||
|
||||
def get_paper(self):
|
||||
@ -666,7 +666,7 @@ class OptionHandler(_Options.OptionHandler):
|
||||
"""
|
||||
return self.paper
|
||||
|
||||
def set_paper(self,paper):
|
||||
def set_paper(self, paper):
|
||||
"""
|
||||
This method is for temporary storage, not for saving/restoring.
|
||||
"""
|
||||
@ -675,7 +675,7 @@ class OptionHandler(_Options.OptionHandler):
|
||||
def get_template_name(self):
|
||||
return self.template_name
|
||||
|
||||
def set_template_name(self,template_name):
|
||||
def set_template_name(self, template_name):
|
||||
self.template_name = template_name
|
||||
|
||||
def get_orientation(self):
|
||||
@ -687,7 +687,7 @@ class OptionHandler(_Options.OptionHandler):
|
||||
def get_custom_paper_size(self):
|
||||
return copy.copy(self.custom_paper_size)
|
||||
|
||||
def set_custom_paper_size(self,custom_paper_size):
|
||||
def set_custom_paper_size(self, custom_paper_size):
|
||||
self.custom_paper_size = copy.copy(custom_paper_size)
|
||||
|
||||
def get_margins(self):
|
||||
@ -763,7 +763,7 @@ class ReportOptions(_Options.Options):
|
||||
"""
|
||||
return self.handler.doc
|
||||
|
||||
def set_document(self,val):
|
||||
def set_document(self, val):
|
||||
"""
|
||||
Set document to a given instance.
|
||||
|
||||
@ -779,7 +779,7 @@ class ReportOptions(_Options.Options):
|
||||
"""
|
||||
return self.handler.output
|
||||
|
||||
def set_output(self,val):
|
||||
def set_output(self, val):
|
||||
"""
|
||||
Set output destination to a given string.
|
||||
|
||||
@ -792,7 +792,7 @@ class ReportOptions(_Options.Options):
|
||||
# MenuReportOptions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MenuReportOptions(GuiMenuOptions,ReportOptions):
|
||||
class MenuReportOptions(GuiMenuOptions, ReportOptions):
|
||||
"""
|
||||
|
||||
The MenuReportOptions class implementes the ReportOptions
|
||||
|
@ -205,7 +205,7 @@ class StyleSheetList(object):
|
||||
the_file = open(self.__file)
|
||||
parser.parse(the_file)
|
||||
the_file.close()
|
||||
except (IOError,OSError,SAXParseException):
|
||||
except (IOError, OSError, SAXParseException):
|
||||
pass
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user