cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 02 Oct 2018 17:18:09 +0300
changeset 2417 316ee9fff395
parent 2416 1ca207782dde
child 2418 5587c490a070
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
editors/Viewer.py
etherlab/CommonEtherCATFunction.py
etherlab/EtherCATManagementEditor.py
tests/tools/check_source.sh
--- a/editors/Viewer.py	Tue Oct 02 16:53:14 2018 +0300
+++ b/editors/Viewer.py	Tue Oct 02 17:18:09 2018 +0300
@@ -3557,7 +3557,7 @@
             self.SearchResults = []
             blocks = []
             for infos, start, end, _text in self.Controler.SearchInPou(self.TagName, search_params, self.Debug):
-                if (infos[0] == self.TagName or self.TagName.split("::")[0] in ['A', 'T']) and infos[1] is not 'name':
+                if (infos[0] == self.TagName or self.TagName.split("::")[0] in ['A', 'T']) and infos[1] != 'name':
                     if infos[1] in ["var_local", "var_input", "var_output", "var_inout"]:
                         self.SearchResults.append((infos[1:], start, end, SEARCH_RESULT_HIGHLIGHT))
                     else:
--- a/etherlab/CommonEtherCATFunction.py	Tue Oct 02 16:53:14 2018 +0300
+++ b/etherlab/CommonEtherCATFunction.py	Tue Oct 02 17:18:09 2018 +0300
@@ -895,7 +895,7 @@
         vendor_spec_strings = []
         for element in device.getType().getcontent():
             data += element
-        if data is not "" and isinstance(data, unicode):
+        if data != "" and isinstance(data, unicode):
             for vendor_spec_string in vendor_spec_strings:
                 if data == vendor_spec_string:
                     self.OrderIdx = vendor_spec_strings.index(data)+1
@@ -962,7 +962,7 @@
                     for device_item in group_etc["devices"]:
                         if device == device_item[1]:
                             data = group_etc["name"]
-        if data is not "" and isinstance(data, unicode):
+        if data != "" and isinstance(data, unicode):
             for vendor_spec_string in vendor_spec_strings:
                 if data == vendor_spec_string:
                     groupnameflag = True
@@ -981,7 +981,7 @@
         for element in device.getName():
             if element.getLcId() == 1 or element.getLcId() == 1033:
                 data = element.getcontent()
-        if data is not "" and isinstance(data, unicode):
+        if data != "" and isinstance(data, unicode):
             for vendor_spec_string in vendor_spec_strings:
                 if data == vendor_spec_string:
                     self.NameIdx = vendor_spec_strings.index(data)+1
@@ -1048,7 +1048,7 @@
         if device.getDc() is not None:
             for element in device.getDc().getOpMode():
                 data = element.getName()
-                if data is not "":
+                if data != "":
                     count += 1
                     self.Strings.append(data)
                     dc_related_elements += "{:0>2x}".format(len(data))
@@ -1066,7 +1066,7 @@
             for input in inputs:
                 if data == input:
                     data = ""
-            if data is not "":
+            if data != "":
                 count += 1
                 self.Strings.append(data)
                 inputs.append(data)
@@ -1080,7 +1080,7 @@
                 for input in inputs:
                     if data == input:
                         data = ""
-                if data is not "":
+                if data != "":
                     count += 1
                     self.Strings.append(data)
                     inputs.append(data)
@@ -1099,7 +1099,7 @@
             for output in outputs:
                 if data == output:
                     data = ""
-            if data is not "":
+            if data != "":
                 count += 1
                 self.Strings.append(data)
                 outputs.append(data)
@@ -1113,7 +1113,7 @@
                 for output in outputs:
                     if data == output:
                         data = ""
-                if data is not "":
+                if data != "":
                     count += 1
                     self.Strings.append(data)
                     outputs.append(data)
@@ -1279,7 +1279,7 @@
                 data += "03"
 
         # construct of EEPROM data
-        if data is not "":
+        if data != "":
             #  category header
             eeprom.append("28")
             eeprom.append("00")
@@ -1328,7 +1328,7 @@
                 data += "00"
             data += number[sm.getcontent()]
 
-        if data is not "":
+        if data != "":
             #  category header
             eeprom.append("29")
             eeprom.append("00")
@@ -1431,7 +1431,7 @@
                     en_fixed = True
                 data += str(int(en_fixed)) + "000"
 
-        if data is not "":
+        if data != "":
             #  category header
             if pdotype == "TxPdo":
                 eeprom.append("32")
@@ -1510,7 +1510,7 @@
                 data += "0000"
                 data += "0000"
 
-        if data is not "":
+        if data != "":
             #  category header
             eeprom.append("3c")
             eeprom.append("00")
--- a/etherlab/EtherCATManagementEditor.py	Tue Oct 02 16:53:14 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py	Tue Oct 02 17:18:09 2018 +0300
@@ -1547,7 +1547,7 @@
                     reg_main_description = description.nodeValue
 
             # Add description for register main table
-            if reg_index is not "" and reg_main_description is not "":
+            if reg_index != "" and reg_main_description != "":
                 self.RegisterDescriptionDict[reg_index] = reg_main_description
 
             if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Details":
@@ -1614,11 +1614,11 @@
                                     reg_sub_value_description = description.nodeValue
 
                             # Add a description of each value to register enum dictionary
-                            if reg_sub_value is not "" and reg_sub_value_description is not "":
+                            if reg_sub_value != "" and reg_sub_value_description != "":
                                 reg_enum_dictionary[reg_sub_value] = reg_sub_value_description
 
         # add a description to register sub table description dictionary
-        if reg_bit_range is not "" and reg_sub_description is not "":
+        if reg_bit_range != "" and reg_sub_description != "":
             self.RegisterSubGridDict[reg_index].append([reg_bit_range,
                                                         reg_sub_description,
                                                         reg_enum_dictionary])
@@ -1707,7 +1707,7 @@
                 self.PageRange[index] = [0, 0]
 
             for reg_row_data in self.RegMonitorData:
-                if reg_row_data[1] is not "":
+                if reg_row_data[1] != "":
                     # data structure for "compact view"
                     reg_compact_data.append(reg_row_data)
                     # count for each register notebooks' row
--- a/tests/tools/check_source.sh	Tue Oct 02 16:53:14 2018 +0300
+++ b/tests/tools/check_source.sh	Tue Oct 02 17:18:09 2018 +0300
@@ -304,6 +304,7 @@
     enable=$enable,W0403          # (relative-import) Relative import 'Y', should be 'X.Y '
     enable=$enable,W0612          # (unused-variable) Unused variable 'X'
     enable=$enable,C0330          # (bad-continuation) Wrong hanging indentation before block
+    enable=$enable,R0123          # (literal-comparison) Comparison to literal
     # enable=
 
     options=