Run pyupgrade: new style classes and super calls, set literals
Signed-off-by: Dan Yeaw <dan@yeaw.me>
This commit is contained in:
parent
0bea903026
commit
df9d898f0f
@ -77,7 +77,7 @@ class MyLine(Line):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(MyLine, self).__init__()
|
||||
super().__init__()
|
||||
self.fuzziness = 2
|
||||
|
||||
def draw_head(self, context):
|
||||
|
@ -38,7 +38,7 @@ def singledispatch(func):
|
||||
return wrapped
|
||||
|
||||
|
||||
class ItemFinder(object):
|
||||
class ItemFinder:
|
||||
"""
|
||||
Find an item on the canvas.
|
||||
"""
|
||||
@ -54,7 +54,7 @@ class ItemFinder(object):
|
||||
Finder = singledispatch(ItemFinder)
|
||||
|
||||
|
||||
class ItemSelection(object):
|
||||
class ItemSelection:
|
||||
"""
|
||||
A role for items. When dealing with selection.
|
||||
|
||||
@ -80,7 +80,7 @@ class ItemSelection(object):
|
||||
Selection = singledispatch(ItemSelection)
|
||||
|
||||
|
||||
class ItemInMotion(object):
|
||||
class ItemInMotion:
|
||||
"""
|
||||
Aspect for dealing with motion on an item.
|
||||
|
||||
@ -118,7 +118,7 @@ class ItemInMotion(object):
|
||||
InMotion = singledispatch(ItemInMotion)
|
||||
|
||||
|
||||
class ItemHandleFinder(object):
|
||||
class ItemHandleFinder:
|
||||
"""
|
||||
Deals with the task of finding handles.
|
||||
"""
|
||||
@ -134,7 +134,7 @@ class ItemHandleFinder(object):
|
||||
HandleFinder = singledispatch(ItemHandleFinder)
|
||||
|
||||
|
||||
class ItemHandleSelection(object):
|
||||
class ItemHandleSelection:
|
||||
"""
|
||||
Deal with selection of the handle.
|
||||
"""
|
||||
@ -172,7 +172,7 @@ class ElementHandleSelection(ItemHandleSelection):
|
||||
self.view.get_window().set_cursor(cursor)
|
||||
|
||||
|
||||
class ItemHandleInMotion(object):
|
||||
class ItemHandleInMotion:
|
||||
"""
|
||||
Move a handle (role is applied to the handle)
|
||||
"""
|
||||
@ -251,7 +251,7 @@ class ItemHandleInMotion(object):
|
||||
HandleInMotion = singledispatch(ItemHandleInMotion)
|
||||
|
||||
|
||||
class ItemConnector(object):
|
||||
class ItemConnector:
|
||||
"""Connect or disconnect an item's handle to another item or port.
|
||||
|
||||
"""
|
||||
@ -329,7 +329,7 @@ class ItemConnector(object):
|
||||
Connector = singledispatch(ItemConnector)
|
||||
|
||||
|
||||
class ItemConnectionSink(object):
|
||||
class ItemConnectionSink:
|
||||
"""Makes an item a sink.
|
||||
|
||||
A sink is another item that an item's handle is connected to like a
|
||||
@ -366,7 +366,7 @@ ConnectionSink = singledispatch(ItemConnectionSink)
|
||||
#
|
||||
|
||||
|
||||
class ItemPaintFocused(object):
|
||||
class ItemPaintFocused:
|
||||
"""
|
||||
Paints on top of all items, just for the focused item and only
|
||||
when it's hovered (see gaphas.painter.FocusedItemPainter)
|
||||
|
@ -57,7 +57,7 @@ class ConnectionError(Exception):
|
||||
"""
|
||||
|
||||
|
||||
class Context(object):
|
||||
class Context:
|
||||
"""
|
||||
Context used for updating and drawing items in a drawing canvas.
|
||||
|
||||
@ -86,7 +86,7 @@ def instant_cairo_context():
|
||||
return cairo.Context(surface)
|
||||
|
||||
|
||||
class Canvas(object):
|
||||
class Canvas:
|
||||
"""
|
||||
Container class for items.
|
||||
"""
|
||||
@ -930,7 +930,7 @@ class VariableProjection(solver.Projection):
|
||||
return self._var
|
||||
|
||||
|
||||
class CanvasProjection(object):
|
||||
class CanvasProjection:
|
||||
"""
|
||||
Project a point as Canvas coordinates. Although this is a
|
||||
projection, it behaves like a tuple with two Variables
|
||||
|
@ -27,7 +27,7 @@ def deprecated(message, since):
|
||||
return _deprecated
|
||||
|
||||
|
||||
class Position(object):
|
||||
class Position:
|
||||
"""
|
||||
A point constructed of two `Variable`'s.
|
||||
|
||||
@ -91,7 +91,7 @@ class Position(object):
|
||||
return (self.x, self.y)[index]
|
||||
|
||||
|
||||
class Handle(object):
|
||||
class Handle:
|
||||
"""
|
||||
Handles are used to support modifications of Items.
|
||||
|
||||
@ -178,7 +178,7 @@ class Handle(object):
|
||||
__repr__ = __str__
|
||||
|
||||
|
||||
class Port(object):
|
||||
class Port:
|
||||
"""Port connectable part of an item.
|
||||
|
||||
The Item's handle connects to a port.
|
||||
@ -186,7 +186,7 @@ class Port(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(Port, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self._connectable = True
|
||||
|
||||
@ -215,7 +215,7 @@ class LinePort(Port):
|
||||
"""
|
||||
|
||||
def __init__(self, start, end):
|
||||
super(LinePort, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self.start = start
|
||||
self.end = end
|
||||
@ -250,7 +250,7 @@ class PointPort(Port):
|
||||
"""
|
||||
|
||||
def __init__(self, point):
|
||||
super(PointPort, self).__init__()
|
||||
super().__init__()
|
||||
self.point = point
|
||||
|
||||
def glue(self, pos):
|
||||
|
@ -40,7 +40,7 @@ def _update(variable, value):
|
||||
variable.value = value
|
||||
|
||||
|
||||
class Constraint(object):
|
||||
class Constraint:
|
||||
"""
|
||||
Constraint base class.
|
||||
|
||||
@ -152,7 +152,7 @@ class EqualsConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, a=None, b=None, delta=0.0):
|
||||
super(EqualsConstraint, self).__init__(a, b, delta)
|
||||
super().__init__(a, b, delta)
|
||||
self.a = a
|
||||
self.b = b
|
||||
self.delta = delta
|
||||
@ -194,7 +194,7 @@ class CenterConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, a=None, b=None, center=None):
|
||||
super(CenterConstraint, self).__init__(a, b, center)
|
||||
super().__init__(a, b, center)
|
||||
self.a = a
|
||||
self.b = b
|
||||
self.center = center
|
||||
@ -234,7 +234,7 @@ class LessThanConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, smaller=None, bigger=None, delta=0.0):
|
||||
super(LessThanConstraint, self).__init__(smaller, bigger, delta)
|
||||
super().__init__(smaller, bigger, delta)
|
||||
self.smaller = smaller
|
||||
self.bigger = bigger
|
||||
self.delta = delta
|
||||
@ -276,7 +276,7 @@ class EquationConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, f, **args):
|
||||
super(EquationConstraint, self).__init__(*list(args.values()))
|
||||
super().__init__(*list(args.values()))
|
||||
self._f = f
|
||||
self._args = {}
|
||||
# see important note on order of operations in __setattr__ below.
|
||||
@ -422,7 +422,7 @@ class BalanceConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, band=None, v=None, balance=None):
|
||||
super(BalanceConstraint, self).__init__(band[0], band[1], v)
|
||||
super().__init__(band[0], band[1], v)
|
||||
self.band = band
|
||||
self.balance = balance
|
||||
self.v = v
|
||||
@ -455,7 +455,7 @@ class LineConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, line, point):
|
||||
super(LineConstraint, self).__init__(
|
||||
super().__init__(
|
||||
line[0][0], line[0][1], line[1][0], line[1][1], point[0], point[1]
|
||||
)
|
||||
|
||||
@ -535,9 +535,7 @@ class PositionConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, origin, point):
|
||||
super(PositionConstraint, self).__init__(
|
||||
origin[0], origin[1], point[0], point[1]
|
||||
)
|
||||
super().__init__(origin[0], origin[1], point[0], point[1])
|
||||
|
||||
self._origin = origin
|
||||
self._point = point
|
||||
@ -580,7 +578,7 @@ class LineAlignConstraint(Constraint):
|
||||
"""
|
||||
|
||||
def __init__(self, line, point, align=0.5, delta=0.0):
|
||||
super(LineAlignConstraint, self).__init__(
|
||||
super().__init__(
|
||||
line[0][0], line[0][1], line[1][0], line[1][1], point[0], point[1]
|
||||
)
|
||||
|
||||
|
@ -11,7 +11,7 @@ from gi.repository import Gtk, GLib
|
||||
DEBUG_ASYNC = False
|
||||
|
||||
|
||||
class AsyncIO(object):
|
||||
class AsyncIO:
|
||||
"""
|
||||
Instead of calling the function, schedule an idle handler at a
|
||||
given priority. This requires the async'ed method to be called
|
||||
@ -176,7 +176,7 @@ def nonrecursive(func):
|
||||
return wrapper
|
||||
|
||||
|
||||
class recursive(object):
|
||||
class recursive:
|
||||
"""
|
||||
This decorator limits the recursion for a specific function
|
||||
|
||||
|
@ -15,7 +15,7 @@ class Box(Element):
|
||||
"""
|
||||
|
||||
def __init__(self, width=10, height=10):
|
||||
super(Box, self).__init__(width, height)
|
||||
super().__init__(width, height)
|
||||
|
||||
def draw(self, context):
|
||||
c = context.cairo
|
||||
@ -51,7 +51,7 @@ class PortoBox(Box):
|
||||
"""
|
||||
|
||||
def __init__(self, width=10, height=10):
|
||||
super(PortoBox, self).__init__(width, height)
|
||||
super().__init__(width, height)
|
||||
|
||||
# disable default ports
|
||||
for p in self._ports:
|
||||
@ -86,7 +86,7 @@ class PortoBox(Box):
|
||||
self._ports.append(self._lport)
|
||||
|
||||
def draw(self, context):
|
||||
super(PortoBox, self).draw(context)
|
||||
super().draw(context)
|
||||
c = context.cairo
|
||||
|
||||
if context.hovered:
|
||||
@ -121,7 +121,7 @@ class Text(Item):
|
||||
"""
|
||||
|
||||
def __init__(self, text=None, plain=False, multiline=False, align_x=1, align_y=-1):
|
||||
super(Text, self).__init__()
|
||||
super().__init__()
|
||||
self.text = text is None and "Hello" or text
|
||||
self.plain = plain
|
||||
self.multiline = multiline
|
||||
@ -149,7 +149,7 @@ class FatLine(Item):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(FatLine, self).__init__()
|
||||
super().__init__()
|
||||
self._handles.extend((Handle(), Handle()))
|
||||
|
||||
h1, h2 = self._handles
|
||||
@ -180,7 +180,7 @@ class FatLine(Item):
|
||||
|
||||
class Circle(Item):
|
||||
def __init__(self):
|
||||
super(Circle, self).__init__()
|
||||
super().__init__()
|
||||
self._handles.extend((Handle(), Handle()))
|
||||
|
||||
def _set_radius(self, r):
|
||||
@ -196,7 +196,7 @@ class Circle(Item):
|
||||
radius = property(_get_radius, _set_radius)
|
||||
|
||||
def setup_canvas(self):
|
||||
super(Circle, self).setup_canvas()
|
||||
super().setup_canvas()
|
||||
h1, h2 = self._handles
|
||||
h1.movable = False
|
||||
|
||||
|
@ -15,7 +15,7 @@ from random import Random
|
||||
from gaphas.painter import Context
|
||||
|
||||
|
||||
class FreeHandCairoContext(object):
|
||||
class FreeHandCairoContext:
|
||||
|
||||
KAPPA = 0.5522847498
|
||||
|
||||
@ -156,7 +156,7 @@ class FreeHandCairoContext(object):
|
||||
self.close_path()
|
||||
|
||||
|
||||
class FreeHandPainter(object):
|
||||
class FreeHandPainter:
|
||||
def __init__(self, subpainter, sloppiness=1.0, view=None):
|
||||
self.subpainter = subpainter
|
||||
self.view = view
|
||||
|
@ -10,7 +10,7 @@ A point is represented as a tuple `(x, y)`.
|
||||
from math import sqrt
|
||||
|
||||
|
||||
class Rectangle(object):
|
||||
class Rectangle:
|
||||
"""
|
||||
Python Rectangle implementation. Rectangles can be added (union),
|
||||
substituted (intersection) and points and rectangles can be tested
|
||||
|
@ -9,7 +9,7 @@ from gaphas.aspect import ItemInMotion, ItemHandleInMotion, ItemPaintFocused
|
||||
from gaphas.item import Item, Element, Line
|
||||
|
||||
|
||||
class ItemGuide(object):
|
||||
class ItemGuide:
|
||||
"""
|
||||
Get edges on an item, on which we can align the items.
|
||||
"""
|
||||
@ -79,7 +79,7 @@ class LineGuide(ItemGuide):
|
||||
yield h.pos.x
|
||||
|
||||
|
||||
class Guides(object):
|
||||
class Guides:
|
||||
def __init__(self, v, h):
|
||||
self.v = v
|
||||
self.h = h
|
||||
@ -91,7 +91,7 @@ class Guides(object):
|
||||
return self.h
|
||||
|
||||
|
||||
class GuideMixin(object):
|
||||
class GuideMixin:
|
||||
"""
|
||||
Helper methods for guides.
|
||||
"""
|
||||
@ -229,7 +229,7 @@ class GuidedItemInMotion(GuideMixin, ItemInMotion):
|
||||
newpos = px + dx, py + dy
|
||||
|
||||
# Call super class, with new position
|
||||
sink = super(GuidedItemInMotion, self).move(newpos)
|
||||
sink = super().move(newpos)
|
||||
|
||||
self.queue_draw_guides()
|
||||
|
||||
@ -258,7 +258,7 @@ class GuidedItemHandleInMotion(GuideMixin, ItemHandleInMotion):
|
||||
|
||||
def move(self, pos):
|
||||
|
||||
sink = super(GuidedItemHandleInMotion, self).move(pos)
|
||||
sink = super().move(pos)
|
||||
|
||||
if not sink:
|
||||
item = self.item
|
||||
|
@ -25,7 +25,7 @@ from gaphas.state import (
|
||||
)
|
||||
|
||||
|
||||
class Item(object):
|
||||
class Item:
|
||||
"""
|
||||
Base class (or interface) for items on a canvas.Canvas.
|
||||
|
||||
@ -314,7 +314,7 @@ class Element(Item):
|
||||
min_height = solvable(strength=REQUIRED, varname="_min_height")
|
||||
|
||||
def __init__(self, width=10, height=10):
|
||||
super(Element, self).__init__()
|
||||
super().__init__()
|
||||
self._handles = [h(strength=VERY_STRONG) for h in [Handle] * 4]
|
||||
|
||||
handles = self._handles
|
||||
@ -351,7 +351,7 @@ class Element(Item):
|
||||
# self.constraints.append(EqualsConstraint(p1[1], p2[1], delta))
|
||||
|
||||
def setup_canvas(self):
|
||||
super(Element, self).setup_canvas()
|
||||
super().setup_canvas()
|
||||
|
||||
# Trigger solver to honour width/height by SE handle pos
|
||||
self._handles[SE].pos.x.dirty()
|
||||
@ -464,7 +464,7 @@ class Line(Item):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(Line, self).__init__()
|
||||
super().__init__()
|
||||
self._handles = [Handle(connectable=True), Handle((10, 10), connectable=True)]
|
||||
self._ports = []
|
||||
self._update_ports()
|
||||
@ -578,14 +578,14 @@ class Line(Item):
|
||||
"""
|
||||
Setup constraints. In this case orthogonal.
|
||||
"""
|
||||
super(Line, self).setup_canvas()
|
||||
super().setup_canvas()
|
||||
self._update_orthogonal_constraints(self.orthogonal)
|
||||
|
||||
def teardown_canvas(self):
|
||||
"""
|
||||
Remove constraints created in setup_canvas().
|
||||
"""
|
||||
super(Line, self).teardown_canvas()
|
||||
super().teardown_canvas()
|
||||
for c in self._orthogonal_constraints:
|
||||
self.canvas.solver.remove_constraint(c)
|
||||
|
||||
@ -649,7 +649,7 @@ class Line(Item):
|
||||
def post_update(self, context):
|
||||
"""
|
||||
"""
|
||||
super(Line, self).post_update(context)
|
||||
super().post_update(context)
|
||||
h0, h1 = self._handles[:2]
|
||||
p0, p1 = h0.pos, h1.pos
|
||||
self._head_angle = atan2(p1.y - p0.y, p1.x - p0.x)
|
||||
|
@ -14,7 +14,7 @@ import cairo
|
||||
from gaphas.state import observed, reversible_method
|
||||
|
||||
|
||||
class Matrix(object):
|
||||
class Matrix:
|
||||
"""
|
||||
Matrix wrapper. This version sends @observed messages on state changes
|
||||
|
||||
|
@ -21,7 +21,7 @@ DEBUG_DRAW_BOUNDING_BOX = False
|
||||
TOLERANCE = 0.8
|
||||
|
||||
|
||||
class Painter(object):
|
||||
class Painter:
|
||||
"""
|
||||
Painter interface.
|
||||
"""
|
||||
@ -46,7 +46,7 @@ class PainterChain(Painter):
|
||||
"""
|
||||
|
||||
def __init__(self, view=None):
|
||||
super(PainterChain, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self._painters = []
|
||||
|
||||
def set_view(self, view):
|
||||
@ -84,7 +84,7 @@ class DrawContext(Context):
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(DrawContext, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
class ItemPainter(Painter):
|
||||
@ -146,7 +146,7 @@ class ItemPainter(Painter):
|
||||
self._draw_items(context.items, cairo, context.area)
|
||||
|
||||
|
||||
class CairoBoundingBoxContext(object):
|
||||
class CairoBoundingBoxContext:
|
||||
"""
|
||||
Delegate all calls to the wrapped CairoBoundingBoxContext,
|
||||
intercept ``stroke()``, ``fill()`` and a few others so the
|
||||
@ -252,7 +252,7 @@ class BoundingBoxPainter(ItemPainter):
|
||||
|
||||
def _draw_item(self, item, cairo, area=None):
|
||||
cairo = CairoBoundingBoxContext(cairo)
|
||||
super(BoundingBoxPainter, self)._draw_item(item, cairo)
|
||||
super()._draw_item(item, cairo)
|
||||
bounds = cairo.get_bounds()
|
||||
|
||||
# Update bounding box with handles.
|
||||
|
@ -12,13 +12,13 @@ from gaphas.item import Line
|
||||
|
||||
|
||||
@singledispatch
|
||||
class Segment(object):
|
||||
class Segment:
|
||||
def __init__(self, item, view):
|
||||
raise TypeError
|
||||
|
||||
|
||||
@Segment.register(Line)
|
||||
class LineSegment(object):
|
||||
class LineSegment:
|
||||
def __init__(self, item, view):
|
||||
self.item = item
|
||||
self.view = view
|
||||
@ -184,7 +184,7 @@ class SegmentHandleFinder(ItemHandleFinder):
|
||||
handle = segment.split(pos)
|
||||
|
||||
if not handle:
|
||||
item, handle = super(SegmentHandleFinder, self).get_handle_at_point(pos)
|
||||
item, handle = super().get_handle_at_point(pos)
|
||||
return item, handle
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ VERY_STRONG = 40
|
||||
REQUIRED = 100
|
||||
|
||||
|
||||
class Variable(object):
|
||||
class Variable:
|
||||
"""Representation of a variable in the constraint solver.
|
||||
|
||||
Each Variable has a @value and a @strength. In a constraint the weakest
|
||||
@ -309,7 +309,7 @@ class Variable(object):
|
||||
return self._value.__rtruediv__(other)
|
||||
|
||||
|
||||
class Projection(object):
|
||||
class Projection:
|
||||
"""
|
||||
Projections are used to convert values from one space to another,
|
||||
e.g. from Canvas to Item space or visa versa.
|
||||
@ -366,7 +366,7 @@ class Projection(object):
|
||||
__repr__ = __str__
|
||||
|
||||
|
||||
class Solver(object):
|
||||
class Solver:
|
||||
"""
|
||||
Solve constraints. A constraint should have accompanying
|
||||
variables.
|
||||
@ -622,7 +622,7 @@ class Solver(object):
|
||||
self._solving = False
|
||||
|
||||
|
||||
class solvable(object):
|
||||
class solvable:
|
||||
"""
|
||||
Easy-to-use drop Variable descriptor.
|
||||
|
||||
|
@ -5,7 +5,7 @@ one would in a database table, with indexes on the desired "columns."
|
||||
from functools import reduce
|
||||
|
||||
|
||||
class Table(object):
|
||||
class Table:
|
||||
"""
|
||||
A Table structure with indexing. Optimized for lookups.
|
||||
"""
|
||||
@ -61,7 +61,7 @@ class Table(object):
|
||||
if v in index[n]:
|
||||
index[n][v].add(data)
|
||||
else:
|
||||
index[n][v] = set([data])
|
||||
index[n][v] = {data}
|
||||
|
||||
def delete(self, *_row, **kv):
|
||||
"""
|
||||
|
@ -48,7 +48,7 @@ DEBUG_TOOL_CHAIN = False
|
||||
Event = Context
|
||||
|
||||
|
||||
class Tool(object):
|
||||
class Tool:
|
||||
"""
|
||||
Base class for a tool. This class
|
||||
A word on click events:
|
||||
@ -142,7 +142,7 @@ class ToolChain(Tool):
|
||||
"""
|
||||
|
||||
def __init__(self, view=None):
|
||||
super(ToolChain, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self._tools = []
|
||||
self._grabbed_tool = None
|
||||
|
||||
@ -241,7 +241,7 @@ class ItemTool(Tool):
|
||||
"""
|
||||
|
||||
def __init__(self, view=None, buttons=(1,)):
|
||||
super(ItemTool, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self._buttons = buttons
|
||||
self._movable_items = set()
|
||||
|
||||
@ -327,7 +327,7 @@ class HandleTool(Tool):
|
||||
"""
|
||||
|
||||
def __init__(self, view=None):
|
||||
super(HandleTool, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self.grabbed_handle = None
|
||||
self.grabbed_item = None
|
||||
self.motion_handle = None
|
||||
@ -431,7 +431,7 @@ class HandleTool(Tool):
|
||||
|
||||
class RubberbandTool(Tool):
|
||||
def __init__(self, view=None):
|
||||
super(RubberbandTool, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self.x0, self.y0, self.x1, self.y1 = 0, 0, 0, 0
|
||||
|
||||
def on_button_press(self, event):
|
||||
@ -487,7 +487,7 @@ class PanTool(Tool):
|
||||
"""
|
||||
|
||||
def __init__(self, view=None):
|
||||
super(PanTool, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self.x0, self.y0 = 0, 0
|
||||
self.speed = 10
|
||||
|
||||
@ -551,7 +551,7 @@ class ZoomTool(Tool):
|
||||
"""
|
||||
|
||||
def __init__(self, view=None):
|
||||
super(ZoomTool, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self.x0, self.y0 = 0, 0
|
||||
self.lastdiff = 0
|
||||
|
||||
@ -622,7 +622,7 @@ class ZoomTool(Tool):
|
||||
|
||||
class PlacementTool(Tool):
|
||||
def __init__(self, view, factory, handle_tool, handle_index):
|
||||
super(PlacementTool, self).__init__(view)
|
||||
super().__init__(view)
|
||||
self._factory = factory
|
||||
self.handle_tool = handle_tool
|
||||
handle_tool.set_view(view)
|
||||
@ -683,7 +683,7 @@ class TextEditTool(Tool):
|
||||
"""
|
||||
|
||||
def __init__(self, view=None):
|
||||
super(TextEditTool, self).__init__(view)
|
||||
super().__init__(view)
|
||||
|
||||
def on_double_click(self, event):
|
||||
"""
|
||||
@ -782,7 +782,7 @@ class ConnectHandleTool(HandleTool):
|
||||
pos = event.get_coords()[1:]
|
||||
self.connect(item, handle, pos)
|
||||
finally:
|
||||
return super(ConnectHandleTool, self).on_button_release(event)
|
||||
return super().on_button_release(event)
|
||||
|
||||
|
||||
def DefaultTool(view=None):
|
||||
|
@ -5,7 +5,7 @@ Simple class containing the tree structure for the canvas items.
|
||||
from operator import attrgetter
|
||||
|
||||
|
||||
class Tree(object):
|
||||
class Tree:
|
||||
"""
|
||||
A Tree structure. Nodes are stores in a depth-first order.
|
||||
|
||||
@ -127,8 +127,7 @@ class Tree(object):
|
||||
children = self.get_children(node)
|
||||
for c in children:
|
||||
yield c
|
||||
for cc in self.get_all_children(c):
|
||||
yield cc
|
||||
yield from self.get_all_children(c)
|
||||
|
||||
def get_ancestors(self, node):
|
||||
"""
|
||||
|
@ -20,7 +20,7 @@ DEBUG_DRAW_QUADTREE = False
|
||||
DEFAULT_CURSOR = Gdk.CursorType.LEFT_PTR
|
||||
|
||||
|
||||
class View(object):
|
||||
class View:
|
||||
"""
|
||||
View class for gaphas.Canvas objects.
|
||||
"""
|
||||
@ -583,7 +583,7 @@ class GtkView(Gtk.DrawingArea, Gtk.Scrollable, View):
|
||||
self._clear_matrices()
|
||||
self._canvas.unregister_view(self)
|
||||
|
||||
super(GtkView, self)._set_canvas(canvas)
|
||||
super()._set_canvas(canvas)
|
||||
|
||||
if self._canvas:
|
||||
self._canvas.register_view(self)
|
||||
@ -610,7 +610,7 @@ class GtkView(Gtk.DrawingArea, Gtk.Scrollable, View):
|
||||
"""
|
||||
Zoom in/out by factor ``factor``.
|
||||
"""
|
||||
super(GtkView, self).zoom(factor)
|
||||
super().zoom(factor)
|
||||
self.queue_draw_refresh()
|
||||
|
||||
@AsyncIO(single=True)
|
||||
@ -768,7 +768,7 @@ class GtkView(Gtk.DrawingArea, Gtk.Scrollable, View):
|
||||
cr.rectangle(0, 0, 0, 0)
|
||||
cr.clip()
|
||||
try:
|
||||
super(GtkView, self).update_bounding_box(cr, items)
|
||||
super().update_bounding_box(cr, items)
|
||||
finally:
|
||||
cr.restore()
|
||||
|
||||
|
@ -12,7 +12,7 @@ from gaphas.tool import ConnectHandleTool
|
||||
from gaphas.view import GtkView
|
||||
|
||||
|
||||
class SimpleCanvas(object):
|
||||
class SimpleCanvas:
|
||||
"""Creates a test canvas object.
|
||||
|
||||
Adds a view, canvas, and handle connection tool to a test
|
||||
|
@ -9,7 +9,7 @@ from gaphas.canvas import Canvas
|
||||
from gaphas.view import View
|
||||
|
||||
|
||||
class CanvasViewItem(object):
|
||||
class CanvasViewItem:
|
||||
def __init__(self):
|
||||
self.canvas = Canvas()
|
||||
self.view = View(self.canvas)
|
||||
|
@ -6,7 +6,7 @@ from gaphas.examples import Box
|
||||
from gaphas.item import NW, NE, SE, SW
|
||||
|
||||
|
||||
class CanvasBox(object):
|
||||
class CanvasBox:
|
||||
def __init__(self):
|
||||
self.canvas = Canvas()
|
||||
self.box = Box()
|
||||
|
@ -7,7 +7,7 @@ from gaphas.item import Element, Line
|
||||
from gaphas.view import GtkView
|
||||
|
||||
|
||||
class Window(object):
|
||||
class Window:
|
||||
def __init__(self):
|
||||
self.canvas = Canvas()
|
||||
self.view = GtkView(self.canvas)
|
||||
|
@ -11,7 +11,7 @@ from gaphas.item import Item
|
||||
from gaphas.solver import Variable
|
||||
|
||||
|
||||
class ItemPosition(object):
|
||||
class ItemPosition:
|
||||
def __init__(self):
|
||||
self.item = Item()
|
||||
self.pos1 = Variable(1), Variable(2)
|
||||
|
@ -24,7 +24,7 @@ class MyPickler(pickle.Pickler):
|
||||
raise e
|
||||
|
||||
|
||||
class MyDisconnect(object):
|
||||
class MyDisconnect:
|
||||
"""Create a disconnect object.
|
||||
|
||||
The disconnect object should be located at top-level, so the pickle code
|
||||
@ -36,7 +36,7 @@ class MyDisconnect(object):
|
||||
pass
|
||||
|
||||
|
||||
class CanvasFixture(object):
|
||||
class CanvasFixture:
|
||||
def __init__(self):
|
||||
self.canvas = Canvas()
|
||||
self.box = Box()
|
||||
|
@ -9,7 +9,7 @@ from gaphas.segment import *
|
||||
from gaphas.view import View
|
||||
|
||||
|
||||
class SegmentFixture(object):
|
||||
class SegmentFixture:
|
||||
def __init__(self):
|
||||
self.canvas = Canvas()
|
||||
self.line = Line()
|
||||
|
@ -22,7 +22,7 @@ REPEAT = 30
|
||||
NUMBER = 1000
|
||||
|
||||
|
||||
class SolverFixture(object):
|
||||
class SolverFixture:
|
||||
def __init__(self):
|
||||
self.solver = Solver()
|
||||
self.a = Variable(1, 30)
|
||||
|
@ -3,7 +3,7 @@ import sys
|
||||
from gaphas.state import reversible_pair, observed, _reverse
|
||||
|
||||
|
||||
class SList(object):
|
||||
class SList:
|
||||
def __init__(self):
|
||||
self.list = list()
|
||||
|
||||
|
@ -56,7 +56,7 @@ def test_glue_no_port_no_can_glue(simple_canvas):
|
||||
|
||||
class Tool(ConnectHandleTool):
|
||||
def __init__(self, *args):
|
||||
super(Tool, self).__init__(*args)
|
||||
super().__init__(*args)
|
||||
self._calls = 0
|
||||
|
||||
def can_glue(self, *args):
|
||||
|
@ -12,7 +12,7 @@ from gaphas.item import Line
|
||||
from gaphas.view import View, GtkView
|
||||
|
||||
|
||||
class ViewFixture(object):
|
||||
class ViewFixture:
|
||||
def __init__(self):
|
||||
self.canvas = Canvas()
|
||||
self.view = GtkView(self.canvas)
|
||||
|
Loading…
x
Reference in New Issue
Block a user