weldx_widgets/kisa/save.py
def on_save(self, _):
        """Handle saving data to file."""
        from IPython.display import clear_output, display

        clear_output()

        result = dict()
        for widget in self.collect_data_from:
            _deep_update_inplace(result, widget.to_tree())

        # set status
        result["wx_user"] = {"KISA": {"status": self.status}}

        def show_header(handle):
            with self.out:
                clear_output()
                display(handle.show_asdf_header(False, True))

        # open (existing) file and update it.
        if pathlib.Path(self.filename).stem.endswith("_r"):
            with self.out:
                print("Refusing to save a read-only (template) file!")
                print("Please choose another name with the '_r' suffix.")
            return
        if self.filename != self._initial_file:
            # we want to save the previous file under a different name, so load contents
            with weldx.WeldxFile(self._initial_file, mode="r") as fh:
                _deep_update_inplace(fh, result)
                if not pathlib.Path(self.filename).exists():
                    fh.write_to(self.filename)
                    show_header(fh)
                else:
                    with weldx.WeldxFile(self.filename, mode="rw") as fh2:
                        _deep_update_inplace(fh2, fh)
                        show_header(fh2)
        else:
            with weldx.WeldxFile(self.filename, mode="rw", sync=True) as fh:
                _deep_update_inplace(fh, result)
                show_header(fh)
Handle saving data to file.
Handle saving data to file.
Handle saving data to file .
def on_save(self, _):
        from IPython.display import clear_output, display
        clear_output()
        result = dict()
        for widget in self.collect_data_from:
            _deep_update_inplace(result, widget.to_tree())
        result["wx_user"] = {"KISA": {"status": self.status}}
        def show_header(handle):
            with self.out:
                clear_output()
                display(handle.show_asdf_header(False, True))
        if pathlib.Path(self.filename).stem.endswith("_r"):
            with self.out:
                print("Refusing to save a read-only (template) file!")
                print("Please choose another name with the '_r' suffix.")
            return
        if self.filename != self._initial_file:
            with weldx.WeldxFile(self._initial_file, mode="r") as fh:
                _deep_update_inplace(fh, result)
                if not pathlib.Path(self.filename).exists():
                    fh.write_to(self.filename)
                    show_header(fh)
                else:
                    with weldx.WeldxFile(self.filename, mode="rw") as fh2:
                        _deep_update_inplace(fh2, fh)
                        show_header(fh2)
        else:
            with weldx.WeldxFile(self.filename, mode="rw", sync=True) as fh:
                _deep_update_inplace(fh, result)
                show_header(fh)
def on_save ( self , _ ) : from IPython . display import clear_output , display clear_output ( ) result = dict ( ) for widget in self . collect_data_from : _deep_update_inplace ( result , widget . to_tree ( ) ) result [ "wx_user" ] = { "KISA" : { "status" : self . status } } def show_header ( handle ) : with self . out : clear_output ( ) display ( handle . show_asdf_header ( False , True ) ) if pathlib . Path ( self . filename ) . stem . endswith ( "_r" ) : with self . out : print ( "Refusing to save a read-only (template) file!" ) print ( "Please choose another name with the '_r' suffix." ) return if self . filename != self . _initial_file : with weldx . WeldxFile ( self . _initial_file , mode = "r" ) as fh : _deep_update_inplace ( fh , result ) if not pathlib . Path ( self . filename ) . exists ( ) : fh . write_to ( self . filename ) show_header ( fh ) else : with weldx . WeldxFile ( self . filename , mode = "rw" ) as fh2 : _deep_update_inplace ( fh2 , fh ) show_header ( fh2 ) else : with weldx . WeldxFile ( self . filename , mode = "rw" , sync = True ) as fh : _deep_update_inplace ( fh , result ) show_header ( fh )
Handle saving data to file.
Handle saving data to file .
"""Handle saving data to file.""" # set status # open (existing) file and update it. # we want to save the previous file under a different name, so load contents
self
_