# HG changeset patch # User Andrey Skvortsov # Date 1502959150 -10800 # Node ID fcc406143e5b48c30c63cb227894b0e2935cf54e # Parent 8c98bad90b8d95825b229b238303de2017550839 clean-up: fix PEP8 E731 do not assign a lambda expression, use a def diff -r 8c98bad90b8d -r fcc406143e5b BeremizIDE.py --- a/BeremizIDE.py Thu Aug 17 10:12:04 2017 +0300 +++ b/BeremizIDE.py Thu Aug 17 11:39:10 2017 +0300 @@ -287,9 +287,12 @@ self._RecursiveAddMenuItems(parent, GetAddMenuItems()) def _init_coll_HelpMenu_Items(self, parent): - handler = lambda event: { - wx.MessageBox(version.GetCommunityHelpMsg(), _(u'Community support'), wx.OK | wx.ICON_INFORMATION) - } + def handler(event): + return wx.MessageBox( + version.GetCommunityHelpMsg(), + _(u'Community support'), + wx.OK | wx.ICON_INFORMATION) + id = wx.NewId() parent.Append(help='', id=id, kind=wx.ITEM_NORMAL, text=_(u'Community support')) self.Bind(wx.EVT_MENU, handler, id=id) diff -r 8c98bad90b8d -r fcc406143e5b IDEFrame.py --- a/IDEFrame.py Thu Aug 17 10:12:04 2017 +0300 +++ b/IDEFrame.py Thu Aug 17 11:39:10 2017 +0300 @@ -2557,7 +2557,8 @@ #------------------------------------------------------------------------------- -UPPER_DIV = lambda x, y: (x / y) + {True: 0, False: 1}[(x % y) == 0] +def UPPER_DIV(x, y): + return (x / y) + {True: 0, False: 1}[(x % y) == 0] class GraphicPrintout(wx.Printout): diff -r 8c98bad90b8d -r fcc406143e5b PLCControler.py --- a/PLCControler.py Thu Aug 17 10:12:04 2017 +0300 +++ b/PLCControler.py Thu Aug 17 11:39:10 2017 +0300 @@ -34,7 +34,7 @@ import util.paths as paths from time import localtime from collections import OrderedDict, namedtuple - +from util.TranslationCatalogs import NoTranslate from plcopen import * from graphics.GraphicCommons import * from PLCGenerator import * @@ -96,7 +96,7 @@ def GetUneditableNames(): - _ = lambda x: x + _ = NoTranslate return [_("User-defined POUs"), _("Functions"), _("Function Blocks"), _("Programs"), _("Data Types"), _("Transitions"), _("Actions"), _("Configurations"), _("Resources"), _("Properties")] @@ -138,8 +138,12 @@ #------------------------------------------------------------------------------- -_StringValue = lambda x: x -_BoolValue = lambda x: x in ["true", "0"] +def _StringValue(x): + return x + + +def _BoolValue(x): + return x in ["true", "0"] def _translate_args(translations, args): diff -r 8c98bad90b8d -r fcc406143e5b PLCOpenEditor.py --- a/PLCOpenEditor.py Thu Aug 17 10:12:04 2017 +0300 +++ b/PLCOpenEditor.py Thu Aug 17 11:39:10 2017 +0300 @@ -162,9 +162,12 @@ #AppendMenu(parent, help='', id=wx.ID_HELP_CONTEXT, # kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3') - handler = lambda event: { - wx.MessageBox(version.GetCommunityHelpMsg(), _(u'Community support'), wx.OK | wx.ICON_INFORMATION) - } + def handler(event): + return wx.MessageBox( + version.GetCommunityHelpMsg(), + _(u'Community support'), + wx.OK | wx.ICON_INFORMATION) + id = wx.NewId() parent.Append(help='', id=id, kind=wx.ITEM_NORMAL, text=_(u'Community support')) self.Bind(wx.EVT_MENU, handler, id=id) diff -r 8c98bad90b8d -r fcc406143e5b controls/VariablePanel.py --- a/controls/VariablePanel.py Thu Aug 17 10:12:04 2017 +0300 +++ b/controls/VariablePanel.py Thu Aug 17 11:39:10 2017 +0300 @@ -38,7 +38,7 @@ from LocationCellEditor import LocationCellEditor from util.BitmapLibrary import GetBitmap from PLCControler import _VariableInfos - +from util.TranslationCatalogs import NoTranslate #------------------------------------------------------------------------------- # Helpers #------------------------------------------------------------------------------- @@ -49,14 +49,14 @@ def GetVariableTableColnames(location): - _ = lambda x: x + _ = NoTranslate if location: return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Option"), _("Documentation")] return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Option"), _("Documentation")] def GetOptions(constant=True, retain=True, non_retain=True): - _ = lambda x: x + _ = NoTranslate options = [""] if constant: options.append(_("Constant")) @@ -71,7 +71,7 @@ def GetFilterChoiceTransfer(): - _ = lambda x: x + _ = NoTranslate return {_("All"): _("All"), _("Interface"): _("Interface"), _(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"), _(" External"): _("External"), _("Variables"): _("Variables"), _(" Local"): _("Local"), diff -r 8c98bad90b8d -r fcc406143e5b dialogs/ActionBlockDialog.py --- a/dialogs/ActionBlockDialog.py Thu Aug 17 10:12:04 2017 +0300 +++ b/dialogs/ActionBlockDialog.py Thu Aug 17 11:39:10 2017 +0300 @@ -29,19 +29,19 @@ from controls import CustomGrid, CustomTable from util.BitmapLibrary import GetBitmap from PLCControler import _ActionInfos - +from util.TranslationCatalogs import NoTranslate #------------------------------------------------------------------------------- # Helpers #------------------------------------------------------------------------------- def GetActionTableColnames(): - _ = lambda x: x + _ = NoTranslate return [_("Qualifier"), _("Duration"), _("Type"), _("Value"), _("Indicator")] def GetTypeList(): - _ = lambda x: x + _ = NoTranslate return [_("Action"), _("Variable"), _("Inline")] #------------------------------------------------------------------------------- diff -r 8c98bad90b8d -r fcc406143e5b dialogs/BrowseLocationsDialog.py --- a/dialogs/BrowseLocationsDialog.py Thu Aug 17 10:12:04 2017 +0300 +++ b/dialogs/BrowseLocationsDialog.py Thu Aug 17 11:39:10 2017 +0300 @@ -30,6 +30,7 @@ from plcopen.structures import LOCATIONDATATYPES from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY from util.BitmapLibrary import GetBitmap +from util.TranslationCatalogs import NoTranslate #------------------------------------------------------------------------------- # Helpers @@ -37,7 +38,7 @@ def GetDirFilterChoiceOptions(): - _ = lambda x: x + _ = NoTranslate return [(_("All"), [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]), (_("Input"), [LOCATION_VAR_INPUT]), (_("Output"), [LOCATION_VAR_OUTPUT]), @@ -48,7 +49,7 @@ def GetTypeFilterChoiceOptions(): - _ = lambda x: x + _ = NoTranslate return [_("All"), _("Type and derivated"), _("Type strict")] diff -r 8c98bad90b8d -r fcc406143e5b dialogs/DiscoveryDialog.py --- a/dialogs/DiscoveryDialog.py Thu Aug 17 10:12:04 2017 +0300 +++ b/dialogs/DiscoveryDialog.py Thu Aug 17 11:39:10 2017 +0300 @@ -159,9 +159,11 @@ event.Skip() def OnIpButton(self, event): + def GetColText(col): + return self.getColumnText(self.LatestSelection, col) + if self.LatestSelection is not None: - addr = lambda col: self.getColumnText(self.LatestSelection, col) - self.URI = "%s://%s:%s" % tuple(map(addr, (1, 2, 3))) + self.URI = "%s://%s:%s" % tuple(map(GetColText, (1, 2, 3))) self.EndModal(wx.ID_OK) event.Skip() diff -r 8c98bad90b8d -r fcc406143e5b dialogs/PouActionDialog.py --- a/dialogs/PouActionDialog.py Thu Aug 17 10:12:04 2017 +0300 +++ b/dialogs/PouActionDialog.py Thu Aug 17 11:39:10 2017 +0300 @@ -26,10 +26,11 @@ import wx from plcopen.structures import TestIdentifier, IEC_KEYWORDS +from util.TranslationCatalogs import NoTranslate def GetActionLanguages(): - _ = lambda x: x + _ = NoTranslate return [_("IL"), _("ST"), _("LD"), _("FBD")] diff -r 8c98bad90b8d -r fcc406143e5b dialogs/PouDialog.py --- a/dialogs/PouDialog.py Thu Aug 17 10:12:04 2017 +0300 +++ b/dialogs/PouDialog.py Thu Aug 17 11:39:10 2017 +0300 @@ -26,10 +26,11 @@ import wx from plcopen.structures import TestIdentifier, IEC_KEYWORDS +from util.TranslationCatalogs import NoTranslate def GetPouTypes(): - _ = lambda x: x + _ = NoTranslate return [_("function"), _("functionBlock"), _("program")] @@ -37,7 +38,7 @@ def GetPouLanguages(): - _ = lambda x: x + _ = NoTranslate return [_("IL"), _("ST"), _("LD"), _("FBD"), _("SFC")] diff -r 8c98bad90b8d -r fcc406143e5b dialogs/PouTransitionDialog.py --- a/dialogs/PouTransitionDialog.py Thu Aug 17 10:12:04 2017 +0300 +++ b/dialogs/PouTransitionDialog.py Thu Aug 17 11:39:10 2017 +0300 @@ -26,6 +26,7 @@ import wx from plcopen.structures import TestIdentifier, IEC_KEYWORDS +from util.TranslationCatalogs import NoTranslate #------------------------------------------------------------------------------- # POU Transition Dialog @@ -33,7 +34,7 @@ def GetTransitionLanguages(): - _ = lambda x: x + _ = NoTranslate return [_("IL"), _("ST"), _("LD"), _("FBD")] diff -r 8c98bad90b8d -r fcc406143e5b dialogs/SearchInProjectDialog.py --- a/dialogs/SearchInProjectDialog.py Thu Aug 17 10:12:04 2017 +0300 +++ b/dialogs/SearchInProjectDialog.py Thu Aug 17 11:39:10 2017 +0300 @@ -24,8 +24,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import re +import wx from plcopen.plcopen import * -import wx +from util.TranslationCatalogs import NoTranslate #------------------------------------------------------------------------------- # Search In Project Dialog @@ -33,7 +34,7 @@ def GetElementsChoices(): - _ = lambda x: x + _ = NoTranslate return [("datatype", _("Data Type")), ("function", _("Function")), ("functionBlock", _("Function Block")), diff -r 8c98bad90b8d -r fcc406143e5b editors/CodeFileEditor.py --- a/editors/CodeFileEditor.py Thu Aug 17 10:12:04 2017 +0300 +++ b/editors/CodeFileEditor.py Thu Aug 17 11:39:10 2017 +0300 @@ -37,6 +37,7 @@ from controls.CustomStyledTextCtrl import CustomStyledTextCtrl, faces, GetCursorPos, NAVIGATION_KEYS from controls.VariablePanel import VARIABLE_NAME_SUFFIX_MODEL from graphics.GraphicCommons import ERROR_HIGHLIGHT, SEARCH_RESULT_HIGHLIGHT, REFRESH_HIGHLIGHT_PERIOD +from util.TranslationCatalogs import NoTranslate [STC_CODE_ERROR, STC_CODE_SEARCH_RESULT, STC_CODE_SECTION] = range(15, 18) @@ -740,7 +741,7 @@ self.Table.ResetView(self.VariablesGrid) def GetVariableTableColnames(self): - _ = lambda x: x + _ = NoTranslate return ["#", _("Name"), _("Type"), _("Initial"), _("Description"), _("OnChange"), _("Options")] def RefreshModel(self): diff -r 8c98bad90b8d -r fcc406143e5b editors/DataTypeEditor.py --- a/editors/DataTypeEditor.py Thu Aug 17 10:12:04 2017 +0300 +++ b/editors/DataTypeEditor.py Thu Aug 17 11:39:10 2017 +0300 @@ -35,6 +35,7 @@ from dialogs import ArrayTypeDialog from EditorPanel import EditorPanel from util.BitmapLibrary import GetBitmap +from util.TranslationCatalogs import NoTranslate #------------------------------------------------------------------------------- # Helpers @@ -48,12 +49,12 @@ def GetElementsTableColnames(): - _ = lambda x: x + _ = NoTranslate return ["#", _("Name"), _("Type"), _("Initial Value")] def GetDatatypeTypes(): - _ = lambda x: x + _ = NoTranslate return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")] diff -r 8c98bad90b8d -r fcc406143e5b editors/ResourceEditor.py --- a/editors/ResourceEditor.py Thu Aug 17 10:12:04 2017 +0300 +++ b/editors/ResourceEditor.py Thu Aug 17 11:39:10 2017 +0300 @@ -32,6 +32,7 @@ from EditorPanel import EditorPanel from util.BitmapLibrary import GetBitmap from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS, DefaultType +from util.TranslationCatalogs import NoTranslate #------------------------------------------------------------------------------- # Configuration Editor class #------------------------------------------------------------------------------- @@ -65,18 +66,20 @@ #------------------------------------------------------------------------------- def GetTasksTableColnames(): - _ = lambda x: x + _ = NoTranslate return [_("Name"), _("Triggering"), _("Single"), _("Interval"), _("Priority")] def GetTaskTriggeringOptions(): - _ = lambda x: x + _ = NoTranslate return [_("Interrupt"), _("Cyclic")] TASKTRIGGERINGOPTIONS_DICT = dict([(_(option), option) for option in GetTaskTriggeringOptions()]) -SingleCellEditor = lambda *x: wx.grid.GridCellChoiceEditor() + +def SingleCellEditor(*x): + return wx.grid.GridCellChoiceEditor() def CheckSingle(single, varlist): @@ -84,7 +87,7 @@ def GetInstancesTableColnames(): - _ = lambda x: x + _ = NoTranslate return [_("Name"), _("Type"), _("Task")] diff -r 8c98bad90b8d -r fcc406143e5b editors/Viewer.py --- a/editors/Viewer.py Thu Aug 17 10:12:04 2017 +0300 +++ b/editors/Viewer.py Thu Aug 17 11:39:10 2017 +0300 @@ -117,8 +117,13 @@ return powerRailCreationFunction -NEGATED_VALUE = lambda x: x if x is not None else False -MODIFIER_VALUE = lambda x: x if x is not None else 'none' +def NEGATED_VALUE(x): + return x if x is not None else False + + +def MODIFIER_VALUE(x): + return x if x is not None else 'none' + CONTACT_TYPES = {(True, "none"): CONTACT_REVERSE, (False, "rising"): CONTACT_RISING, diff -r 8c98bad90b8d -r fcc406143e5b plcopen/definitions.py --- a/plcopen/definitions.py Thu Aug 17 10:12:04 2017 +0300 +++ b/plcopen/definitions.py Thu Aug 17 11:39:10 2017 +0300 @@ -26,12 +26,13 @@ from os.path import join, split, realpath import util.paths as paths +from util.TranslationCatalogs import NoTranslate sd = paths.AbsDir(__file__) # Override gettext _ in this module # since we just want string to be added to dictionnary # but translation should happen here -_ = lambda x: x +_ = NoTranslate LANGUAGES = ["IL", "ST", "FBD", "LD", "SFC"] diff -r 8c98bad90b8d -r fcc406143e5b plcopen/plcopen.py --- a/plcopen/plcopen.py Thu Aug 17 10:12:04 2017 +0300 +++ b/plcopen/plcopen.py Thu Aug 17 11:39:10 2017 +0300 @@ -154,7 +154,11 @@ PLCOpenParser = GenerateParserFromXSD(paths.AbsNeighbourFile(__file__, "tc6_xml_v201.xsd")) -PLCOpen_XPath = lambda xpath: etree.XPath(xpath, namespaces=PLCOpenParser.NSMAP) + + +def PLCOpen_XPath(xpath): + return etree.XPath(xpath, namespaces=PLCOpenParser.NSMAP) + LOAD_POU_PROJECT_TEMPLATE = """