Пример #1
0
    def __init__(self, debug=(), log_setting=None):
        self.__version__ = __version__

        # Intercept IO
        enable_io_wrapper()

        self.config = self._load_config()
        self.logger = self._config_logging(log_setting)

        # Tab handler for running scripts
        self.external_tab_handler = None

        # Wire the components
        self.main_screen = ShSequentialScreen(self,
                                              nlines_max=self.config.getint(
                                                  'display', 'BUFFER_MAX'),
                                              debug=_DEBUG_MAIN_SCREEN
                                              in debug)

        self.mini_buffer = ShMiniBuffer(self,
                                        self.main_screen,
                                        debug=_DEBUG_MINI_BUFFER in debug)

        self.stream = ShStream(self,
                               self.main_screen,
                               debug=_DEBUG_STREAM in debug)

        self.io = ShIO(self, debug=_DEBUG_IO in debug)

        self.terminal = None  # will be set during UI initialisation
        self.ui = ShUI(self, debug=_DEBUG_UI in debug)
        self.renderer = ShSequentialRenderer(self.main_screen,
                                             self.terminal,
                                             debug=_DEBUG_RENDERER in debug)

        parser = ShParser(debug=_DEBUG_PARSER in debug)
        expander = ShExpander(self, debug=_DEBUG_EXPANDER in debug)
        self.runtime = ShRuntime(self,
                                 parser,
                                 expander,
                                 debug=_DEBUG_RUNTIME in debug)
        self.completer = ShCompleter(self, debug=_DEBUG_COMPLETER in debug)

        # Navigate to the startup folder
        if IN_PYTHONISTA:
            os.chdir(self.runtime.state.environ_get('HOME2'))
        self.runtime.load_rcfile()
        self.io.write(
            self.text_style('StaSh v%s\n' % self.__version__, {
                'color': 'blue',
                'traits': ['bold']
            }))
        self.runtime.script_will_end()  # configure the read callback

        # Load shared libraries
        self._load_lib()
Пример #2
0
    def __init__(self,
                 debug=(),
                 log_setting=None,
                 no_cfgfile=False,
                 no_rcfile=False,
                 no_historyfile=False):
        self.__version__ = __version__

        # Intercept IO
        enable_io_wrapper()

        self.config = self._load_config(no_cfgfile=no_cfgfile)
        self.logger = self._config_logging(log_setting)

        self.user_action_proxy = ShUserActionProxy(self)

        # Tab handler for running scripts
        self.external_tab_handler = None

        # Wire the components
        self.main_screen = ShSequentialScreen(self,
                                              nlines_max=self.config.getint(
                                                  'display', 'BUFFER_MAX'),
                                              debug=_DEBUG_MAIN_SCREEN
                                              in debug)

        self.mini_buffer = ShMiniBuffer(self,
                                        self.main_screen,
                                        debug=_DEBUG_MINI_BUFFER in debug)

        self.stream = ShStream(self,
                               self.main_screen,
                               debug=_DEBUG_STREAM in debug)

        self.io = ShIO(self, debug=_DEBUG_IO in debug)

        self.terminal = None  # will be set during UI initialisation
        self.ui = ShUI(self, debug=_DEBUG_UI in debug)
        self.renderer = ShSequentialRenderer(self.main_screen,
                                             self.terminal,
                                             debug=_DEBUG_RENDERER in debug)

        parser = ShParser(debug=_DEBUG_PARSER in debug)
        expander = ShExpander(self, debug=_DEBUG_EXPANDER in debug)
        self.runtime = ShRuntime(self,
                                 parser,
                                 expander,
                                 no_historyfile=no_historyfile,
                                 debug=_DEBUG_RUNTIME in debug)
        self.completer = ShCompleter(self, debug=_DEBUG_COMPLETER in debug)

        # Navigate to the startup folder
        if IN_PYTHONISTA:
            os.chdir(self.runtime.state.environ_get('HOME2'))
        self.runtime.load_rcfile(no_rcfile=no_rcfile)
        self.io.write(
            self.text_style('StaSh v%s\n' % self.__version__, {
                'color': 'blue',
                'traits': ['bold']
            },
                            always=True))
        # Load shared libraries
        self._load_lib()

        # Show tip of the day (this calls script_will_end)
        self('$STASH_ROOT/bin/totd.py',
             add_to_history=False,
             persistent_level=0)