def perform_startup_preparations(
        self,
        filepath,
        after_closing_file=False,
    ):
        """Perform tasks for startup and return loop holder.

        Depending on whether or not the "filepath" argument
        is a valid path to be loaded, we perform specific
        tasks and return a reference to the loop holder to
        be used.

        This loop holder will be either this window manager
        itself or the splash screen. The splash screen is
        only used if there wasn't a valid path to be
        loaded.

        Parameters
        ==========
        filepath (string)
            if empty, it means no file must be loaded;
            otherwise, it is a string representing the
            path for a file to be loaded.
        after_closing_file (bool, defaults to False)
            If the filepath string is empty and this parameter
            is True, triggers different admin tasks and the window
            manager is used as the loop holder. That is, when closing
            a file, only the window manager in 'no_file' mode is shown.

        Future implementation
        =====================

        in the future, the splash screen should be shown
        first, while the window prepares for a new session,
        and only then we will decide whether it will be
        kept on the screen or not.
        """
        ### clean loaded file data, if any
        self.clean_loaded_file_data()

        ### if a filepath is received, try opening it,
        ### taking additional steps depending on the outcome

        if filepath:

            ### try opening the filepath
            try:
                self.open(Path(filepath))

            ### when the operation succeeds, a manager
            ### switch exception is raised to indicate
            ### the window manager should take control
            ### of the app;
            ###
            ### we prevent the exception to bubble up,
            ### though, since there would be no "except"
            ### clause to catch this exception at the
            ### spot where this method is executed;
            ###
            ### instead, we return a reference to this
            ### window manager, which will be used as
            ### the loop holder
            except SwitchLoopException:
                return self

        ### if the filepath was an empty string, or the operation
        ### to load it fails, the execution flow of this method
        ### reaches this spot;

        ## we prepare the window manager for a new session
        ## (this call would not be necessary if we had loaded
        ## a file, because it would have already been called
        ## inside self.open());
        self.prepare_for_new_session()

        ## if we are starting a new session after closing a file,
        ## return this window manager to be used as the loop holder

        if after_closing_file:
            return self

        ## otherwise return a reference to the splash screen,
        ## after calling the drawing operation of this window manager,
        ## so it appears behind the splash screen

        else:

            self.draw()
            return self.splash_screen
Perform tasks for startup and return loop holder.

        Depending on whether or not the "filepath" argument
        is a valid path to be loaded, we perform specific
        tasks and return a reference to the loop holder to
        be used.

        This loop holder will be either this window manager
        itself or the splash screen. The splash screen is
        only used if there wasn't a valid path to be
        loaded.

        Parameters
        ==========
        filepath (string)
            if empty, it means no file must be loaded;
            otherwise, it is a string representing the
            path for a file to be loaded.
        after_closing_file (bool, defaults to False)
            If the filepath string is empty and this parameter
            is True, triggers different admin tasks and the window
            manager is used as the loop holder. That is, when closing
            a file, only the window manager in 'no_file' mode is shown.

        Future implementation
        =====================

        in the future, the splash screen should be shown
        first, while the window prepares for a new session,
        and only then we will decide whether it will be
        kept on the screen or not.
        
nodezator/winman/fileop.py