Esempio n. 1
0
 def rename(self, new_name):
     parent_dir = os.path.dirname(self.path)
     new_path = os.path.join(parent_dir, new_name)
     if os.path.exists(new_path):
         raise RenameError(_("An item of this name already exists"))
     shutil.move(self.path, new_path)
     self.path = new_path
     super(FileSystemItemNode, self).rename(new_name)
Esempio n. 2
0
 def new_folder(self, insert_pos=None):
     """
     Create a new child folder with a default name.
     """
     name = _("New folder")
     i = 0
     n = name
     while os.path.exists(os.path.join(self.path, n)):
         n = "%s %d" % (name, i)
         i += 1
     name = n
     new_path = os.path.join(self.path, name)
     os.mkdir(new_path)
     if hasattr(self, "folder_class"):
         cls = self.folder_class
     else:
         cls = self.__class__
     self.add_child(cls(new_path, name), insert_pos)