]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
Some instance type test improved
authorlbessard <lbessard>
Thu, 28 Aug 2008 12:24:10 +0000 (12:24 +0000)
committerlbessard <lbessard>
Thu, 28 Aug 2008 12:24:10 +0000 (12:24 +0000)
objdictgen/gen_cfile.py
objdictgen/networkedit.py
objdictgen/nodemanager.py
objdictgen/objdictedit.py
objdictgen/objdictgen.py

index c821783da58381dc50d59181785f673c8bb7b128..48ef711208aaf0a22d133c9b3eb04f5dd3bff8a8 100644 (file)
@@ -183,7 +183,7 @@ def GenerateFileContent(Node, headerfilepath, pointers_dict = {}):
             strIndex += "\n/* index 0x%(index)04X :   %(EntryName)s. */\n"%texts
         
         # Entry type is VAR
-        if type(values) != ListType:
+        if isinstance(values, ListType):
             subentry_infos = Node.GetSubentryInfos(index, 0)
             typename = Node.GetTypeName(subentry_infos["type"])
             typeinfos = GetValidTypeInfos(typename, [values])
index 51ae601bc977e530ce05675c515db98a6122a32d..fccfc27a27d4b73006d13be53a23de40b9df022a 100644 (file)
@@ -27,7 +27,7 @@ import wx.grid
 from types import *
 import os, re, platform, sys, time, traceback, getopt
 
-__version__ = "$Revision: 1.24 $"
+__version__ = "$Revision: 1.25 $"
 
 from nodelist import *
 from nodemanager import *
@@ -705,13 +705,13 @@ class networkedit(wx.Frame):
                 find_index = True
                 index, subIndex = result
                 result = OpenPDFDocIndex(index, ScriptDirectory)
-                if type(result) == StringType:
+                if isinstance(result, (StringType, UnicodeType)):
                     message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
                     message.ShowModal()
                     message.Destroy()
         if not find_index:
             result = OpenPDFDocIndex(None, ScriptDirectory)
-            if type(result) == StringType:
+            if isinstance(result, (StringType, UnicodeType)):
                 message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
                 message.Destroy()
@@ -817,7 +817,7 @@ class networkedit(wx.Frame):
             if dialog.ShowModal() == wx.ID_OK:
                 index, name, struct, number = dialog.GetValues()
                 result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
-                if type(result) != StringType:
+                if not isinstance(result, (StringType, UnicodeType)):
                     self.RefreshBufferState()
                     self.RefreshCurrentIndexList()
                 else:
index 2b29882c08448a14cced9b95286afe4ab54a1901..e48c145f1a860f3350f3e5f6cf72534d7691134e 100755 (executable)
@@ -1027,7 +1027,7 @@ class NodeManager:
             editors = []
             values = node.GetEntry(index, compute = False)
             params = node.GetParamsEntry(index)
-            if type(values) == ListType:
+            if isinstance(values, ListType):
                 for i, value in enumerate(values):
                     data.append({"value" : value})
                     data[-1].update(params[i])      
@@ -1042,7 +1042,7 @@ class NodeManager:
                 dic["access"] = AccessType[infos["access"]]
                 dic["save"] = OptionType[dic["save"]]
                 editor = {"subindex" : None, "save" : "option", "callback" : "option", "comment" : "string"}
-                if type(values) == ListType and i == 0:
+                if isinstance(values, ListType) and i == 0:
                     editor["name"] = None
                     editor["type"] = None
                     if 0x1600 <= index <= 0x17FF or 0x1A00 <= index <= 0x1C00:
index f0e3b9e75a882320d4e88f30f718a391cdd0ae79..60cded33710b3c86a859507d26ca479fe732df8a 100755 (executable)
@@ -26,7 +26,7 @@ import wx
 from types import *
 import os, re, platform, sys, time, traceback, getopt
 
-__version__ = "$Revision: 1.44 $"
+__version__ = "$Revision: 1.45 $"
 
 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
 
@@ -298,7 +298,7 @@ class objdictedit(wx.Frame):
             self.Manager = NodeManager()
             for filepath in filesOpen:
                 result = self.Manager.OpenFileInCurrent(filepath)
-                if type(result) == IntType:
+                if isinstance(result, (IntType, LongType)):
                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
                     new_editingpanel.SetIndex(result)
                     self.FileOpened.AddPage(new_editingpanel, "")
@@ -389,13 +389,13 @@ class objdictedit(wx.Frame):
                 find_index = True
                 index, subIndex = result
                 result = OpenPDFDocIndex(index, ScriptDirectory)
-                if type(result) == StringType:
+                if isinstance(result, (StringType, UnicodeType)):
                     message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
                     message.ShowModal()
                     message.Destroy()
         if not find_index:
             result = OpenPDFDocIndex(None, ScriptDirectory)
-            if type(result) == StringType:
+            if isinstance(result, (StringType, UnicodeType)):
                 message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
                 message.Destroy()
@@ -598,7 +598,7 @@ class objdictedit(wx.Frame):
             NMT = dialog.GetNMTManagement()
             options = dialog.GetOptions()
             result = self.Manager.CreateNewNode(name, id, nodetype, description, profile, filepath, NMT, options)
-            if type(result) == IntType:
+            if isinstance(result, (IntType, LongType)):
                 new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
                 new_editingpanel.SetIndex(result)
                 self.FileOpened.AddPage(new_editingpanel, "")
@@ -627,7 +627,7 @@ class objdictedit(wx.Frame):
             filepath = dialog.GetPath()
             if os.path.isfile(filepath):
                 result = self.Manager.OpenFileInCurrent(filepath)
-                if type(result) == IntType:
+                if isinstance(result, (IntType, LongType)):
                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
                     new_editingpanel.SetIndex(result)
                     self.FileOpened.AddPage(new_editingpanel, "")
@@ -663,7 +663,7 @@ class objdictedit(wx.Frame):
         result = self.Manager.SaveCurrentInFile()
         if not result:
             self.SaveAs()
-        elif type(result) != StringType:
+        elif not isinstance(result, (StringType, UnicodeType)):
             self.RefreshBufferState()
         else:
             message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
@@ -681,7 +681,7 @@ class objdictedit(wx.Frame):
             filepath = dialog.GetPath()
             if os.path.isdir(os.path.dirname(filepath)):
                 result = self.Manager.SaveCurrentInFile(filepath)
-                if type(result) != StringType:
+                if not isinstance(result, (StringType, UnicodeType)):
                     self.RefreshBufferState()
                 else:
                     message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
@@ -726,7 +726,7 @@ class objdictedit(wx.Frame):
             filepath = dialog.GetPath()
             if os.path.isfile(filepath):
                 result = self.Manager.ImportCurrentFromEDSFile(filepath)
-                if type(result) == IntType:
+                if isinstance(result, (IntType, LongType)):
                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
                     new_editingpanel.SetIndex(result)
                     self.FileOpened.AddPage(new_editingpanel, "")
@@ -881,7 +881,7 @@ class objdictedit(wx.Frame):
             if dialog.ShowModal() == wx.ID_OK:
                 index, name, struct, number = dialog.GetValues()
                 result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
-                if type(result) != StringType:
+                if not isinstance(result, (StringType, UnicodeType)):
                     self.RefreshBufferState()
                     self.RefreshCurrentIndexList()
                 else:
index 7b7afbe23b0a6f2e3ec5b0d9a645e9b4a9bdecde..84ac9ab900b25c075d3831877ee651663a72f228 100644 (file)
@@ -57,7 +57,7 @@ if __name__ == '__main__':
         if os.path.isfile(fileIn):
             print "Parsing input file"
             result = manager.OpenFileInCurrent(fileIn)
-            if type(result) != UnicodeType:
+            if not isinstance(result, (StringType, UnicodeType)):
                 Node = result
             else:
                 print result
@@ -67,7 +67,7 @@ if __name__ == '__main__':
             sys.exit(-1)
         print "Writing output file"
         result = manager.ExportCurrentToCFile(fileOut)
-        if type(result) == UnicodeType:
+        if isinstance(result, (UnicodeType, StringType)):
             print result
             sys.exit(-1)
         print "All done"