objdictgen/nodemanager.py
changeset 268 8a21eb5bdedc
parent 258 8f7725451453
child 299 506f9700b9fb
equal deleted inserted replaced
267:96c688ebcde7 268:8a21eb5bdedc
   245                 node.SetProfileName(profile)
   245                 node.SetProfileName(profile)
   246                 node.SetProfile(Mapping)
   246                 node.SetProfile(Mapping)
   247                 node.SetSpecificMenu(AddMenuEntries)
   247                 node.SetSpecificMenu(AddMenuEntries)
   248                 return None
   248                 return None
   249             except:
   249             except:
   250                 return "Syntax Error\nBad OD Profile file!."
   250                 return "Syntax Error\nBad OD Profile file!"
   251         else:
   251         else:
   252             # Default profile
   252             # Default profile
   253             node.SetProfileName("None")
   253             node.SetProfileName("None")
   254             node.SetProfile({})
   254             node.SetProfile({})
   255             node.SetSpecificMenu([])
   255             node.SetSpecificMenu([])
   257 
   257 
   258     """
   258     """
   259     Open a file and store it in a new buffer
   259     Open a file and store it in a new buffer
   260     """
   260     """
   261     def OpenFileInCurrent(self, filepath):
   261     def OpenFileInCurrent(self, filepath):
   262         # Open and load file
   262         try:
   263         file = open(filepath, "r")
   263             # Open and load file
   264         node = load(file)
   264             file = open(filepath, "r")
   265         file.close()
   265             node = load(file)
   266         self.CurrentNode = node
   266             file.close()
   267         # Add a new buffer and defining current state
   267             self.CurrentNode = node
   268         index = self.AddNodeBuffer(self.CurrentNode.Copy(), True)
   268             # Add a new buffer and defining current state
   269         self.SetCurrentFilePath(filepath)
   269             index = self.AddNodeBuffer(self.CurrentNode.Copy(), True)
   270         return index
   270             self.SetCurrentFilePath(filepath)
       
   271             return index
       
   272         except:
       
   273             return "Unable to load file \"%s\"!"%filepath
   271 
   274 
   272     """
   275     """
   273     Save current node in  a file
   276     Save current node in  a file
   274     """
   277     """
   275     def SaveCurrentInFile(self, filepath = None):
   278     def SaveCurrentInFile(self, filepath = None):