# HG changeset patch # User Andrey Skvortsov # Date 1538738521 -10800 # Node ID 105c20fdeb1969f2ba042df92d42be26c7d253c7 # Parent 82bfc75bcd9dc224abf9b147e1bd569f69dd54c8 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement diff -r 82bfc75bcd9d -r 105c20fdeb19 IDEFrame.py --- a/IDEFrame.py Fri Oct 05 13:48:54 2018 +0300 +++ b/IDEFrame.py Fri Oct 05 14:22:01 2018 +0300 @@ -23,6 +23,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from __future__ import absolute_import +from __future__ import division import sys from types import TupleType import base64 @@ -201,22 +202,22 @@ raise ValueError("Not possible") if tab["size"][0] == rect.width: if tab["pos"][1] == rect.y: - split = (wx.TOP, float(tab["size"][1]) / float(rect.height)) + split = (wx.TOP, tab["size"][1] / rect.height) split_rect = wx.Rect(rect.x, rect.y + tab["size"][1] + TAB_BORDER, rect.width, rect.height - tab["size"][1] - TAB_BORDER) elif tab["pos"][1] == rect.height + 1 - tab["size"][1]: - split = (wx.BOTTOM, 1.0 - float(tab["size"][1]) / float(rect.height)) + split = (wx.BOTTOM, 1.0 - tab["size"][1] / rect.height) split_rect = wx.Rect(rect.x, rect.y, rect.width, rect.height - tab["size"][1] - TAB_BORDER) split_id = idx break elif tab["size"][1] == rect.height: if tab["pos"][0] == rect.x: - split = (wx.LEFT, float(tab["size"][0]) / float(rect.width)) + split = (wx.LEFT, tab["size"][0] / rect.width) split_rect = wx.Rect(rect.x + tab["size"][0] + TAB_BORDER, rect.y, rect.width - tab["size"][0] - TAB_BORDER, rect.height) elif tab["pos"][0] == rect.width + 1 - tab["size"][0]: - split = (wx.RIGHT, 1.0 - float(tab["size"][0]) / float(rect.width)) + split = (wx.RIGHT, 1.0 - tab["size"][0] / rect.width) split_rect = wx.Rect(rect.x, rect.y, rect.width - tab["size"][0] - TAB_BORDER, rect.height) split_id = idx @@ -2592,7 +2593,7 @@ def UPPER_DIV(x, y): - return (x / y) + {True: 0, False: 1}[(x % y) == 0] + return (x // y) + {True: 0, False: 1}[(x % y) == 0] class GraphicPrintout(wx.Printout): @@ -2639,8 +2640,8 @@ ppiPrinterX, ppiPrinterY = self.GetPPIPrinter() pw, ph = self.GetPageSizePixels() dw, dh = dc.GetSizeTuple() - Xscale = (float(dw) * float(ppiPrinterX)) / (float(pw) * 25.4) - Yscale = (float(dh) * float(ppiPrinterY)) / (float(ph) * 25.4) + Xscale = (dw * ppiPrinterX) / (pw * 25.4) + Yscale = (dh * ppiPrinterY) / (ph * 25.4) fontsize = self.FontSize * Yscale @@ -2662,10 +2663,10 @@ # Calculate the position on the DC for centering the graphic posX = area_width * ((page - 1) % self.PageGrid[0]) - posY = area_height * ((page - 1) / self.PageGrid[0]) - - scaleX = float(area_width) / float(self.PageSize[0]) - scaleY = float(area_height) / float(self.PageSize[1]) + posY = area_height * ((page - 1) // self.PageGrid[0]) + + scaleX = area_width / self.PageSize[0] + scaleY = area_height / self.PageSize[1] scale = min(scaleX, scaleY) # Set the scale and origin diff -r 82bfc75bcd9d -r 105c20fdeb19 PLCControler.py --- a/PLCControler.py Fri Oct 05 13:48:54 2018 +0300 +++ b/PLCControler.py Fri Oct 05 14:22:01 2018 +0300 @@ -25,6 +25,7 @@ from __future__ import absolute_import +from __future__ import division from types import TupleType from copy import deepcopy import os @@ -1939,8 +1940,8 @@ x, y, width, height = bbox.bounding_box() if middle: - new_pos[0] -= width / 2 - new_pos[1] -= height / 2 + new_pos[0] -= width // 2 + new_pos[1] -= height // 2 else: new_pos = map(lambda x: x + 30, new_pos) if scaling[0] != 0 and scaling[1] != 0: diff -r 82bfc75bcd9d -r 105c20fdeb19 canfestival/canfestival.py --- a/canfestival/canfestival.py Fri Oct 05 13:48:54 2018 +0300 +++ b/canfestival/canfestival.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from __future__ import absolute_import +from __future__ import division import os import sys import shutil @@ -327,7 +328,7 @@ nodeid = self.CanFestivalNode.getNodeId() if value != nodeid: slaves = self.GetSlaveIDs() - dir = (value - nodeid) / abs(value - nodeid) + dir = (value - nodeid) // abs(value - nodeid) while value in slaves and value >= 0: value += dir if value < 0: diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/CustomTree.py --- a/controls/CustomTree.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/CustomTree.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import wx import wx.lib.agw.customtreectrl as CT @@ -100,14 +101,14 @@ if self.BackgroundAlign & wx.ALIGN_RIGHT: x = client_size[0] - bitmap_size[0] elif self.BackgroundAlign & wx.ALIGN_CENTER_HORIZONTAL: - x = (client_size[0] - bitmap_size[0]) / 2 + x = (client_size[0] - bitmap_size[0]) // 2 else: x = 0 if self.BackgroundAlign & wx.ALIGN_BOTTOM: y = client_size[1] - bitmap_size[1] elif self.BackgroundAlign & wx.ALIGN_CENTER_VERTICAL: - y = (client_size[1] - bitmap_size[1]) / 2 + y = (client_size[1] - bitmap_size[1]) // 2 else: y = 0 diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/DebugVariablePanel/DebugVariableGraphicViewer.py --- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from types import TupleType from time import time as gettime from cycler import cycler @@ -195,7 +196,7 @@ # Get Before which Viewer the variable has to be moved or added # according to the position of mouse in Viewer. - if y > height / 2: + if y > height // 2: target_idx += 1 # Drag'n Drop is an internal is an internal move inside Debug @@ -443,10 +444,10 @@ x = rect.x + (- w - offset if direction == wx.LEFT else rect.width + offset) - y = rect.y + (rect.height - h) / 2 + y = rect.y + (rect.height - h) // 2 offset += w else: - x = rect.x + (rect.width - w) / 2 + x = rect.x + (rect.width - w) // 2 y = rect.y + (- h - offset if direction == wx.TOP else rect.height + offset) @@ -801,7 +802,7 @@ self.ParentWindow.SetCanvasPosition( self.StartCursorTick + (self.MouseStartPos.x - event.x) * - (end_tick - start_tick) / rect.width) + (end_tick - start_tick) // rect.width) def OnCanvasScroll(self, event): """ @@ -819,7 +820,7 @@ tick = (start_tick + end_tick) / 2. else: tick = event.xdata - self.ParentWindow.ChangeRange(int(-event.step) / 3, tick) + self.ParentWindow.ChangeRange(int(-event.step) // 3, tick) # Vetoing event to prevent parent panel to be scrolled self.ParentWindow.VetoScrollEvent = True @@ -927,7 +928,7 @@ # Mouse is over Viewer figure and graph is not 3D bbox = self.GetAxesBoundingBox() if bbox.InsideXY(x, y) and not self.Is3DCanvas(): - rect = wx.Rect(bbox.x, bbox.y, bbox.width / 2, bbox.height) + rect = wx.Rect(bbox.x, bbox.y, bbox.width // 2, bbox.height) # Mouse is over Viewer left part of figure if rect.InsideXY(x, y): self.SetHighlight(HIGHLIGHT_LEFT) @@ -937,7 +938,7 @@ self.SetHighlight(HIGHLIGHT_RIGHT) # Mouse is over upper part of Viewer - elif y < height / 2: + elif y < height // 2: # Viewer is upper one in Debug Variable Panel, show highlight if self.ParentWindow.IsViewerFirst(self): self.SetHighlight(HIGHLIGHT_BEFORE) @@ -1400,11 +1401,11 @@ destGC.SetPen(HIGHLIGHT['DROP_PEN']) destGC.SetBrush(HIGHLIGHT['DROP_BRUSH']) - x_offset = (bbox.width / 2 + x_offset = (bbox.width // 2 if self.Highlight == HIGHLIGHT_RIGHT else 0) destGC.DrawRectangle(bbox.x + x_offset, bbox.y, - bbox.width / 2, bbox.height) + bbox.width // 2, bbox.height) # Draw other Viewer common elements self.DrawCommonElements(destGC, self.GetButtons()) diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/DebugVariablePanel/DebugVariablePanel.py --- a/controls/DebugVariablePanel/DebugVariablePanel.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/DebugVariablePanel/DebugVariablePanel.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from types import TupleType import numpy @@ -307,7 +308,7 @@ # Calculate range to apply to data self.CurrentRange = self.RANGE_VALUES[ - self.CanvasRange.GetSelection()][1] / self.Ticktime + self.CanvasRange.GetSelection()][1] // self.Ticktime def SetDataProducer(self, producer): """ @@ -390,7 +391,7 @@ cursor_tick_idx = numpy.argmin(numpy.abs(self.Ticks - cursor_tick)) if self.Ticks[cursor_tick_idx] == self.CursorTick: cursor_tick_idx = max(0, - min(cursor_tick_idx + abs(move) / move, + min(cursor_tick_idx + abs(move) // move, len(self.Ticks) - 1)) self.CursorTick = self.Ticks[cursor_tick_idx] self.StartTick = max( @@ -488,18 +489,18 @@ panel.ShowButtons(True) merge_type = GRAPH_PARALLEL if isinstance(panel, DebugVariableTextViewer) or panel.Is3DCanvas(): - if y_mouse > yw + height / 2: + if y_mouse > yw + height // 2: idx += 1 wx.CallAfter(self.MoveValue, variable, idx, True) else: rect = panel.GetAxesBoundingBox(True) if rect.InsideXY(x_mouse, y_mouse): - merge_rect = wx.Rect(rect.x, rect.y, rect.width / 2., rect.height) + merge_rect = wx.Rect(rect.x, rect.y, rect.width // 2, rect.height) if merge_rect.InsideXY(x_mouse, y_mouse): merge_type = GRAPH_ORTHOGONAL wx.CallAfter(self.MergeGraphs, variable, idx, merge_type, force=True) else: - if y_mouse > yw + height / 2: + if y_mouse > yw + height // 2: idx += 1 wx.CallAfter(self.MoveValue, variable, idx, True) self.ForceRefresh() @@ -547,16 +548,16 @@ tick_duration = int(tick * self.Ticktime) not_null = False duration = "" - for value, format in [(tick_duration / DAY, _("%dd")), - ((tick_duration % DAY) / HOUR, _("%dh")), - ((tick_duration % HOUR) / MINUTE, _("%dm")), - ((tick_duration % MINUTE) / SECOND, _("%ds"))]: + for value, format in [(tick_duration // DAY, _("%dd")), + ((tick_duration % DAY) // HOUR, _("%dh")), + ((tick_duration % HOUR) // MINUTE, _("%dm")), + ((tick_duration % MINUTE) // SECOND, _("%ds"))]: if value > 0 or not_null: duration += format % value not_null = True - duration += _("%03gms") % (float(tick_duration % SECOND) / MILLISECOND) + duration += _("%03gms") % ((tick_duration % SECOND) / MILLISECOND) self.TickTimeLabel.SetLabel("t: %s" % duration) else: self.TickLabel.SetLabel("") @@ -638,7 +639,7 @@ def OnRangeChanged(self, event): try: - self.CurrentRange = self.RANGE_VALUES[self.CanvasRange.GetSelection()][1] / self.Ticktime + self.CurrentRange = self.RANGE_VALUES[self.CanvasRange.GetSelection()][1] // self.Ticktime except ValueError: self.CanvasRange.SetValue(str(self.CurrentRange)) wx.CallAfter(self.RefreshRange) @@ -909,11 +910,12 @@ xstart, ystart = self.GraphicsWindow.GetViewStart() window_size = self.GraphicsWindow.GetClientSize() vwidth, vheight = self.GraphicsSizer.GetMinSize() - posx = max(0, min(xstart, (vwidth - window_size[0]) / SCROLLBAR_UNIT)) - posy = max(0, min(ystart, (vheight - window_size[1]) / SCROLLBAR_UNIT)) + posx = max(0, min(xstart, (vwidth - window_size[0]) // SCROLLBAR_UNIT)) + posy = max(0, min(ystart, (vheight - window_size[1]) // SCROLLBAR_UNIT)) self.GraphicsWindow.Scroll(posx, posy) self.GraphicsWindow.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, - vwidth / SCROLLBAR_UNIT, vheight / SCROLLBAR_UNIT, + vwidth // SCROLLBAR_UNIT, + vheight // SCROLLBAR_UNIT, posx, posy) def OnGraphicsWindowEraseBackground(self, event): diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/DebugVariablePanel/DebugVariableTextViewer.py --- a/controls/DebugVariablePanel/DebugVariableTextViewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/DebugVariablePanel/DebugVariableTextViewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from types import TupleType import wx @@ -104,7 +105,7 @@ # according to the position of mouse in Viewer. _width, height = self.ParentControl.GetSize() target_idx = self.ParentControl.GetIndex() - if y > height / 2: + if y > height // 2: target_idx += 1 # Drag'n Drop is an internal is an internal move inside Debug @@ -209,7 +210,7 @@ # Draw item variable path at Viewer left side w, h = gc.GetTextExtent(item_path) - gc.DrawText(item_path, 20, (height - h) / 2) + gc.DrawText(item_path, 20, (height - h) // 2) # Update 'Release' button state and text color according to item forced # flag value @@ -222,7 +223,7 @@ # Draw item current value at right side of Viewer item_value = item.GetValue() w, h = gc.GetTextExtent(item_value) - gc.DrawText(item_value, width - 40 - w, (height - h) / 2) + gc.DrawText(item_value, width - 40 - w, (height - h) // 2) # Draw other Viewer common elements self.DrawCommonElements(gc) diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/DebugVariablePanel/DebugVariableViewer.py --- a/controls/DebugVariablePanel/DebugVariableViewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/DebugVariablePanel/DebugVariableViewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from collections import OrderedDict import wx @@ -375,7 +376,7 @@ _width, height = self.GetSize() # Mouse is in the first half of Viewer - if y < height / 2: + if y < height // 2: # If Viewer is the upper one, draw drop before highlight if self.ParentWindow.IsViewerFirst(self): self.SetHighlight(HIGHLIGHT_BEFORE) diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/EnhancedStatusBar.py --- a/controls/EnhancedStatusBar.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/EnhancedStatusBar.py Fri Oct 05 14:22:01 2018 +0300 @@ -56,6 +56,7 @@ """ from __future__ import absolute_import +from __future__ import division import wx # Horizontal Alignment Constants @@ -145,7 +146,7 @@ widget.SetPosition((xpos, rect.y-1)) elif verticalalignment == ESB_ALIGN_CENTER_VERTICAL: if widgetsize[1] < rect.height - 1: - diffs = (rect.height - widgetsize[1])/2 + diffs = (rect.height - widgetsize[1]) // 2 widget.SetPosition((xpos, rect.y+diffs)) else: widget.SetSize((widgetsize[0], rect.height-2)) @@ -163,7 +164,7 @@ widget.SetPosition((xpos, rect.y-1)) elif verticalalignment == ESB_ALIGN_CENTER_VERTICAL: if widgetsize[1] < rect.height - 1: - diffs = (rect.height - widgetsize[1])/2 + diffs = (rect.height - widgetsize[1]) // 2 widget.SetPosition((xpos, rect.y+diffs)) else: widget.SetSize((widgetsize[0], rect.height-2)) @@ -175,13 +176,13 @@ elif horizontalalignment == ESB_ALIGN_CENTER_HORIZONTAL: - xpos = rect.x + (rect.width - widgetsize[0])/2 - 1 + xpos = rect.x + (rect.width - widgetsize[0]) // 2 - 1 if verticalalignment == ESB_EXACT_FIT: widget.SetSize((widgetsize[0], rect.height)) widget.SetPosition((xpos, rect.y)) elif verticalalignment == ESB_ALIGN_CENTER_VERTICAL: if widgetsize[1] < rect.height - 1: - diffs = (rect.height - widgetsize[1])/2 + diffs = (rect.height - widgetsize[1]) // 2 widget.SetPosition((xpos, rect.y+diffs)) else: widget.SetSize((widgetsize[0], rect.height-1)) diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/LogViewer.py --- a/controls/LogViewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/LogViewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from datetime import datetime from time import time as gettime from weakref import proxy @@ -44,11 +45,11 @@ def ArrowPoints(direction, width, height, xoffset, yoffset): if direction == wx.TOP: return [wx.Point(xoffset + 1, yoffset + height - 2), - wx.Point(xoffset + width / 2, yoffset + 1), + wx.Point(xoffset + width // 2, yoffset + 1), wx.Point(xoffset + width - 1, yoffset + height - 2)] else: return [wx.Point(xoffset + 1, yoffset - height + 1), - wx.Point(xoffset + width / 2, yoffset - 2), + wx.Point(xoffset + width // 2, yoffset - 2), wx.Point(xoffset + width - 1, yoffset - height + 1)] @@ -125,7 +126,7 @@ thumb_size = range_rect.height * THUMB_SIZE_RATIO thumb_range = range_rect.height - thumb_size self.RefreshThumbPosition( - max(-1., min((posy - self.ThumbScrollingStartPos.y) * 2. / thumb_range, 1.))) + max(-1., min((posy - self.ThumbScrollingStartPos.y) * 2. // thumb_range, 1.))) event.Skip() def OnResize(self, event): @@ -147,11 +148,11 @@ gc.SetPen(wx.Pen(wx.NamedColour("GREY"), 3)) gc.SetBrush(wx.GREY_BRUSH) - gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) / 4 - 3)) - gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) / 4 + 3)) - - gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) / 4 + 3)) - gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) / 4 - 3)) + gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 - 3)) + gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 + 3)) + + gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 + 3)) + gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 - 3)) thumb_rect = self.GetThumbRect() exclusion_rect = wx.Rect(thumb_rect.x, thumb_rect.y, @@ -223,8 +224,8 @@ w, h = dc.GetTextExtent(self.Label) dc.DrawText(self.Label, - self.Position.x + (self.Size.width - w) / 2, - self.Position.y + (self.Size.height - h) / 2) + self.Position.x + (self.Size.width - w) // 2, + self.Position.y + (self.Size.height - h) // 2) DATE_INFO_SIZE = 10 @@ -260,19 +261,19 @@ if draw_date: datetime_text = self.Date.strftime("%d/%m/%y %H:%M") dw, dh = dc.GetTextExtent(datetime_text) - dc.DrawText(datetime_text, (width - dw) / 2, offset + (DATE_INFO_SIZE - dh) / 2) + dc.DrawText(datetime_text, (width - dw) // 2, offset + (DATE_INFO_SIZE - dh) // 2) offset += DATE_INFO_SIZE seconds_text = "%12.9f" % self.Seconds sw, sh = dc.GetTextExtent(seconds_text) - dc.DrawText(seconds_text, 5, offset + (MESSAGE_INFO_SIZE - sh) / 2) + dc.DrawText(seconds_text, 5, offset + (MESSAGE_INFO_SIZE - sh) // 2) bw, bh = self.LevelBitmap.GetWidth(), self.LevelBitmap.GetHeight() - dc.DrawBitmap(self.LevelBitmap, 10 + sw, offset + (MESSAGE_INFO_SIZE - bh) / 2) + dc.DrawBitmap(self.LevelBitmap, 10 + sw, offset + (MESSAGE_INFO_SIZE - bh) // 2) text = self.Message.replace("\n", " ") _mw, mh = dc.GetTextExtent(text) - dc.DrawText(text, 15 + sw + bw, offset + (MESSAGE_INFO_SIZE - mh) / 2) + dc.DrawText(text, 15 + sw + bw, offset + (MESSAGE_INFO_SIZE - mh) // 2) def GetHeight(self, draw_date): if draw_date: @@ -612,7 +613,7 @@ def ScrollMessagePanelByPage(self, page): if self.CurrentMessage is not None: _width, height = self.MessagePanel.GetClientSize() - message_per_page = max(1, (height - DATE_INFO_SIZE) / MESSAGE_INFO_SIZE - 1) + message_per_page = max(1, (height - DATE_INFO_SIZE) // MESSAGE_INFO_SIZE - 1) self.ScrollMessagePanel(page * message_per_page) def ScrollMessagePanelByTimestamp(self, seconds): @@ -757,7 +758,7 @@ event.Skip() def OnMessagePanelMouseWheel(self, event): - self.ScrollMessagePanel(event.GetWheelRotation() / event.GetWheelDelta()) + self.ScrollMessagePanel(event.GetWheelRotation() // event.GetWheelDelta()) event.Skip() def OnMessagePanelEraseBackground(self, event): diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/PouInstanceVariablesPanel.py --- a/controls/PouInstanceVariablesPanel.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/PouInstanceVariablesPanel.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from collections import namedtuple import wx @@ -76,7 +77,7 @@ bbox_width = (r_image_w + 4) * len(rightimages) + 4 bbox_height = r_image_h + 8 bbox_x = w - bbox_width - bbox_y = item.GetY() + ((total_h > r_image_h) and [(total_h-r_image_h)/2] or [0])[0] + bbox_y = item.GetY() + ((total_h > r_image_h) and [(total_h-r_image_h)//2] or [0])[0] return wx.Rect(bbox_x, bbox_y, bbox_width, bbox_height) @@ -369,8 +370,8 @@ self.InstanceChoice.SetFocusFromKbd() size = self.InstanceChoice.GetSize() event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) - event.x = size.width / 2 - event.y = size.height / 2 + event.x = size.width // 2 + event.y = size.height // 2 event.SetEventObject(self.InstanceChoice) # event = wx.KeyEvent(wx.EVT_KEY_DOWN._getEvtType()) # event.m_keyCode = wx.WXK_SPACE diff -r 82bfc75bcd9d -r 105c20fdeb19 controls/VariablePanel.py --- a/controls/VariablePanel.py Fri Oct 05 13:48:54 2018 +0300 +++ b/controls/VariablePanel.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import re from types import TupleType, StringType, UnicodeType from builtins import str as text @@ -684,7 +685,7 @@ self.VariablesGrid.SetColAttr(col, attr) self.VariablesGrid.SetColMinimalWidth(col, self.ColSettings["size"][col]) if (panel_width > self.PanelWidthMin) and not self.ColSettings["fixed_size"][col]: - self.VariablesGrid.SetColSize(col, int((float(self.ColSettings["size"][col])/stretch_cols_sum)*stretch_cols_width)) + self.VariablesGrid.SetColSize(col, int((self.ColSettings["size"][col]/stretch_cols_sum)*stretch_cols_width)) else: self.VariablesGrid.SetColSize(col, self.ColSettings["size"][col]) diff -r 82bfc75bcd9d -r 105c20fdeb19 dialogs/BlockPreviewDialog.py --- a/dialogs/BlockPreviewDialog.py Fri Oct 05 13:48:54 2018 +0300 +++ b/dialogs/BlockPreviewDialog.py Fri Oct 05 14:22:01 2018 +0300 @@ -25,6 +25,7 @@ from __future__ import absolute_import +from __future__ import division import wx from plcopen.structures import TestIdentifier, IEC_KEYWORDS @@ -282,13 +283,13 @@ k = 1.1 if (bbox.width * 1.1 > client_size.width or bbox.height * 1.1 > client_size.height) \ else 1.0 - scale = (max(float(bbox.width) / client_size.width, - float(bbox.height) / client_size.height) * k) + scale = (max(bbox.width / client_size.width, + bbox.height / client_size.height) * k) dc.SetUserScale(1.0 / scale, 1.0 / scale) # Center graphic element in preview panel - x = int(client_size.width * scale - bbox.width) / 2 + posx - bbox.x - y = int(client_size.height * scale - bbox.height) / 2 + posy - bbox.y + x = int(client_size.width * scale - bbox.width) // 2 + posx - bbox.x + y = int(client_size.height * scale - bbox.height) // 2 + posy - bbox.y self.Element.SetPosition(x, y) # Draw graphic element diff -r 82bfc75bcd9d -r 105c20fdeb19 dialogs/DurationEditorDialog.py --- a/dialogs/DurationEditorDialog.py Fri Oct 05 13:48:54 2018 +0300 +++ b/dialogs/DurationEditorDialog.py Fri Oct 05 14:22:01 2018 +0300 @@ -25,6 +25,7 @@ from __future__ import absolute_import +from __future__ import division import re import wx @@ -139,10 +140,10 @@ not_null = False duration = "T#" - for value, format in [((int(milliseconds) / DAY), "%dd"), - ((int(milliseconds) % DAY) / HOUR, "%dh"), - ((int(milliseconds) % HOUR) / MINUTE, "%dm"), - ((int(milliseconds) % MINUTE) / SECOND, "%ds")]: + for value, format in [((int(milliseconds) // DAY), "%dd"), + ((int(milliseconds) % DAY) // HOUR, "%dh"), + ((int(milliseconds) % HOUR) // MINUTE, "%dm"), + ((int(milliseconds) % MINUTE) // SECOND, "%ds")]: if value > 0 or not_null: duration += format % value diff -r 82bfc75bcd9d -r 105c20fdeb19 editors/CodeFileEditor.py --- a/editors/CodeFileEditor.py Fri Oct 05 13:48:54 2018 +0300 +++ b/editors/CodeFileEditor.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import re from builtins import str as text @@ -141,9 +142,9 @@ section_comment = " %s section " % (section) len_headers = EDGE_COLUMN - len(section_comment) section_comment = \ - self.COMMENT_HEADER * (len_headers / 2) + \ + self.COMMENT_HEADER * (len_headers // 2) + \ section_comment + \ - self.COMMENT_HEADER * (len_headers - len_headers / 2) + self.COMMENT_HEADER * (len_headers - len_headers // 2) self.SectionsComments[section] = { "comment": section_comment, diff -r 82bfc75bcd9d -r 105c20fdeb19 editors/ConfTreeNodeEditor.py --- a/editors/ConfTreeNodeEditor.py Fri Oct 05 13:48:54 2018 +0300 +++ b/editors/ConfTreeNodeEditor.py Fri Oct 05 14:22:01 2018 +0300 @@ -25,6 +25,7 @@ from __future__ import absolute_import +from __future__ import division import types import wx @@ -100,11 +101,11 @@ if not self.up: dw = dy = self.labelDelta - pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre - pos_y = (height-bh-th)/2+dy + pos_x = (width - bw) // 2 + dw # adjust for bitmap and text to centre + pos_y = (height - bh - th) // 2 + dy if bmp is not None: dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available - pos_x = (width-tw)/2+dw # adjust for bitmap and text to centre + pos_x = (width-tw)//2+dw # adjust for bitmap and text to centre pos_y += bh + 2 dc.DrawText(label, pos_x, pos_y) # draw the text @@ -305,8 +306,8 @@ self.Thaw() def GenerateMethodButtonSizer(self): - normal_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) - mouseover_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) + normal_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) + mouseover_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) msizer = wx.BoxSizer(wx.HORIZONTAL) @@ -615,11 +616,12 @@ xstart, ystart = self.ParamsEditor.GetViewStart() window_size = self.ParamsEditor.GetClientSize() maxx, maxy = self.ParamsEditorSizer.GetMinSize() - posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) - posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) + posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) + posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) self.ParamsEditor.Scroll(posx, posy) self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, - maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, + maxx // SCROLLBAR_UNIT, + maxy // SCROLLBAR_UNIT, posx, posy) def OnParamsEditorResize(self, event): diff -r 82bfc75bcd9d -r 105c20fdeb19 editors/LDViewer.py --- a/editors/LDViewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/editors/LDViewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from types import * import wx @@ -160,7 +161,7 @@ return if not parts: parts = 1 - element_tree[element]["weight"] = max(1, weight / parts) + element_tree[element]["weight"] = max(1, weight // parts) # ------------------------------------------------------------------------------- @@ -457,10 +458,10 @@ contact = LD_Contact(self, CONTACT_NORMAL, var_name, id) width, height = contact.GetMinSize() if scaling is not None: - x = round(float(x) / float(scaling[0])) * scaling[0] - y = round(float(y) / float(scaling[1])) * scaling[1] - width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] - height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] + x = round(x / scaling[0]) * scaling[0] + y = round(y / scaling[1]) * scaling[1] + width = round(width / scaling[0] + 0.5) * scaling[0] + height = round(height / scaling[1] + 0.5) * scaling[1] contact.SetPosition(x, y) contact.SetSize(width, height) self.AddBlock(contact) @@ -470,10 +471,10 @@ coil = LD_Coil(self, COIL_NORMAL, var_name, id) width, height = coil.GetMinSize() if scaling is not None: - x = round(float(x) / float(scaling[0])) * scaling[0] - y = round(float(y) / float(scaling[1])) * scaling[1] - width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] - height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] + x = round(x / scaling[0]) * scaling[0] + y = round(y / scaling[1]) * scaling[1] + width = round(width / scaling[0] + 0.5) * scaling[0] + height = round(height / scaling[1] + 0.5) * scaling[1] coil.SetPosition(x, y) coil.SetSize(width, height) self.AddBlock(coil) @@ -537,7 +538,7 @@ # Create Coil id = self.GetNewId() coil = LD_Coil(self, values["type"], values["name"], id) - coil.SetPosition(startx, starty + (LD_LINE_SIZE - LD_ELEMENT_SIZE[1]) / 2) + coil.SetPosition(startx, starty + (LD_LINE_SIZE - LD_ELEMENT_SIZE[1]) // 2) coil_connectors = coil.GetConnectors() self.AddBlock(coil) rung.SelectElement(coil) @@ -606,7 +607,7 @@ points = wires[0].GetSelectedSegmentPoints() id = self.GetNewId() contact = LD_Contact(self, values["type"], values["name"], id) - contact.SetPosition(0, points[0].y - (LD_ELEMENT_SIZE[1] + 1) / 2) + contact.SetPosition(0, points[0].y - (LD_ELEMENT_SIZE[1] + 1) // 2) self.AddBlock(contact) self.Controler.AddEditedElementContact(self.TagName, id) rungindex = self.FindRung(wires[0]) diff -r 82bfc75bcd9d -r 105c20fdeb19 editors/SFCViewer.py --- a/editors/SFCViewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/editors/SFCViewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from types import * import wx @@ -534,7 +535,7 @@ pos = connectors["action"].GetPosition(False) id = self.GetNewId() actionblock = SFC_ActionBlock(self, [], id) - actionblock.SetPosition(pos.x + SFC_WIRE_MIN_SIZE, pos.y - SFC_STEP_DEFAULT_SIZE[1] / 2) + actionblock.SetPosition(pos.x + SFC_WIRE_MIN_SIZE, pos.y - SFC_STEP_DEFAULT_SIZE[1] // 2) actionblock_connector = actionblock.GetConnector() wire = self.ConnectConnectors(actionblock_connector, connectors["action"]) wire.SetPoints([wx.Point(pos.x + SFC_WIRE_MIN_SIZE, pos.y), wx.Point(pos.x, pos.y)]) diff -r 82bfc75bcd9d -r 105c20fdeb19 editors/TextViewer.py --- a/editors/TextViewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/editors/TextViewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import re from types import * @@ -893,7 +894,7 @@ if self.TextSyntax in ["ST", "ALL"]: indent = self.Editor.GetLineIndentation(line) if LineStartswith(lineText.strip(), self.BlockStartKeywords): - indent = (indent / 2 + 1) * 2 + indent = (indent // 2 + 1) * 2 self.Editor.AddText("\n" + " " * indent) key_handled = True elif key == wx.WXK_BACK: @@ -902,7 +903,7 @@ indent = self.Editor.GetColumn(self.Editor.GetCurrentPos()) if lineText.strip() == "" and len(lineText) > 0 and indent > 0: self.Editor.DelLineLeft() - self.Editor.AddText(" " * ((max(0, indent - 1) / 2) * 2)) + self.Editor.AddText(" " * ((max(0, indent - 1) // 2) * 2)) key_handled = True if not key_handled: event.Skip() diff -r 82bfc75bcd9d -r 105c20fdeb19 editors/Viewer.py --- a/editors/Viewer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/editors/Viewer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import math from time import time as gettime from types import TupleType @@ -308,10 +309,10 @@ block = FBD_Block(self.ParentWindow, values[0], blockname, id, inputs=blockinputs) width, height = block.GetMinSize() if scaling is not None: - x = round(float(x) / float(scaling[0])) * scaling[0] - y = round(float(y) / float(scaling[1])) * scaling[1] - width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] - height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] + x = round(x / scaling[0]) * scaling[0] + y = round(y / scaling[1]) * scaling[1] + width = round(width / scaling[0] + 0.5) * scaling[0] + height = round(height / scaling[1] + 0.5) * scaling[1] block.SetPosition(x, y) block.SetSize(width, height) self.ParentWindow.AddBlock(block) @@ -860,7 +861,7 @@ self.Editor.Freeze() if mouse_event is None: client_size = self.Editor.GetClientSize() - mouse_pos = wx.Point(client_size[0] / 2, client_size[1] / 2) + mouse_pos = wx.Point(client_size[0] // 2, client_size[1] // 2) mouse_event = wx.MouseEvent(wx.EVT_MOUSEWHEEL.typeId) mouse_event.x = mouse_pos.x mouse_event.y = mouse_pos.y @@ -1339,7 +1340,8 @@ maxy = int(maxy * self.ViewScale[1]) self.Editor.SetScrollbars( SCROLLBAR_UNIT, SCROLLBAR_UNIT, - round(maxx / SCROLLBAR_UNIT) + width_incr, round(maxy / SCROLLBAR_UNIT) + height_incr, + round(maxx / SCROLLBAR_UNIT) + width_incr, + round(maxy / SCROLLBAR_UNIT) + height_incr, xstart, ystart, True) def EnsureVisible(self, block): @@ -1356,13 +1358,13 @@ xpos, ypos = xstart, ystart if block_minx < screen_minx and block_maxx < screen_maxx: - xpos -= (screen_minx - block_minx) / SCROLLBAR_UNIT + 1 + xpos -= (screen_minx - block_minx) // SCROLLBAR_UNIT + 1 elif block_maxx > screen_maxx and block_minx > screen_minx: - xpos += (block_maxx - screen_maxx) / SCROLLBAR_UNIT + 1 + xpos += (block_maxx - screen_maxx) // SCROLLBAR_UNIT + 1 if block_miny < screen_miny and block_maxy < screen_maxy: - ypos -= (screen_miny - block_miny) / SCROLLBAR_UNIT + 1 + ypos -= (screen_miny - block_miny) // SCROLLBAR_UNIT + 1 elif block_maxy > screen_maxy and block_miny > screen_miny: - ypos += (block_maxy - screen_maxy) / SCROLLBAR_UNIT + 1 + ypos += (block_maxy - screen_maxy) // SCROLLBAR_UNIT + 1 self.Scroll(xpos, ypos) def SelectInGroup(self, element): @@ -2317,8 +2319,8 @@ new_pos = event.GetPosition() xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL) ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL) - scrollx = max(0, self.StartScreenPos[0] - (new_pos[0] - self.StartMousePos[0]) / SCROLLBAR_UNIT) - scrolly = max(0, self.StartScreenPos[1] - (new_pos[1] - self.StartMousePos[1]) / SCROLLBAR_UNIT) + scrollx = max(0, self.StartScreenPos[0] - (new_pos[0] - self.StartMousePos[0]) // SCROLLBAR_UNIT) + scrolly = max(0, self.StartScreenPos[1] - (new_pos[1] - self.StartMousePos[1]) // SCROLLBAR_UNIT) if scrollx > xmax or scrolly > ymax: self.RefreshScrollBars(max(0, scrollx - xmax), max(0, scrolly - ymax)) self.Scroll(scrollx, scrolly) @@ -2546,10 +2548,10 @@ variable = FBD_Variable(self, var_class, var_name, var_type, id) width, height = variable.GetMinSize() if scaling is not None: - x = round(float(x) / float(scaling[0])) * scaling[0] - y = round(float(y) / float(scaling[1])) * scaling[1] - width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] - height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] + x = round(x / scaling[0]) * scaling[0] + y = round(y / scaling[1]) * scaling[1] + width = round(width / scaling[0] + 0.5) * scaling[0] + height = round(height / scaling[1] + 0.5) * scaling[1] variable.SetPosition(x, y) variable.SetSize(width, height) self.AddBlock(variable) @@ -2566,8 +2568,8 @@ def GetScaledSize(self, width, height): if self.Scaling is not None: - width = round(float(width) / float(self.Scaling[0]) + 0.4) * self.Scaling[0] - height = round(float(height) / float(self.Scaling[1]) + 0.4) * self.Scaling[1] + width = round(width / self.Scaling[0] + 0.4) * self.Scaling[0] + height = round(height / self.Scaling[1] + 0.4) * self.Scaling[1] return width, height def AddNewElement(self, element, bbox, wire=None, connector=None): diff -r 82bfc75bcd9d -r 105c20fdeb19 etherlab/CommonEtherCATFunction.py --- a/etherlab/CommonEtherCATFunction.py Fri Oct 05 13:48:54 2018 +0300 +++ b/etherlab/CommonEtherCATFunction.py Fri Oct 05 14:22:01 2018 +0300 @@ -9,6 +9,7 @@ # See COPYING file for copyrights details. from __future__ import absolute_import +from __future__ import division from builtins import str as text import wx @@ -551,7 +552,7 @@ if (value_len % 2) == 0: hex_len = value_len else: - hex_len = (value_len / 2) * 2 + 2 + hex_len = (value_len // 2) * 2 + 2 hex_data = ("{:0>"+str(hex_len)+"x}").format(decnum) @@ -650,7 +651,7 @@ eeprom_list = [] if direction is 0 or 1: - for dummy in range(length/2): + for dummy in range(length//2): if data == "": eeprom_list.append("00") else: @@ -810,7 +811,7 @@ for eeprom_element in device.getEeprom().getcontent(): if eeprom_element["name"] == "ByteSize": eeprom_size = int(str(eeprom_element)) - data = "{:0>4x}".format(int(eeprom_element)/1024*8-1) + data = "{:0>4x}".format(int(eeprom_element)//1024*8-1) if data == "": eeprom.append("00") @@ -1134,15 +1135,15 @@ else: length += length % 4 padflag = True - eeprom.append("{:0>4x}".format(length/4)[2:4]) - eeprom.append("{:0>4x}".format(length/4)[0:2]) + eeprom.append("{:0>4x}".format(length//4)[2:4]) + eeprom.append("{:0>4x}".format(length//4)[0:2]) # total numbers of strings eeprom.append("{:0>2x}".format(count)) for element in [vendor_specific_data, dc_related_elements, input_elements, output_elements]: - for dummy in range(len(element)/2): + for dummy in range(len(element)//2): if element == "": eeprom.append("00") else: @@ -1287,11 +1288,11 @@ # category length if count % 2 == 1: padflag = True - eeprom.append("{:0>4x}".format((count+1)/2)[2:4]) - eeprom.append("{:0>4x}".format((count+1)/2)[0:2]) + eeprom.append("{:0>4x}".format((count+1)//2)[2:4]) + eeprom.append("{:0>4x}".format((count+1)//2)[0:2]) else: - eeprom.append("{:0>4x}".format((count)/2)[2:4]) - eeprom.append("{:0>4x}".format((count)/2)[0:2]) + eeprom.append("{:0>4x}".format((count)//2)[2:4]) + eeprom.append("{:0>4x}".format((count)//2)[0:2]) for dummy in range(count): if data == "": eeprom.append("00") @@ -1334,9 +1335,9 @@ eeprom.append("29") eeprom.append("00") # category length - eeprom.append("{:0>4x}".format(len(data)/4)[2:4]) - eeprom.append("{:0>4x}".format(len(data)/4)[0:2]) - for dummy in range(len(data)/2): + eeprom.append("{:0>4x}".format(len(data)//4)[2:4]) + eeprom.append("{:0>4x}".format(len(data)//4)[0:2]) + for dummy in range(len(data)//2): if data == "": eeprom.append("00") else: @@ -1442,10 +1443,10 @@ eeprom.append("00") eeprom.append("00") # category length - eeprom.append("{:0>4x}".format(len(data)/4)[2:4]) - eeprom.append("{:0>4x}".format(len(data)/4)[0:2]) + eeprom.append("{:0>4x}".format(len(data)//4)[2:4]) + eeprom.append("{:0>4x}".format(len(data)//4)[0:2]) data = str(data.lower()) - for dummy in range(len(data)/2): + for dummy in range(len(data)//2): if data == "": eeprom.append("00") else: @@ -1516,10 +1517,10 @@ eeprom.append("3c") eeprom.append("00") # category length - eeprom.append("{:0>4x}".format(len(data)/4)[2:4]) - eeprom.append("{:0>4x}".format(len(data)/4)[0:2]) + eeprom.append("{:0>4x}".format(len(data)//4)[2:4]) + eeprom.append("{:0>4x}".format(len(data)//4)[0:2]) data = str(data.lower()) - for dummy in range(len(data)/2): + for dummy in range(len(data)//2): if data == "": eeprom.append("00") else: diff -r 82bfc75bcd9d -r 105c20fdeb19 etherlab/ConfigEditor.py --- a/etherlab/ConfigEditor.py Fri Oct 05 13:48:54 2018 +0300 +++ b/etherlab/ConfigEditor.py Fri Oct 05 14:22:01 2018 +0300 @@ -10,6 +10,7 @@ # See COPYING file for copyrights details. from __future__ import absolute_import +from __future__ import division import os import re from types import TupleType @@ -324,12 +325,12 @@ xstart, ystart = self.EtherCATManagementEditor.GetViewStart() window_size = self.EtherCATManagementEditor.GetClientSize() maxx, maxy = self.EtherCATManagementEditor.GetMinSize() - posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) - posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) + posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) + posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) self.EtherCATManagementEditor.Scroll(posx, posy) self.EtherCATManagementEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, - maxx / SCROLLBAR_UNIT, - maxy / SCROLLBAR_UNIT, + maxx // SCROLLBAR_UNIT, + maxy // SCROLLBAR_UNIT, posx, posy) event.Skip() # ------------------------------------------------------------------------------------------------------- @@ -1056,12 +1057,12 @@ xstart, ystart = self.EthercatMasterEditor.GetViewStart() window_size = self.EthercatMasterEditor.GetClientSize() maxx, maxy = self.EthercatMasterEditorSizer.GetMinSize() - posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) - posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) + posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) + posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) self.EthercatMasterEditor.Scroll(posx, posy) self.EthercatMasterEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, - maxx / SCROLLBAR_UNIT, - maxy / SCROLLBAR_UNIT, + maxx // SCROLLBAR_UNIT, + maxy // SCROLLBAR_UNIT, posx, posy) event.Skip() @@ -1421,11 +1422,11 @@ xstart, ystart = self.ModuleLibraryEditor.GetViewStart() window_size = self.ModuleLibraryEditor.GetClientSize() maxx, maxy = self.ModuleLibraryEditor.GetMinSize() - posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) - posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) + posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) + posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) self.ModuleLibraryEditor.Scroll(posx, posy) self.ModuleLibraryEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, - maxx / SCROLLBAR_UNIT, - maxy / SCROLLBAR_UNIT, + maxx // SCROLLBAR_UNIT, + maxy // SCROLLBAR_UNIT, posx, posy) event.Skip() diff -r 82bfc75bcd9d -r 105c20fdeb19 etherlab/EtherCATManagementEditor.py --- a/etherlab/EtherCATManagementEditor.py Fri Oct 05 13:48:54 2018 +0300 +++ b/etherlab/EtherCATManagementEditor.py Fri Oct 05 14:22:01 2018 +0300 @@ -8,6 +8,7 @@ # See COPYING file for copyrights details. from __future__ import absolute_import +from __future__ import division import os import string from xml.dom import minidom @@ -422,7 +423,7 @@ self.Controler.CommonMethod.SaveSDOData[self.AllSDOData].append(self.Data) - if count >= len(self.SDOs.splitlines()) / 2: + if count >= len(self.SDOs.splitlines()) // 2: (keep_going, _skip) = slaveSDO_progress.Update(count, "Please waiting a moment!!") else: (keep_going, _skip) = slaveSDO_progress.Update(count) @@ -1034,7 +1035,7 @@ # Config Data: EEPROM Size, PDI Type, Device Emulation # EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1 - eeprom_size = str((int(self.GetWordAddressData(sii_dict.get('Size'), 10))+1)/8*1024) + eeprom_size = str((int(self.GetWordAddressData(sii_dict.get('Size'), 10))+1)//8*1024) # Find PDI Type in pdiType dictionary cnt_pdi_type = int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16).split('x')[1][2:4], 16) for i in self.PDIType.keys(): @@ -1363,10 +1364,10 @@ for col in range(self.Col): if col == 16: self.SetColLabelValue(16, "Text View") - self.SetColSize(16, (self.GetSize().x-120)*4/20) + self.SetColSize(16, (self.GetSize().x-120)*4//20) else: self.SetColLabelValue(col, '%s' % col) - self.SetColSize(col, (self.GetSize().x-120)/20) + self.SetColSize(col, (self.GetSize().x-120)//20) # set data into table row = col = 0 diff -r 82bfc75bcd9d -r 105c20fdeb19 etherlab/EthercatCFileGenerator.py --- a/etherlab/EthercatCFileGenerator.py Fri Oct 05 13:48:54 2018 +0300 +++ b/etherlab/EthercatCFileGenerator.py Fri Oct 05 14:22:01 2018 +0300 @@ -10,6 +10,7 @@ # See COPYING file for copyrights details. from __future__ import absolute_import +from __future__ import division import os from etherlab.EthercatSlave import ExtractHexDecValue, DATATYPECONVERSION, ExtractName @@ -254,7 +255,7 @@ subindex = initCmd["Subindex"] entry = device_entries.get((index, subindex), None) if entry is not None: - data_size = entry["BitSize"] / 8 + data_size = entry["BitSize"] // 8 data_str = ("0x%%.%dx" % (data_size * 2)) % initCmd["Value"] init_cmd_infos = { "index": index, @@ -413,7 +414,7 @@ elif pdo_type == "Outputs" and entry.getDataType() is not None and device_coe is not None: data_type = entry.getDataType().getcontent() entry_infos["dir"] = "Q" - entry_infos["data_size"] = max(1, entry_infos["bitlen"] / 8) + entry_infos["data_size"] = max(1, entry_infos["bitlen"] // 8) entry_infos["data_type"] = DATATYPECONVERSION.get(data_type) entry_infos["var_type"] = data_type entry_infos["real_var"] = "slave%(slave)d_%(index).4x_%(subindex).2x_default" % entry_infos diff -r 82bfc75bcd9d -r 105c20fdeb19 graphics/DebugDataConsumer.py --- a/graphics/DebugDataConsumer.py Fri Oct 05 13:48:54 2018 +0300 +++ b/graphics/DebugDataConsumer.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import datetime @@ -76,10 +77,10 @@ not_null = False for val, format in [ - (int(microseconds) / DAY, "%dd"), # Days - ((int(microseconds) % DAY) / HOUR, "%dh"), # Hours - ((int(microseconds) % HOUR) / MINUTE, "%dm"), # Minutes - ((int(microseconds) % MINUTE) / SECOND, "%ds")]: # Seconds + (int(microseconds) // DAY, "%dd"), # Days + ((int(microseconds) % DAY) // HOUR, "%dh"), # Hours + ((int(microseconds) % HOUR) // MINUTE, "%dm"), # Minutes + ((int(microseconds) % MINUTE) // SECOND, "%ds")]: # Seconds # Add value to TIME literal if value is non-null or another non-null # value have already be found @@ -128,9 +129,9 @@ data = "TOD#" for val, format in [ - (int(microseconds) / HOUR, "%2.2d:"), # Hours - ((int(microseconds) % HOUR) / MINUTE, "%2.2d:"), # Minutes - ((int(microseconds) % MINUTE) / SECOND, "%2.2d."), # Seconds + (int(microseconds) // HOUR, "%2.2d:"), # Hours + ((int(microseconds) % HOUR) // MINUTE, "%2.2d:"), # Minutes + ((int(microseconds) % MINUTE) // SECOND, "%2.2d."), # Seconds (microseconds % SECOND, "%6.6d")]: # Microseconds # Add value to TIME_OF_DAY literal diff -r 82bfc75bcd9d -r 105c20fdeb19 graphics/FBD_Objects.py --- a/graphics/FBD_Objects.py Fri Oct 05 13:48:54 2018 +0300 +++ b/graphics/FBD_Objects.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import wx from six.moves import xrange @@ -131,7 +132,7 @@ def GetTextBoundingBox(self): # Calculate the size of the name outside the block text_width, text_height = self.NameSize - return wx.Rect(self.Pos.x + (self.Size[0] - text_width) / 2, + return wx.Rect(self.Pos.x + (self.Size[0] - text_width) // 2, self.Pos.y - (text_height + 2), text_width, text_height) @@ -161,9 +162,9 @@ # Calculate the size for the connector lines lines = max(len(self.Inputs), len(self.Outputs)) if lines > 0: - linesize = max((self.Size[1] - BLOCK_LINE_SIZE) / lines, BLOCK_LINE_SIZE) + linesize = max((self.Size[1] - BLOCK_LINE_SIZE) // lines, BLOCK_LINE_SIZE) # Update inputs and outputs positions - position = BLOCK_LINE_SIZE + linesize / 2 + position = BLOCK_LINE_SIZE + linesize // 2 for i in xrange(lines): if scaling is not None: ypos = round_scaling(self.Pos.y + position, scaling[1]) - self.Pos.y @@ -479,9 +480,9 @@ # Draw a rectangle with the block size dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) # Draw block name and block type - name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) / 2, + name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, self.Pos.y - (name_size[1] + 2)) - type_pos = (self.Pos.x + (self.Size[0] - type_size[0]) / 2, + type_pos = (self.Pos.x + (self.Size[0] - type_size[0]) // 2, self.Pos.y + 5) dc.DrawText(self.Name, name_pos[0], name_pos[1]) dc.DrawText(self.Type, type_pos[0], type_pos[1]) @@ -592,7 +593,7 @@ bbx_width = self.Size[0] + 2 * CONNECTOR_SIZE else: bbx_width = self.Size[0] + CONNECTOR_SIZE - bbx_x = min(bbx_x, self.Pos.x + (self.Size[0] - self.NameSize[0]) / 2) + bbx_x = min(bbx_x, self.Pos.x + (self.Size[0] - self.NameSize[0]) // 2) bbx_width = max(bbx_width, self.NameSize[0]) bbx_height = self.Size[1] if self.ExecutionOrder != 0: @@ -605,9 +606,9 @@ def RefreshConnectors(self): scaling = self.Parent.GetScaling() if scaling is not None: - position = round_scaling(self.Pos.y + self.Size[1] / 2, scaling[1]) - self.Pos.y - else: - position = self.Size[1] / 2 + position = round_scaling(self.Pos.y + self.Size[1] // 2, scaling[1]) - self.Pos.y + else: + position = self.Size[1] // 2 if self.Input: self.Input.SetPosition(wx.Point(0, position)) if self.Output: @@ -778,8 +779,8 @@ name_size = self.NameSize executionorder_size = self.ExecutionOrderSize - text_pos = (self.Pos.x + (self.Size[0] - name_size[0]) / 2, - self.Pos.y + (self.Size[1] - name_size[1]) / 2) + text_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, + self.Pos.y + (self.Size[1] - name_size[1]) // 2) # Draw a rectangle with the variable size dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) # Draw variable name @@ -877,9 +878,9 @@ def RefreshConnectors(self): scaling = self.Parent.GetScaling() if scaling is not None: - position = round_scaling(self.Pos.y + self.Size[1] / 2, scaling[1]) - self.Pos.y - else: - position = self.Size[1] / 2 + position = round_scaling(self.Pos.y + self.Size[1] // 2, scaling[1]) - self.Pos.y + else: + position = self.Size[1] // 2 if self.Type == CONNECTOR: self.Connector.SetPosition(wx.Point(0, position)) else: @@ -1018,18 +1019,18 @@ # Draw a rectangle with the connection size with arrows inside dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) - arrowsize = min(self.Size[1] / 2, (self.Size[0] - name_size[0] - 10) / 2) + arrowsize = min(self.Size[1] // 2, (self.Size[0] - name_size[0] - 10) // 2) dc.DrawLine(self.Pos.x, self.Pos.y, self.Pos.x + arrowsize, - self.Pos.y + self.Size[1] / 2) - dc.DrawLine(self.Pos.x + arrowsize, self.Pos.y + self.Size[1] / 2, + self.Pos.y + self.Size[1] // 2) + dc.DrawLine(self.Pos.x + arrowsize, self.Pos.y + self.Size[1] // 2, self.Pos.x, self.Pos.y + self.Size[1]) dc.DrawLine(self.Pos.x + self.Size[0] - arrowsize, self.Pos.y, - self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] / 2) - dc.DrawLine(self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] / 2, + self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] // 2) + dc.DrawLine(self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] // 2, self.Pos.x + self.Size[0] - arrowsize, self.Pos.y + self.Size[1]) # Draw connection name - text_pos = (self.Pos.x + (self.Size[0] - name_size[0]) / 2, - self.Pos.y + (self.Size[1] - name_size[1]) / 2) + text_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, + self.Pos.y + (self.Size[1] - name_size[1]) // 2) dc.DrawText(self.Name, text_pos[0], text_pos[1]) # Draw connector if self.Connector: diff -r 82bfc75bcd9d -r 105c20fdeb19 graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Fri Oct 05 13:48:54 2018 +0300 +++ b/graphics/GraphicCommons.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division from math import * from types import * from six.moves import xrange @@ -116,7 +117,7 @@ def round_scaling(x, n, constraint=0): - fraction = float(x) / float(n) + fraction = x / n if constraint == -1: xround = int(fraction) else: @@ -186,8 +187,8 @@ """ pos = event.GetLogicalPosition(dc) if scaling: - pos.x = round(float(pos.x) / float(scaling[0])) * scaling[0] - pos.y = round(float(pos.y) / float(scaling[1])) * scaling[1] + pos.x = round(pos.x / scaling[0]) * scaling[0] + pos.y = round(pos.y / scaling[1]) * scaling[1] return pos @@ -435,11 +436,11 @@ pt = wx.Point(*self.Parent.CalcUnscrolledPosition(pos.x, pos.y)) left = (self.BoundingBox.x - 2) * scalex - HANDLE_SIZE - center = (self.BoundingBox.x + self.BoundingBox.width / 2) * scalex - HANDLE_SIZE / 2 + center = (self.BoundingBox.x + self.BoundingBox.width // 2) * scalex - HANDLE_SIZE // 2 right = (self.BoundingBox.x + self.BoundingBox.width + 2) * scalex top = (self.BoundingBox.y - 2) * scaley - HANDLE_SIZE - middle = (self.BoundingBox.y + self.BoundingBox.height / 2) * scaley - HANDLE_SIZE / 2 + middle = (self.BoundingBox.y + self.BoundingBox.height / 2) * scaley - HANDLE_SIZE // 2 bottom = (self.BoundingBox.y + self.BoundingBox.height + 2) * scaley extern_rect = wx.Rect(left, top, right + HANDLE_SIZE - left, bottom + HANDLE_SIZE - top) @@ -683,11 +684,11 @@ dc.SetBrush(wx.BLACK_BRUSH) left = (self.BoundingBox.x - 2) * scalex - HANDLE_SIZE - center = (self.BoundingBox.x + self.BoundingBox.width / 2) * scalex - HANDLE_SIZE / 2 + center = (self.BoundingBox.x + self.BoundingBox.width // 2) * scalex - HANDLE_SIZE // 2 right = (self.BoundingBox.x + self.BoundingBox.width + 2) * scalex top = (self.BoundingBox.y - 2) * scaley - HANDLE_SIZE - middle = (self.BoundingBox.y + self.BoundingBox.height / 2) * scaley - HANDLE_SIZE / 2 + middle = (self.BoundingBox.y + self.BoundingBox.height // 2) * scaley - HANDLE_SIZE // 2 bottom = (self.BoundingBox.y + self.BoundingBox.height + 2) * scaley for x, y in [(left, top), (center, top), (right, top), @@ -859,13 +860,13 @@ if horizontally == ALIGN_LEFT: movex = minx - posx elif horizontally == ALIGN_CENTER: - movex = (maxx + minx - width) / 2 - posx + movex = (maxx + minx - width) // 2 - posx elif horizontally == ALIGN_RIGHT: movex = maxx - width - posx if vertically == ALIGN_TOP: movey = miny - posy elif vertically == ALIGN_MIDDLE: - movey = (maxy + miny - height) / 2 - posy + movey = (maxy + miny - height) // 2 - posy elif vertically == ALIGN_BOTTOM: movey = maxy - height - posy if movex != 0 or movey != 0: @@ -1087,7 +1088,7 @@ rect = rect.Union( wx.Rect( parent_pos[0] + self.Pos.x + CONNECTOR_SIZE * self.Direction[0] + - width * (self.Direction[0] - 1) / 2, + width * (self.Direction[0] - 1) // 2, parent_pos[1] + self.Pos.y + CONNECTOR_SIZE * self.Direction[1] + height * (self.Direction[1] - 1), width, height)) @@ -1492,9 +1493,9 @@ if self.Negated: # If connector is negated, draw a circle - xcenter = parent_pos[0] + self.Pos.x + (CONNECTOR_SIZE * self.Direction[0]) / 2 - ycenter = parent_pos[1] + self.Pos.y + (CONNECTOR_SIZE * self.Direction[1]) / 2 - dc.DrawCircle(xcenter, ycenter, CONNECTOR_SIZE / 2) + xcenter = parent_pos[0] + self.Pos.x + (CONNECTOR_SIZE * self.Direction[0]) // 2 + ycenter = parent_pos[1] + self.Pos.y + (CONNECTOR_SIZE * self.Direction[1]) // 2 + dc.DrawCircle(xcenter, ycenter, CONNECTOR_SIZE // 2) else: xstart = parent_pos[0] + self.Pos.x ystart = parent_pos[1] + self.Pos.y @@ -1519,13 +1520,13 @@ yend = ystart + CONNECTOR_SIZE * self.Direction[1] dc.DrawLine(xstart + self.Direction[0], ystart + self.Direction[1], xend, yend) if self.Direction[0] != 0: - ytext = parent_pos[1] + self.Pos.y - name_size[1] / 2 + ytext = parent_pos[1] + self.Pos.y - name_size[1] // 2 if self.Direction[0] < 0: xtext = parent_pos[0] + self.Pos.x + 5 else: xtext = parent_pos[0] + self.Pos.x - (name_size[0] + 5) if self.Direction[1] != 0: - xtext = parent_pos[0] + self.Pos.x - name_size[0] / 2 + xtext = parent_pos[0] + self.Pos.x - name_size[0] // 2 if self.Direction[1] < 0: ytext = parent_pos[1] + self.Pos.y + 5 else: @@ -1544,7 +1545,7 @@ width, height = self.ValueSize dc.DrawText(self.ComputedValue, parent_pos[0] + self.Pos.x + CONNECTOR_SIZE * self.Direction[0] + - width * (self.Direction[0] - 1) / 2, + width * (self.Direction[0] - 1) // 2, parent_pos[1] + self.Pos.y + CONNECTOR_SIZE * self.Direction[1] + height * (self.Direction[1] - 1)) dc.SetFont(self.ParentBlock.Parent.GetFont()) @@ -1611,17 +1612,17 @@ if self.ValueSize is not None: width, height = self.ValueSize if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4: - x = self.Points[0].x + width * self.StartPoint[1][0] / 2 + x = self.Points[0].x + width * self.StartPoint[1][0] // 2 y = self.Points[0].y + height * (self.StartPoint[1][1] - 1) rect = rect.Union(wx.Rect(x, y, width, height)) - x = self.Points[-1].x + width * self.EndPoint[1][0] / 2 + x = self.Points[-1].x + width * self.EndPoint[1][0] // 2 y = self.Points[-1].y + height * (self.EndPoint[1][1] - 1) rect = rect.Union(wx.Rect(x, y, width, height)) else: - middle = len(self.Segments) / 2 + len(self.Segments) % 2 - 1 - x = (self.Points[middle].x + self.Points[middle + 1].x - width) / 2 + middle = len(self.Segments) // 2 + len(self.Segments) % 2 - 1 + x = (self.Points[middle].x + self.Points[middle + 1].x - width) // 2 if self.BoundingBox[3] > height and self.Segments[middle] in [NORTH, SOUTH]: - y = (self.Points[middle].y + self.Points[middle + 1].y - height) / 2 + y = (self.Points[middle].y + self.Points[middle + 1].y - height) // 2 else: y = self.Points[middle].y - height rect = rect.Union(wx.Rect(x, y, width, height)) @@ -2092,9 +2093,9 @@ # Current point is positioned in the middle of start point # and end point on the current direction and a point is added if self.Segments[0][0] != 0: - self.Points[1].x = (end.x + start.x) / 2 + self.Points[1].x = (end.x + start.x) // 2 if self.Segments[0][1] != 0: - self.Points[1].y = (end.y + start.y) / 2 + self.Points[1].y = (end.y + start.y) // 2 self.Points.insert(2, wx.Point(self.Points[1].x, self.Points[1].y)) self.Segments.insert(2, DirectionChoice( (self.Segments[1][1], @@ -2136,9 +2137,9 @@ # Current point is positioned in the middle of previous point # and end point on the current direction and a point is added if self.Segments[1][0] != 0: - self.Points[2].x = (self.Points[1].x + end.x) / 2 + self.Points[2].x = (self.Points[1].x + end.x) // 2 if self.Segments[1][1] != 0: - self.Points[2].y = (self.Points[1].y + end.y) / 2 + self.Points[2].y = (self.Points[1].y + end.y) // 2 self.Points.insert(3, wx.Point(self.Points[2].x, self.Points[2].y)) self.Segments.insert( 3, @@ -2160,9 +2161,9 @@ # Current point is positioned in the middle of previous point # and end point on the current direction if self.Segments[i - 1][0] != 0: - self.Points[i].x = (end.x + self.Points[i - 1].x) / 2 + self.Points[i].x = (end.x + self.Points[i - 1].x) // 2 if self.Segments[i - 1][1] != 0: - self.Points[i].y = (end.y + self.Points[i - 1].y) / 2 + self.Points[i].y = (end.y + self.Points[i - 1].y) // 2 # A point is added self.Points.insert(i + 1, wx.Point(self.Points[i].x, self.Points[i].y)) self.Segments.insert( @@ -2242,9 +2243,9 @@ dir = self.EndPoint[1] else: dir = (0, 0) - pointx = max(-dir[0] * MIN_SEGMENT_SIZE, min(int(round(point[0] * width / float(max(lastwidth, 1)))), + pointx = max(-dir[0] * MIN_SEGMENT_SIZE, min(int(round(point[0] * width / max(lastwidth, 1))), width - dir[0] * MIN_SEGMENT_SIZE)) - pointy = max(-dir[1] * MIN_SEGMENT_SIZE, min(int(round(point[1] * height / float(max(lastheight, 1)))), + pointy = max(-dir[1] * MIN_SEGMENT_SIZE, min(int(round(point[1] * height / max(lastheight, 1))), height - dir[1] * MIN_SEGMENT_SIZE)) self.Points[i] = wx.Point(minx + x + pointx, miny + y + pointy) self.StartPoint[0] = self.Points[0] @@ -2266,8 +2267,8 @@ # during a resize dragging for i, point in enumerate(self.RealPoints): if not (i == 0 and self.StartConnected) and not (i == len(self.Points) - 1 and self.EndConnected): - point[0] = point[0] * width / float(max(lastwidth, 1)) - point[1] = point[1] * height / float(max(lastheight, 1)) + point[0] = point[0] * width / max(lastwidth, 1) + point[1] = point[1] * height / max(lastheight, 1) # Calculate the correct position of the points from real points for i, point in enumerate(self.RealPoints): if not (i == 0 and self.StartConnected) and not (i == len(self.Points) - 1 and self.EndConnected): @@ -2399,9 +2400,9 @@ pointx = self.Points[segment].x pointy = self.Points[segment].y if dir[0] != 0: - pointx = (self.Points[segment].x + self.Points[segment + 1].x) / 2 + pointx = (self.Points[segment].x + self.Points[segment + 1].x) // 2 if dir[1] != 0: - pointy = (self.Points[segment].y + self.Points[segment + 1].y) / 2 + pointy = (self.Points[segment].y + self.Points[segment + 1].y) // 2 self.Points.insert(segment + 1, wx.Point(pointx, pointy)) self.Segments.insert(segment + 1, (dir[1], dir[0])) self.Points.insert(segment + 2, wx.Point(pointx, pointy)) @@ -2410,11 +2411,11 @@ p1x = p2x = self.Points[segment].x p1y = p2y = self.Points[segment].y if dir[0] != 0: - p1x = (2 * self.Points[segment].x + self.Points[segment + 1].x) / 3 - p2x = (self.Points[segment].x + 2 * self.Points[segment + 1].x) / 3 + p1x = (2 * self.Points[segment].x + self.Points[segment + 1].x) // 3 + p2x = (self.Points[segment].x + 2 * self.Points[segment + 1].x) // 3 if dir[1] != 0: - p1y = (2 * self.Points[segment].y + self.Points[segment + 1].y) / 3 - p2y = (self.Points[segment].y + 2 * self.Points[segment + 1].y) / 3 + p1y = (2 * self.Points[segment].y + self.Points[segment + 1].y) // 3 + p2y = (self.Points[segment].y + 2 * self.Points[segment + 1].y) // 3 self.Points.insert(segment + 1, wx.Point(p1x, p1y)) self.Segments.insert(segment + 1, (dir[1], dir[0])) self.Points.insert(segment + 2, wx.Point(p1x, p1y)) @@ -2477,9 +2478,9 @@ if event.ControlDown(): direction = (self.StartPoint[1], self.EndPoint[1]) if direction in [(EAST, WEST), (WEST, EAST)]: - avgy = (self.StartPoint[0].y + self.EndPoint[0].y) / 2 + avgy = (self.StartPoint[0].y + self.EndPoint[0].y) // 2 if scaling is not None: - avgy = round(float(avgy) / scaling[1]) * scaling[1] + avgy = round(avgy / scaling[1]) * scaling[1] if self.StartConnected is not None: movey = avgy - self.StartPoint[0].y startblock = self.StartConnected.GetParentBlock() @@ -2498,9 +2499,9 @@ self.MoveEndPoint(wx.Point(self.EndPoint[0].x, avgy)) self.Parent.RefreshBuffer() elif direction in [(NORTH, SOUTH), (SOUTH, NORTH)]: - avgx = (self.StartPoint[0].x + self.EndPoint[0].x) / 2 + avgx = (self.StartPoint[0].x + self.EndPoint[0].x) // 2 if scaling is not None: - avgx = round(float(avgx) / scaling[0]) * scaling[0] + avgx = round(avgx / scaling[0]) * scaling[0] if self.StartConnected is not None: movex = avgx - self.StartPoint[0].x startblock = self.StartConnected.GetParentBlock() @@ -2726,17 +2727,17 @@ if self.ValueSize is not None: width, height = self.ValueSize if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4: - x = self.Points[0].x + width * (self.StartPoint[1][0] - 1) / 2 + x = self.Points[0].x + width * (self.StartPoint[1][0] - 1) // 2 y = self.Points[0].y + height * (self.StartPoint[1][1] - 1) dc.DrawText(self.ComputedValue, x, y) - x = self.Points[-1].x + width * (self.EndPoint[1][0] - 1) / 2 + x = self.Points[-1].x + width * (self.EndPoint[1][0] - 1) // 2 y = self.Points[-1].y + height * (self.EndPoint[1][1] - 1) dc.DrawText(self.ComputedValue, x, y) else: - middle = len(self.Segments) / 2 + len(self.Segments) % 2 - 1 - x = (self.Points[middle].x + self.Points[middle + 1].x - width) / 2 + middle = len(self.Segments) // 2 + len(self.Segments) % 2 - 1 + x = (self.Points[middle].x + self.Points[middle + 1].x - width) // 2 if self.BoundingBox[3] > height and self.Segments[middle] in [NORTH, SOUTH]: - y = (self.Points[middle].y + self.Points[middle + 1].y - height) / 2 + y = (self.Points[middle].y + self.Points[middle + 1].y - height) // 2 else: y = self.Points[middle].y - height dc.DrawText(self.ComputedValue, x, y) diff -r 82bfc75bcd9d -r 105c20fdeb19 graphics/LD_Objects.py --- a/graphics/LD_Objects.py Fri Oct 05 13:48:54 2018 +0300 +++ b/graphics/LD_Objects.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import wx from six.moves import xrange @@ -49,7 +50,7 @@ self.Connectors = [] self.RealConnectors = None self.Id = id - self.Extensions = [LD_LINE_SIZE / 2, LD_LINE_SIZE / 2] + self.Extensions = [LD_LINE_SIZE // 2, LD_LINE_SIZE // 2] self.SetType(type, connectors) def Flush(self): @@ -184,14 +185,14 @@ def RefreshConnectors(self): scaling = self.Parent.GetScaling() height = self.Size[1] - self.Extensions[0] - self.Extensions[1] - interval = float(height) / float(max(len(self.Connectors) - 1, 1)) + interval = height / max(len(self.Connectors) - 1, 1) for i, connector in enumerate(self.Connectors): if self.RealConnectors: position = self.Extensions[0] + int(round(self.RealConnectors[i] * height)) else: position = self.Extensions[0] + int(round(i * interval)) if scaling is not None: - position = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y + position = round((self.Pos.y + position) / scaling[1]) * scaling[1] - self.Pos.y if self.Type == LEFTRAIL: connector.SetPosition(wx.Point(self.Size[0], position)) elif self.Type == RIGHTRAIL: @@ -251,7 +252,7 @@ if height > 0: for connector in self.Connectors: position = connector.GetRelPosition() - self.RealConnectors.append(max(0., min(float(position.y - self.Extensions[0]) / float(height), 1.))) + self.RealConnectors.append(max(0., min((position.y - self.Extensions[0]) / height, 1.))) elif len(self.Connectors) > 1: self.RealConnectors = map(lambda x: x * 1 / (len(self.Connectors) - 1), xrange(len(self.Connectors))) else: @@ -312,7 +313,7 @@ movey = max(-self.BoundingBox.y, movey) if scaling is not None: position = handle.GetRelPosition() - movey = round(float(self.Pos.y + position.y + movey) / float(scaling[1])) * scaling[1] - self.Pos.y - position.y + movey = round((self.Pos.y + position.y + movey) / scaling[1]) * scaling[1] - self.Pos.y - position.y self.MoveConnector(handle, movey) return 0, movey elif self.Parent.GetDrawingMode() == FREEDRAWING_MODE: @@ -363,8 +364,8 @@ self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1]) self.Highlights = {} # Create an input and output connector - self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST) - self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST) + self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] // 2 + 1), WEST) + self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] // 2 + 1), EAST) self.PreviousValue = False self.PreviousSpreading = False self.RefreshNameSize() @@ -493,7 +494,7 @@ text_width, text_height = self.Parent.GetTextExtent(self.Name) # Calculate the bounding box size if self.Name != "": - bbx_x = self.Pos.x - max(0, (text_width - self.Size[0]) / 2) + bbx_x = self.Pos.x - max(0, (text_width - self.Size[0]) // 2) bbx_width = max(self.Size[0], text_width) bbx_y = self.Pos.y - (text_height + 2) bbx_height = self.Size[1] + (text_height + 2) @@ -541,9 +542,9 @@ # Refresh the positions of the block connectors def RefreshConnectors(self): scaling = self.Parent.GetScaling() - position = self.Size[1] / 2 + 1 + position = self.Size[1] // 2 + 1 if scaling is not None: - position = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y + position = round((self.Pos.y + position) / scaling[1]) * scaling[1] - self.Pos.y self.Input.SetPosition(wx.Point(0, position)) self.Output.SetPosition(wx.Point(self.Size[0], position)) self.RefreshConnected() @@ -670,13 +671,13 @@ dc.DrawRectangle(self.Pos.x, self.Pos.y, 2, self.Size[1] + 1) dc.DrawRectangle(self.Pos.x + self.Size[0] - 1, self.Pos.y, 2, self.Size[1] + 1) # Draw contact name - name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) / 2, + name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, self.Pos.y - (name_size[1] + 2)) dc.DrawText(self.Name, name_pos[0], name_pos[1]) # Draw the modifier symbol in the middle of contact if typetext != "": - type_pos = (self.Pos.x + (self.Size[0] - type_size[0]) / 2 + 1, - self.Pos.y + (self.Size[1] - type_size[1]) / 2) + type_pos = (self.Pos.x + (self.Size[0] - type_size[0]) // 2 + 1, + self.Pos.y + (self.Size[1] - type_size[1]) // 2) dc.DrawText(typetext, type_pos[0], type_pos[1]) # Draw input and output connectors self.Input.Draw(dc) @@ -709,8 +710,8 @@ self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1]) self.Highlights = {} # Create an input and output connector - self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST) - self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST) + self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] // 2 + 1), WEST) + self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] // 2 + 1), EAST) self.Value = None self.PreviousValue = False self.RefreshNameSize() @@ -813,7 +814,7 @@ text_width, text_height = self.Parent.GetTextExtent(self.Name) # Calculate the bounding box size if self.Name != "": - bbx_x = self.Pos.x - max(0, (text_width - self.Size[0]) / 2) + bbx_x = self.Pos.x - max(0, (text_width - self.Size[0]) // 2) bbx_width = max(self.Size[0], text_width) bbx_y = self.Pos.y - (text_height + 2) bbx_height = self.Size[1] + (text_height + 2) @@ -861,9 +862,9 @@ # Refresh the positions of the block connectors def RefreshConnectors(self): scaling = self.Parent.GetScaling() - position = self.Size[1] / 2 + 1 + position = self.Size[1] // 2 + 1 if scaling is not None: - position = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y + position = round((self.Pos.y + position) / scaling[1]) * scaling[1] - self.Pos.y self.Input.SetPosition(wx.Point(0, position)) self.Output.SetPosition(wx.Point(self.Size[0], position)) self.RefreshConnected() @@ -993,19 +994,19 @@ dc.SetPen(MiterPen(wx.GREEN)) else: dc.SetPen(MiterPen(wx.BLACK)) - dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1) + dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] // 2 + 1) name_size = self.NameSize if typetext != "": type_size = self.TypeSize # Draw coil name - name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) / 2, + name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, self.Pos.y - (name_size[1] + 2)) dc.DrawText(self.Name, name_pos[0], name_pos[1]) # Draw the modifier symbol in the middle of coil if typetext != "": - type_pos = (self.Pos.x + (self.Size[0] - type_size[0]) / 2 + 1, - self.Pos.y + (self.Size[1] - type_size[1]) / 2) + type_pos = (self.Pos.x + (self.Size[0] - type_size[0]) // 2 + 1, + self.Pos.y + (self.Size[1] - type_size[1]) // 2) dc.DrawText(typetext, type_pos[0], type_pos[1]) # Draw input and output connectors self.Input.Draw(dc) diff -r 82bfc75bcd9d -r 105c20fdeb19 graphics/SFC_Objects.py --- a/graphics/SFC_Objects.py Fri Oct 05 13:48:54 2018 +0300 +++ b/graphics/SFC_Objects.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import wx from six.moves import xrange @@ -59,7 +60,7 @@ self.Size = wx.Size(SFC_STEP_DEFAULT_SIZE[0], SFC_STEP_DEFAULT_SIZE[1]) # Create an input and output connector if not self.Initial: - self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH) + self.Input = Connector(self, "", None, wx.Point(self.Size[0] // 2, 0), NORTH) else: self.Input = None self.Output = None @@ -171,7 +172,7 @@ # Add output connector to step def AddInput(self): if not self.Input: - self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH) + self.Input = Connector(self, "", None, wx.Point(self.Size[0] // 2, 0), NORTH) self.RefreshBoundingBox() # Remove output connector from step @@ -184,7 +185,7 @@ # Add output connector to step def AddOutput(self): if not self.Output: - self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True) + self.Output = Connector(self, "", None, wx.Point(self.Size[0] // 2, self.Size[1]), SOUTH, onlyone=True) self.RefreshBoundingBox() # Remove output connector from step @@ -197,7 +198,7 @@ # Add action connector to step def AddAction(self): if not self.Action: - self.Action = Connector(self, "", None, wx.Point(self.Size[0], self.Size[1] / 2), EAST, onlyone=True) + self.Action = Connector(self, "", None, wx.Point(self.Size[0], self.Size[1] // 2), EAST, onlyone=True) self.RefreshBoundingBox() # Remove action connector from step @@ -232,11 +233,11 @@ # Refresh the positions of the step connectors def RefreshConnectors(self): scaling = self.Parent.GetScaling() - horizontal_pos = self.Size[0] / 2 - vertical_pos = self.Size[1] / 2 + horizontal_pos = self.Size[0] // 2 + vertical_pos = self.Size[1] // 2 if scaling is not None: - horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x - vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y + horizontal_pos = round((self.Pos.x + horizontal_pos) / scaling[0]) * scaling[0] - self.Pos.x + vertical_pos = round((self.Pos.y + vertical_pos) / scaling[1]) * scaling[1] - self.Pos.y # Update input position if it exists if self.Input: self.Input.SetPosition(wx.Point(horizontal_pos, 0)) @@ -363,7 +364,7 @@ # Updates the step size def UpdateSize(self, width, height): - diffx = self.Size.GetWidth() / 2 - width / 2 + diffx = self.Size.GetWidth() // 2 - width // 2 diffy = height - self.Size.GetHeight() self.Move(diffx, 0) Graphic_Element.SetSize(self, width, height) @@ -463,8 +464,8 @@ movex = max(-self.BoundingBox.x, movex) movey = max(-self.BoundingBox.y, movey) if scaling is not None: - movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x - movey = round(float(self.Pos.y + movey) / float(scaling[1])) * scaling[1] - self.Pos.y + movex = round((self.Pos.x + movex) / scaling[0]) * scaling[0] - self.Pos.x + movey = round((self.Pos.y + movey) / scaling[1]) * scaling[1] - self.Pos.y if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: self.Move(movex, movey) self.RefreshConnected() @@ -557,8 +558,8 @@ if self.Initial: dc.DrawRectangle(self.Pos.x + 2, self.Pos.y + 2, self.Size[0] - 3, self.Size[1] - 3) # Draw step name - name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) / 2, - self.Pos.y + (self.Size[1] - name_size[1]) / 2) + name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, + self.Pos.y + (self.Size[1] - name_size[1]) // 2) dc.DrawText(self.Name, name_pos[0], name_pos[1]) # Draw input and output connectors if self.Input: @@ -591,8 +592,8 @@ self.Priority = 0 self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1]) # Create an input and output connector - self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True) - self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True) + self.Input = Connector(self, "", None, wx.Point(self.Size[0] // 2, 0), NORTH, onlyone=True) + self.Output = Connector(self, "", None, wx.Point(self.Size[0] // 2, self.Size[1]), SOUTH, onlyone=True) self.SetType(type, condition) self.SetPriority(priority) self.Highlights = {} @@ -713,7 +714,7 @@ # Calculate the bounding box of the condition outside the transition text_width, text_height = self.ConditionSize text_bbx = wx.Rect(self.Pos.x + self.Size[0] + 5, - self.Pos.y + (self.Size[1] - text_height) / 2, + self.Pos.y + (self.Size[1] - text_height) // 2, text_width, text_height) test_text = text_bbx.InsideXY(pt.x, pt.y) @@ -735,8 +736,8 @@ text_width, text_height = self.ConditionSize # Calculate the bounding box size bbx_width = max(bbx_width, self.Size[0] + 5 + text_width) - bbx_y = min(bbx_y, self.Pos.y - max(0, (text_height - self.Size[1]) / 2)) - bbx_height = max(bbx_height, self.Pos.y - bbx_y + (self.Size[1] + text_height) / 2) + bbx_y = min(bbx_y, self.Pos.y - max(0, (text_height - self.Size[1]) // 2)) + bbx_height = max(bbx_height, self.Pos.y - bbx_y + (self.Size[1] + text_height) // 2) self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1) # Returns the connector connected to input @@ -756,11 +757,11 @@ # Refresh the positions of the transition connectors def RefreshConnectors(self): scaling = self.Parent.GetScaling() - horizontal_pos = self.Size[0] / 2 - vertical_pos = self.Size[1] / 2 + horizontal_pos = self.Size[0] // 2 + vertical_pos = self.Size[1] // 2 if scaling is not None: - horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x - vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y + horizontal_pos = round((self.Pos.x + horizontal_pos) / scaling[0]) * scaling[0] - self.Pos.x + vertical_pos = round((self.Pos.y + vertical_pos) / scaling[1]) * scaling[1] - self.Pos.y # Update input position self.Input.SetPosition(wx.Point(horizontal_pos, 0)) # Update output position @@ -822,7 +823,7 @@ self.Condition.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE) self.Type = type if type == "connection": - self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2), WEST) + self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] // 2), WEST) else: if condition is None: condition = "" @@ -917,7 +918,7 @@ if self.Parent.GetDrawingMode() != FREEDRAWING_MODE: movex = max(-self.BoundingBox.x, movex) if scaling is not None: - movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x + movex = round((self.Pos.x + movex) / scaling[0]) * scaling[0] - self.Pos.x self.Move(movex, 0) self.RefreshInputPosition() self.RefreshOutputPosition() @@ -1009,7 +1010,7 @@ # Draw plain rectangle for representing the transition dc.DrawRectangle(self.Pos.x, - self.Pos.y + (self.Size[1] - SFC_TRANSITION_SIZE[1])/2, + self.Pos.y + (self.Size[1] - SFC_TRANSITION_SIZE[1]) // 2, self.Size[0] + 1, SFC_TRANSITION_SIZE[1] + 1) vertical_line_x = self.Input.GetPosition()[0] @@ -1021,7 +1022,7 @@ else: condition = "Transition" condition_pos = (self.Pos.x + self.Size[0] + 5, - self.Pos.y + (self.Size[1] - condition_size[1]) / 2) + self.Pos.y + (self.Size[1] - condition_size[1]) // 2) dc.DrawText(condition, condition_pos[0], condition_pos[1]) # Draw priority number if self.Priority != 0: @@ -1062,7 +1063,7 @@ self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, self.GetMinSize()[1]) # Create an input and output connector if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: - self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True)] + self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] // 2, 0), NORTH, onlyone=True)] self.Outputs = [] for i in xrange(number): self.Outputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone=True)) @@ -1070,7 +1071,7 @@ self.Inputs = [] for i in xrange(number): self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone=True)) - self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True)] + self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] // 2, self.Size[1]), SOUTH, onlyone=True)] self.Value = None self.PreviousValue = None @@ -1285,14 +1286,14 @@ if self.RealConnectors: input.SetPosition(wx.Point(int(round(self.RealConnectors["Inputs"][i] * width)), 0)) else: - input.SetPosition(wx.Point(int(round(float(position.x)*float(width)/float(self.Size[0]))), 0)) + input.SetPosition(wx.Point(int(round(position.x*width / self.Size[0])), 0)) input.MoveConnected() for i, output in enumerate(self.Outputs): position = output.GetRelPosition() if self.RealConnectors: output.SetPosition(wx.Point(int(round(self.RealConnectors["Outputs"][i] * width)), height)) else: - output.SetPosition(wx.Point(int(round(float(position.x)*float(width)/float(self.Size[0]))), height)) + output.SetPosition(wx.Point(int(round(position.x*width / self.Size[0])), height)) output.MoveConnected() self.Size = wx.Size(width, height) self.RefreshBoundingBox() @@ -1368,10 +1369,10 @@ self.RealConnectors = {"Inputs": [], "Outputs": []} for input in self.Inputs: position = input.GetRelPosition() - self.RealConnectors["Inputs"].append(float(position.x)/float(self.Size[0])) + self.RealConnectors["Inputs"].append(position.x / self.Size[0]) for output in self.Outputs: position = output.GetRelPosition() - self.RealConnectors["Outputs"].append(float(position.x)/float(self.Size[0])) + self.RealConnectors["Outputs"].append(position.x / self.Size[0]) Graphic_Element.OnLeftDown(self, event, dc, scaling) # Method called when a LeftUp event have been generated @@ -1425,7 +1426,7 @@ if handle_type == HANDLE_CONNECTOR: movex = max(-self.BoundingBox.x, movex) if scaling is not None: - movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x + movex = round((self.Pos.x + movex) / scaling[0]) * scaling[0] - self.Pos.x self.MoveConnector(handle, movex) if self.Parent.GetDrawingMode() != FREEDRAWING_MODE: self.RefreshConnectedPosition(handle) @@ -1519,7 +1520,7 @@ self.Size = wx.Size(SFC_JUMP_SIZE[0], SFC_JUMP_SIZE[1]) self.Highlights = [] # Create an input and output connector - self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True) + self.Input = Connector(self, "", None, wx.Point(self.Size[0] // 2, 0), NORTH, onlyone=True) self.Value = None self.PreviousValue = None @@ -1586,7 +1587,7 @@ # Calculate the bounding box of the condition outside the transition text_width, text_height = self.TargetSize text_bbx = wx.Rect(self.Pos.x + self.Size[0] + 2, - self.Pos.y + (self.Size[1] - text_height) / 2, + self.Pos.y + (self.Size[1] - text_height) // 2, text_width, text_height) return text_bbx.InsideXY(pt.x, pt.y) or Graphic_Element.HitTest(self, pt, connectors) @@ -1609,9 +1610,9 @@ # Refresh the element connectors position def RefreshConnectors(self): scaling = self.Parent.GetScaling() - horizontal_pos = self.Size[0] / 2 + horizontal_pos = self.Size[0] // 2 if scaling is not None: - horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x + horizontal_pos = round((self.Pos.x + horizontal_pos) / scaling[0]) * scaling[0] - self.Pos.x self.Input.SetPosition(wx.Point(horizontal_pos, 0)) self.RefreshConnected() @@ -1685,7 +1686,7 @@ if self.Parent.GetDrawingMode() != FREEDRAWING_MODE: movex = max(-self.BoundingBox.x, movex) if scaling is not None: - movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x + movex = round((self.Pos.x + movex) / scaling[0]) * scaling[0] - self.Pos.x self.Move(movex, 0) self.RefreshInputPosition() return movex, 0 @@ -1760,14 +1761,14 @@ target_size = self.TargetSize # Draw plain rectangle for representing the divergence - dc.DrawLine(self.Pos.x + self.Size[0] / 2, self.Pos.y, self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1]) + dc.DrawLine(self.Pos.x + self.Size[0] // 2, self.Pos.y, self.Pos.x + self.Size[0] // 2, self.Pos.y + self.Size[1]) points = [wx.Point(self.Pos.x, self.Pos.y), - wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1] / 3), + wx.Point(self.Pos.x + self.Size[0] // 2, self.Pos.y + self.Size[1] // 3), wx.Point(self.Pos.x + self.Size[0], self.Pos.y), - wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1])] + wx.Point(self.Pos.x + self.Size[0] // 2, self.Pos.y + self.Size[1])] dc.DrawPolygon(points) target_pos = (self.Pos.x + self.Size[0] + 2, - self.Pos.y + (self.Size[1] - target_size[1]) / 2) + self.Pos.y + (self.Size[1] - target_size[1]) // 2) dc.DrawText(self.Target, target_pos[0], target_pos[1]) # Draw input connector if self.Input: @@ -1795,7 +1796,7 @@ self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1]) self.Highlights = {} # Create an input and output connector - self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone=True) + self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] // 2), WEST, onlyone=True) self.SetActions(actions) self.Value = None self.PreviousValue = None @@ -1843,7 +1844,7 @@ def GetLineSize(self): if len(self.Actions) > 0: - return self.Size[1] / len(self.Actions) + return self.Size[1] // len(self.Actions) else: return SFC_ACTION_MIN_SIZE[1] @@ -1889,9 +1890,9 @@ # Refresh the element connectors position def RefreshConnectors(self): scaling = self.Parent.GetScaling() - vertical_pos = SFC_ACTION_MIN_SIZE[1] / 2 + vertical_pos = SFC_ACTION_MIN_SIZE[1] // 2 if scaling is not None: - vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y + vertical_pos = round((self.Pos.y + vertical_pos) / scaling[1]) * scaling[1] - self.Pos.y self.Input.SetPosition(wx.Point(0, vertical_pos)) self.RefreshConnected() @@ -1962,7 +1963,7 @@ if handle_type == HANDLE_MOVE: movex = max(-self.BoundingBox.x, movex) if scaling is not None: - movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x + movex = round((self.Pos.x + movex) / scaling[0]) * scaling[0] - self.Pos.x wires = self.Input.GetWires() if len(wires) == 1: input_pos = wires[0][0].GetOtherConnected(self.Input).GetPosition(False) @@ -2033,24 +2034,24 @@ self.Pos.x + self.Size[0], self.Pos.y + i * line_size) qualifier_size = dc.GetTextExtent(action.qualifier) if action.duration != "": - qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, - self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1]) + qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) // 2, + self.Pos.y + i * line_size + line_size // 2 - qualifier_size[1]) duration_size = dc.GetTextExtent(action.duration) - duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2, - self.Pos.y + i * line_size + line_size / 2) + duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) // 2, + self.Pos.y + i * line_size + line_size // 2) dc.DrawText(action.duration, duration_pos[0], duration_pos[1]) else: - qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, - self.Pos.y + i * line_size + (line_size - qualifier_size[1]) / 2) + qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) // 2, + self.Pos.y + i * line_size + (line_size - qualifier_size[1]) // 2) dc.DrawText(action.qualifier, qualifier_pos[0], qualifier_pos[1]) content_size = dc.GetTextExtent(action.value) - content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2, - self.Pos.y + i * line_size + (line_size - content_size[1]) / 2) + content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) // 2, + self.Pos.y + i * line_size + (line_size - content_size[1]) // 2) dc.DrawText(action.value, content_pos[0], content_pos[1]) if action.indicator != "": indicator_size = dc.GetTextExtent(action.indicator) - indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2, - self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2) + indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) // 2, + self.Pos.y + i * line_size + (line_size - indicator_size[1]) // 2) dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1]) if not getattr(dc, "printing", False): diff -r 82bfc75bcd9d -r 105c20fdeb19 modbus/mb_utils.py --- a/modbus/mb_utils.py Fri Oct 05 13:48:54 2018 +0300 +++ b/modbus/mb_utils.py Fri Oct 05 14:22:01 2018 +0300 @@ -23,6 +23,7 @@ # used in safety-critical situations without a full and competent review. from __future__ import absolute_import +from __future__ import division from six.moves import xrange # dictionary implementing: @@ -187,7 +188,7 @@ {%(buffer)s}, {%(buffer)s}}''' timeout = int(GetCTVal(child, 4)) - timeout_s = int(timeout / 1000) + timeout_s = timeout // 1000 timeout_ms = timeout - (timeout_s * 1000) timeout_ns = timeout_ms * 1000000 diff -r 82bfc75bcd9d -r 105c20fdeb19 plcopen/plcopen.py --- a/plcopen/plcopen.py Fri Oct 05 13:48:54 2018 +0300 +++ b/plcopen/plcopen.py Fri Oct 05 14:22:01 2018 +0300 @@ -25,6 +25,7 @@ from __future__ import absolute_import +from __future__ import division from types import * import re from collections import OrderedDict @@ -262,9 +263,9 @@ text += "%ds" % time_values[2] if time_values[3] != 0: if time_values[3] % 1000 != 0: - text += "%.3fms" % (float(time_values[3]) / 1000) + text += "%.3fms" % (time_values[3] / 1000) else: - text += "%dms" % (time_values[3] / 1000) + text += "%dms" % (time_values[3] // 1000) task.set("interval", text) # Update resources pou instance attributes diff -r 82bfc75bcd9d -r 105c20fdeb19 tests/tools/check_source.sh --- a/tests/tools/check_source.sh Fri Oct 05 13:48:54 2018 +0300 +++ b/tests/tools/check_source.sh Fri Oct 05 14:22:01 2018 +0300 @@ -358,6 +358,7 @@ enable=$enable,W1648 # (bad-python3-import) Module moved in Python 3 enable=$enable,W1613 # (xrange-builtin) xrange built-in referenced enable=$enable,W1612 # (unicode-builtin) unicode built-in referenced + enable=$enable,W1619 #(old-division) division w/o __future__ statement # enable= options= diff -r 82bfc75bcd9d -r 105c20fdeb19 tests/tools/test_CustomIntCtrl.py --- a/tests/tools/test_CustomIntCtrl.py Fri Oct 05 13:48:54 2018 +0300 +++ b/tests/tools/test_CustomIntCtrl.py Fri Oct 05 14:22:01 2018 +0300 @@ -24,6 +24,7 @@ from __future__ import absolute_import +from __future__ import division import unittest import time @@ -66,7 +67,7 @@ def testCorrectValue(self): """Test case if no limiting is necessary""" self.AddControls() - val = (self.max_val + self.min_val) / 2 + val = (self.max_val + self.min_val) // 2 self.int_ctrl.SetValue(val) self.ProcessEvents() @@ -86,7 +87,7 @@ self.int_ctrl.Bind(controls.CustomIntCtrl.EVT_CUSTOM_INT, EventHandler) - val = (self.max_val + self.min_val) / 2 + val = (self.max_val + self.min_val) // 2 self.int_ctrl.SetValue(val) self.ProcessEvents()