ConfigTreeNode.py
changeset 1932 65d2dbbf7022
parent 1881 091005ec69c4
child 2003 2076df8743b5
equal deleted inserted replaced
1931:7e6b03251bfe 1932:65d2dbbf7022
   408         suffix = 1
   408         suffix = 1
   409         while res in AllNames:
   409         while res in AllNames:
   410             res = "%s_%d" % (BaseDesiredName, suffix)
   410             res = "%s_%d" % (BaseDesiredName, suffix)
   411             suffix += 1
   411             suffix += 1
   412 
   412 
   413         # Get old path
       
   414         oldname = self.CTNPath()
       
   415         # Check previous confnode existance
   413         # Check previous confnode existance
   416         dontexist = self.BaseParams.getName() == "__unnamed__"
   414         dontexist = self.BaseParams.getName() == "__unnamed__"
       
   415         if not dontexist:
       
   416             # Get old path
       
   417             oldpath = self.CTNPath()
   417         # Set the new name
   418         # Set the new name
   418         self.BaseParams.setName(res)
   419         self.BaseParams.setName(res)
   419         # Rename confnode dir if exist
   420         # Rename confnode dir if exist
   420         if not dontexist:
   421         if not dontexist:
   421             shutil.move(oldname, self.CTNPath())
   422             shutil.move(oldpath, self.CTNPath())
   422         # warn user he has two left hands
   423         # warn user he has two left hands
   423         if DesiredName != res:
   424         if DesiredName != res:
   424             msg = _("A child named \"{a1}\" already exists -> \"{a2}\"\n").format(a1=DesiredName, a2=res)
   425             msg = _("A child named \"{a1}\" already exists -> \"{a2}\"\n").format(a1=DesiredName, a2=res)
   425             self.GetCTRoot().logger.write_warning(msg)
   426             self.GetCTRoot().logger.write_warning(msg)
   426         return res
   427         return res