Ejemplo n.º 1
0
    def delete(self, index):
        """
        Removes the given form at the index from the project.
        """
        formnode = self.takeRow(index)[0]
        form = formnode.form

        archivefolder = os.path.join(self.project.folder, "_archive")
        formachivefolder = os.path.join(archivefolder, form.name)
        try:
            shutil.move(form.folder, formachivefolder)

            if self.project.oldformconfigstlye:
                configname = "{}.config".format(form.name)
                config = {form.name : form.settings}
                configlocation = os.path.join(archivefolder, configname)
                with open(configlocation, 'w') as f:
                    roam.yaml.dump(data=config, stream=f, default_flow_style=False)

        except Exception as ex:
            logger.exception("Could not remove folder")
            return

        self.project.removeform(form.name)
        self.project.save()
Ejemplo n.º 2
0
 def delete(self, index):
     nodes = self.takeRow(index)
     if not nodes:
         return
     projectnode = nodes[0]
     project = projectnode.project
     try:
         archivefolder = os.path.join(project.basepath, "_archive")
         shutil.move(project.folder, archivefolder)
     except Exception as ex:
         logger.exception("Could not remove form folder")