def change_current_dir(self, new_dir):
        """Change directory and rebuild content widgets.

        That is, if given dir exists.
        """
        ### if new_dir is falsy or it isn't even a directory
        ### or doesn't exist, cancel execution of the rest
        ### of the method by returning earlier
        if not new_dir or not new_dir.is_dir():
            return

        ### otherwise, try loading the new directory,
        ### if you have the needed permission

        ## backup current dir in a local variable
        current_dir = self.current_dir

        ## set the new directory as the current one
        self.current_dir = new_dir

        ## try loading the contents of the new directory,
        ## which is now the current one
        try:
            self.load_current_dir_contents()

        ## if you don't have the needed permission, inform
        ## the user and set the previous directory back
        ## as the current one

        except PermissionError as err:

            ## put an error message together explaining
            ## the error

            error_msg = (
                "It seems we don't have permission to access"
                " the directory. The following error was"
                " issued: {}: {}"
            ).format(err.__class__.__name__, str(err))

            ## present the dialog
            create_and_show_dialog(error_msg, level_name='error')

            ## set the previous directory back as the
            ## current one
            self.current_dir = current_dir
Change directory and rebuild content widgets.

        That is, if given dir exists.
        
nodezator/fileman/dirpanel/main.py