From aa800b3ad6d2ec5164fdfeecdb6006d308ea80cc Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 2 Jun 2009 12:09:34 +0000 Subject: [PATCH] Misc PEP8 cleanup. svn: r12610 --- src/ReportBase/_DocReportDialog.py | 31 ++++++------ src/ReportBase/_ReportDialog.py | 8 +-- src/ReportBase/_ReportOptions.py | 78 +++++++++++++++--------------- src/gen/plug/docgen/stylesheet.py | 2 +- 4 files changed, 61 insertions(+), 58 deletions(-) diff --git a/src/ReportBase/_DocReportDialog.py b/src/ReportBase/_DocReportDialog.py index ce2a616d1..d4484e465 100644 --- a/src/ReportBase/_DocReportDialog.py +++ b/src/ReportBase/_DocReportDialog.py @@ -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('%s'%_("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('%s' % _("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 = "" diff --git a/src/ReportBase/_ReportDialog.py b/src/ReportBase/_ReportDialog.py index 486ed262b..895254b6d 100644 --- a/src/ReportBase/_ReportDialog.py +++ b/src/ReportBase/_ReportDialog.py @@ -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.""" diff --git a/src/ReportBase/_ReportOptions.py b/src/ReportBase/_ReportOptions.py index 7251cad09..90ee4e800 100644 --- a/src/ReportBase/_ReportOptions.py +++ b/src/ReportBase/_ReportOptions.py @@ -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('\n') if self.get_last_paper_metric() != self.default_paper_metric: f.write(' \n' % self.get_last_paper_metric() ) @@ -410,7 +410,7 @@ class OptionListCollection(_Options.OptionListCollection): f.write(' \n' % self.get_last_orientation() ) f.write('\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('