[gedit-latex] fix style of py files in base/ according to PEP 8.
- From: Jose Aliste <jaliste src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-latex] fix style of py files in base/ according to PEP 8.
- Date: Tue, 28 Jun 2011 22:43:11 +0000 (UTC)
commit f9ca6a9f9ba3fb1f97c7f97885b0018c042c7def
Author: Josà Aliste <jaliste src gnome org>
Date: Tue Jun 28 18:38:35 2011 -0400
fix style of py files in base/ according to PEP 8.
latex/base/__init__.py | 21 ++++++++-------------
latex/base/completion.py | 13 +++++--------
latex/base/config.py | 28 ++++++++++++++--------------
latex/base/decorators.py | 1 +
latex/base/templates.py | 9 +++------
latex/base/windowactivatable.py | 32 +++++++++++++++++---------------
6 files changed, 48 insertions(+), 56 deletions(-)
---
diff --git a/latex/base/__init__.py b/latex/base/__init__.py
index c651220..2071f71 100644
--- a/latex/base/__init__.py
+++ b/latex/base/__init__.py
@@ -153,7 +153,6 @@ class BottomView(View, Gtk.HBox):
self._context = None
-
class Template(object):
"""
This one is exposed and should be used by the 'real' plugin code
@@ -171,12 +170,14 @@ class Template(object):
from gi.repository import GObject
+
class GeditLaTeXPlugin_MenuToolAction(Gtk.Action):
__gtype_name__ = "GeditLaTeXPlugin_MenuToolAction"
def do_create_tool_item(self):
return Gtk.MenuToolButton()
+
class Action(object):
"""
"""
@@ -327,7 +328,6 @@ class Editor(object):
__log = getLogger("Editor")
-
class Marker(object):
"""
Markers refer to and highlight a range of text in the TextBuffer decorated by
@@ -348,7 +348,6 @@ class Editor(object):
self.type = type
self.id = id
-
class MarkerTypeRecord(object):
"""
This used for managing Marker types
@@ -361,17 +360,14 @@ class Editor(object):
self.anonymous = anonymous
self.markers = []
-
__PATTERN_INDENT = re.compile("[ \t]+")
-
# A list of file extensions
#
# If one or more files with one of these extensions is dragged and dropped on the editor,
# the Editor.drag_drop_received method is called. An empty list disables the dnd support.
dnd_extensions = []
-
def __init__(self, tab_decorator, file):
self._tab_decorator = tab_decorator
self._file = file
@@ -397,21 +393,19 @@ class Editor(object):
self._marker_types = {} # {marker type -> MarkerTypeRecord object}
self._markers = {} # { marker id -> marker object }
-
self._window_context = self._tab_decorator._window_decorator._window_context
self._window_context.create_editor_views(self, file)
-
self._offset = None # used by move_cursor
self.__view_signal_handlers = [
self._text_view.connect("button-press-event", self.__on_button_pressed),
self._text_view.connect("key-release-event", self.__on_key_released),
- self._text_view.connect("button-release-event", self.__on_button_released) ]
+ self._text_view.connect("button-release-event", self.__on_button_released)]
self.__buffer_change_timestamp = time.time()
self.__buffer_signal_handlers = [
- self._text_buffer.connect("changed", self.__on_buffer_changed) ]
+ self._text_buffer.connect("changed", self.__on_buffer_changed)]
# dnd support
if len(self.dnd_extensions) > 0:
@@ -730,7 +724,6 @@ class Editor(object):
if end_offset > buffer_end_offset:
self.__log.error("create_marker(): end offset out of range (%s > %s)" % (end_offset, buffer_end_offset))
-
type_record = self._marker_types[marker_type]
# hightlight
@@ -1004,6 +997,7 @@ import re
import urllib
import urlparse
+
def fixurl(url):
r"""From http://stackoverflow.com/questions/804336/best-way-to-convert-a-unicode-url-to-ascii-utf-8-percent-escaped-in-python/805166#805166 .
Was named canonurl(). Comments added to the original are prefixed with ##.
@@ -1062,7 +1056,7 @@ def fixurl(url):
# turn it into Unicode
try:
url = unicode(url, 'utf-8')
- except Exception, exc: #UnicodeDecodeError, exc:
+ except Exception, exc: # UnicodeDecodeError, exc:
## It often happens that the url is already "python unicode" encoded
if not str(exc) == "decoding Unicode is not supported":
return '' # bad UTF-8 chars in URL
@@ -1282,7 +1276,7 @@ class File(object):
return self.path
if self.path[:len(base)] == base:
# bases match, return relative part
- return self.path[len(base)+1:]
+ return self.path[len(base) + 1:]
return self.path
def relativize_shortname(self, base):
@@ -1337,6 +1331,7 @@ class File(object):
# compare None with File
return False
+
class Folder(File):
# FIXME: a Folder is NOT a subclass of a File, both are a subclass of some AbstractFileSystemObject,
diff --git a/latex/base/completion.py b/latex/base/completion.py
index d95b779..356c234 100644
--- a/latex/base/completion.py
+++ b/latex/base/completion.py
@@ -47,7 +47,7 @@ class ProposalPopup(Gtk.Window):
def __init__(self):
if not '_ready' in dir(self):
- Gtk.Window.__init__(self,type=Gtk.WindowType.POPUP)
+ Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
#self, Gtk.WindowType.POPUP)
self._store = Gtk.ListStore(str, object, GdkPixbuf.Pixbuf) # markup, Proposal instance
@@ -125,7 +125,7 @@ class ProposalPopup(Gtk.Window):
for proposal in proposals:
self._store.append([proposal.label, proposal, proposal.icon])
- self._view.set_cursor(Gtk.TreePath.new_from_string("0"),None, False)
+ self._view.set_cursor(Gtk.TreePath.new_from_string("0"), None, False)
def navigate(self, key):
"""
@@ -312,11 +312,9 @@ class CompletionDistributor(object):
or more CompletionHandlers
"""
-
# TODO: clearify and simplify states here!
# TODO: auto-close (maybe...)
-
_log = getLogger("CompletionDistributor")
_MAX_PREFIX_LENGTH = 100
@@ -327,13 +325,13 @@ class CompletionDistributor(object):
_STATE_IDLE, _STATE_CTRL_PRESSED, _STATE_ACTIVE = 0, 1, 2
# keys that abort completion
- _ABORT_KEYS = [ "Escape", "Left", "Right", "Home", "End", "space", "Tab" ]
+ _ABORT_KEYS = ["Escape", "Left", "Right", "Home", "End", "space", "Tab"]
# keys that are used to navigate in the popup
- _NAVIGATION_KEYS = [ "Up", "Down", "Page_Up", "Page_Down" ]
+ _NAVIGATION_KEYS = ["Up", "Down", "Page_Up", "Page_Down"]
# some characters have key constants that differ from their value
- _SPECIAL_KEYS = {"@" : "at"}
+ _SPECIAL_KEYS = {"@": "at"}
def __init__(self, editor, handlers):
"""
@@ -428,7 +426,6 @@ class CompletionDistributor(object):
# # TODO: self._autoClose(braceTyped=True)
# pass
-
if self._state == self._STATE_ACTIVE:
if key in self._NAVIGATION_KEYS or key in ["Control_L", "Control_R", "space"]:
# returning True stops the signal
diff --git a/latex/base/config.py b/latex/base/config.py
index 0d3655c..3ea051b 100644
--- a/latex/base/config.py
+++ b/latex/base/config.py
@@ -114,7 +114,7 @@ UI = """
from ..latex.actions import LaTeXMenuAction, LaTeXNewAction, LaTeXChooseMasterAction, \
LaTeXItemizeAction, LaTeXEnumerateAction, LaTeXFontFamilyAction, LaTeXFontFamilyMenuAction, LaTeXBoldAction, \
LaTeXItalicAction, LaTeXEmphasizeAction, LaTeXDescriptionAction, LaTeXStructureMenuAction, LaTeXPartAction, LaTeXChapterAction, \
- LaTeXSectionAction, LaTeXSubsectionAction, LaTeXParagraphAction,LaTeXSubparagraphAction, LaTeXStructureAction, \
+ LaTeXSectionAction, LaTeXSubsectionAction, LaTeXParagraphAction, LaTeXSubparagraphAction, LaTeXStructureAction, \
LaTeXGraphicsAction, LaTeXUseBibliographyAction, LaTeXTableAction, LaTeXListingAction, LaTeXJustifyLeftAction, \
LaTeXJustifyCenterAction, LaTeXJustifyRightAction, LaTeXMathMenuAction, LaTeXMathAction, LaTeXDisplayMathAction, \
LaTeXEquationAction, LaTeXUnEqnArrayAction, LaTeXEqnArrayAction, LaTeXUnderlineAction, LaTeXSmallCapitalsAction, \
@@ -123,16 +123,16 @@ from ..latex.actions import LaTeXMenuAction, LaTeXNewAction, LaTeXChooseMasterAc
from ..bibtex.actions import BibTeXMenuAction, BibTeXNewEntryAction
-ACTIONS = [ LaTeXMenuAction, LaTeXNewAction, LaTeXChooseMasterAction,
+ACTIONS = [LaTeXMenuAction, LaTeXNewAction, LaTeXChooseMasterAction,
LaTeXItemizeAction, LaTeXEnumerateAction, LaTeXFontFamilyAction, LaTeXFontFamilyMenuAction, LaTeXBoldAction,
LaTeXItalicAction, LaTeXEmphasizeAction, LaTeXDescriptionAction, LaTeXStructureMenuAction, LaTeXPartAction, LaTeXChapterAction,
- LaTeXSectionAction, LaTeXSubsectionAction, LaTeXParagraphAction,LaTeXSubparagraphAction, LaTeXStructureAction,
+ LaTeXSectionAction, LaTeXSubsectionAction, LaTeXParagraphAction, LaTeXSubparagraphAction, LaTeXStructureAction,
LaTeXGraphicsAction, LaTeXUseBibliographyAction, LaTeXTableAction, LaTeXListingAction, LaTeXJustifyLeftAction,
LaTeXJustifyCenterAction, LaTeXJustifyRightAction, LaTeXMathMenuAction, LaTeXMathAction, LaTeXDisplayMathAction,
LaTeXEquationAction, LaTeXUnEqnArrayAction, LaTeXEqnArrayAction, LaTeXUnderlineAction, LaTeXSmallCapitalsAction,
LaTeXRomanAction, LaTeXSansSerifAction, LaTeXTypewriterAction, LaTeXCloseEnvironmentAction, LaTeXBlackboardBoldAction,
LaTeXCaligraphyAction, LaTeXFrakturAction, LaTeXBuildImageAction, LaTeXSaveAsTemplateAction,
- BibTeXMenuAction, BibTeXNewEntryAction ]
+ BibTeXMenuAction, BibTeXNewEntryAction]
# views
@@ -141,27 +141,27 @@ from ..latex.views import LaTeXSymbolMapView, LaTeXOutlineView
from ..bibtex.views import BibTeXOutlineView
-#WINDOW_SCOPE_VIEWS = { ".tex" : {"LaTeXSymbolMapView" : LaTeXSymbolMapView } }
+#WINDOW_SCOPE_VIEWS = {".tex": {"LaTeXSymbolMapView": LaTeXSymbolMapView}}
#
-#EDITOR_SCOPE_VIEWS = { ".tex" : {"IssueView" : IssueView,
-# "LaTeXOutlineView" : LaTeXOutlineView},
+#EDITOR_SCOPE_VIEWS = {".tex": {"IssueView": IssueView,
+# "LaTeXOutlineView": LaTeXOutlineView},
#
-# ".bib" : {"IssueView" : IssueView,
-# "BibTeXOutlineView" : BibTeXOutlineView} }
+# ".bib": {"IssueView": IssueView,
+# "BibTeXOutlineView": BibTeXOutlineView}}
from ..preferences import Preferences
-LATEX_EXTENSIONS = Preferences().get("latex-extensions").split(",")
+LATEX_EXTENSIONS = Preferences().get("latex-extensions").split(", ")
BIBTEX_EXTENSIONS = [".bib"]
WINDOW_SCOPE_VIEWS = {}
EDITOR_SCOPE_VIEWS = {}
for e in LATEX_EXTENSIONS:
- WINDOW_SCOPE_VIEWS[e] = {"LaTeXSymbolMapView" : LaTeXSymbolMapView }
- EDITOR_SCOPE_VIEWS[e] = {"IssueView" : IssueView, "LaTeXOutlineView" : LaTeXOutlineView}
+ WINDOW_SCOPE_VIEWS[e] = {"LaTeXSymbolMapView": LaTeXSymbolMapView}
+ EDITOR_SCOPE_VIEWS[e] = {"IssueView": IssueView, "LaTeXOutlineView": LaTeXOutlineView}
for e in BIBTEX_EXTENSIONS:
- EDITOR_SCOPE_VIEWS[e] = {"IssueView" : IssueView, "BibTeXOutlineView" : BibTeXOutlineView}
+ EDITOR_SCOPE_VIEWS[e] = {"IssueView": IssueView, "BibTeXOutlineView": BibTeXOutlineView}
# editors
@@ -169,7 +169,7 @@ for e in BIBTEX_EXTENSIONS:
from ..latex.editor import LaTeXEditor
from ..bibtex.editor import BibTeXEditor
-EDITORS = [ LaTeXEditor, BibTeXEditor ]
+EDITORS = [LaTeXEditor, BibTeXEditor]
# ex:ts=8:et:
diff --git a/latex/base/decorators.py b/latex/base/decorators.py
index b0c43f9..c78fa2a 100644
--- a/latex/base/decorators.py
+++ b/latex/base/decorators.py
@@ -33,6 +33,7 @@ from . import File
# TODO: maybe create ActionDelegate for GeditWindowDecorator
+
class GeditTabDecorator(object):
"""
This monitors the opened file and manages the Editor objects
diff --git a/latex/base/templates.py b/latex/base/templates.py
index 6cfc857..47ec9a3 100644
--- a/latex/base/templates.py
+++ b/latex/base/templates.py
@@ -29,7 +29,7 @@ class TemplateToken:
"""
A token of a template expression
"""
- LITERAL, PLACEHOLDER, CURSOR = 1,2,3
+ LITERAL, PLACEHOLDER, CURSOR = 1, 2, 3
def __init__(self, type, value=None):
self.type = type
@@ -40,7 +40,7 @@ class TemplateTokenizer:
"""
A simple state machine for tokenizing a template expression
"""
- _INIT, _LITERAL, _LITERAL_DOLLAR, _DOLLAR, _PLACEHOLDER = 1,2,3,4,5
+ _INIT, _LITERAL, _LITERAL_DOLLAR, _DOLLAR, _PLACEHOLDER = 1, 2, 3, 4, 5
def __init__(self, expression):
self._character_iter = iter(expression)
@@ -392,7 +392,6 @@ class TemplateDelegate(object):
self._placeholder_marks.append([markLeft, markRight])
-
# highlight complete template area
itStart = self._text_buffer.get_iter_at_offset(start)
itEnd = self._text_buffer.get_iter_at_offset(start + len(self._compiler.plain))
@@ -409,7 +408,6 @@ class TemplateDelegate(object):
else:
self._mark_final = self._text_buffer.create_mark(None, itEnd, True)
-
self._selected_placeholder = 0
self._activate()
@@ -425,7 +423,7 @@ class TemplateDelegate(object):
self._handlers = [
self._text_view.connect("key-press-event", self._on_key_pressed),
self._text_view.connect_after("key-release-event", self._on_key_released),
- self._text_view.connect("button-press-event", self._on_button_pressed) ]
+ self._text_view.connect("button-press-event", self._on_button_pressed)]
self._active = True
def _deactivate(self):
@@ -535,7 +533,6 @@ class TemplateDelegate(object):
else:
self._leave_template(place_cursor=False)
-
def _on_button_pressed(self, text_view, event):
"""
Leave template when mouse button is pressed
diff --git a/latex/base/windowactivatable.py b/latex/base/windowactivatable.py
index 272b1dc..28b44a6 100644
--- a/latex/base/windowactivatable.py
+++ b/latex/base/windowactivatable.py
@@ -37,8 +37,9 @@ from config import UI, WINDOW_SCOPE_VIEWS, EDITOR_SCOPE_VIEWS, ACTIONS
from . import File, SideView, BottomView, WindowContext
from decorators import GeditTabDecorator
+
class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Configurable):
- __gtype_name__ = "LaTeXWindowActivatable"
+ __gtype_name__ = "LaTeXWindowActivatable"
"""
This class
@@ -91,7 +92,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
self._signal_handlers = [
self.window.connect("tab_added", self._on_tab_added),
self.window.connect("tab_removed", self._on_tab_removed),
- self.window.connect("active_tab_changed", self._on_active_tab_changed) ]
+ self.window.connect("active_tab_changed", self._on_active_tab_changed)]
def do_deactivate(self):
"""
@@ -251,7 +252,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
# this is used for enable/disable actions by name
# None stands for every extension
- self._tool_action_extensions = { None : [] }
+ self._tool_action_extensions = {None: []}
self._tool_action_group = Gtk.ActionGroup("LaTeXPluginToolActions")
@@ -294,7 +295,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
i += 1
- tool_ui = self._tool_ui_template.substitute({"items" : items_ui})
+ tool_ui = self._tool_ui_template.substitute({"items": items_ui})
self._ui_manager.insert_action_group(self._tool_action_group, -1)
self._tool_ui_id = self._ui_manager.add_ui_from_string(tool_ui)
@@ -376,15 +377,19 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
side_views = self._window_side_views + self._side_views
for view in side_views:
self.window.get_side_panel().remove_item(view)
- if view in self._side_views: self._side_views.remove(view)
- if view in self._window_side_views: self._window_side_views.remove(view)
+ if view in self._side_views:
+ self._side_views.remove(view)
+ if view in self._window_side_views:
+ self._window_side_views.remove(view)
# remove all bottom views
bottom_views = self._window_bottom_views + self._bottom_views
for view in bottom_views:
self.window.get_bottom_panel().remove_item(view)
- if view in self._bottom_views: self._bottom_views.remove(view)
- if view in self._window_bottom_views: self._window_bottom_views.remove(view)
+ if view in self._bottom_views:
+ self._bottom_views.remove(view)
+ if view in self._window_bottom_views:
+ self._window_bottom_views.remove(view)
def adjust(self, tab_decorator):
"""
@@ -430,7 +435,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
for name in l:
self._tool_action_group.get_action(name).set_sensitive(False)
-
# enable the actions for all extensions
for name in self._action_extensions[None]:
self._action_group.get_action(name).set_visible(True)
@@ -443,7 +447,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
except KeyError:
pass
-
# enable the tool actions that apply for all extensions
for name in self._tool_action_extensions[None]:
self._tool_action_group.get_action(name).set_sensitive(True)
@@ -492,17 +495,16 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
# add AFTER.difference(BEFORE)
i = 1
for view in after_side_views.difference(before_side_views):
- i+=1
+ i += 1
self.window.get_side_panel().add_item(view, "after_side_view_id" + str(i), view.label, view.icon)
self._side_views.append(view)
i = 1
for view in after_bottom_views.difference(before_bottom_views):
- i+=1
+ i += 1
print view.label, view.icon
- self.window.get_bottom_panel().add_item(view, "bottom_view_id" + str(i),view.label, view.icon)
+ self.window.get_bottom_panel().add_item(view, "bottom_view_id" + str(i), view.label, view.icon)
self._bottom_views.append(view)
-
#
# adjust window-scope views
#
@@ -551,7 +553,7 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
i = 1
for view in after_window_side_views.difference(before_window_side_views):
i += 1
- self.window.get_side_panel().add_item(view,"WHATView"+ str(i), view.label, view.icon)
+ self.window.get_side_panel().add_item(view, "WHATView" + str(i), view.label, view.icon)
self._window_side_views.append(view)
for view in after_window_bottom_views.difference(before_window_bottom_views):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]