window.py 文件源码

python
阅读 76 收藏 0 点赞 0 评论 0

项目:libtmux 作者: tony 项目源码 文件源码
def show_window_options(self, option=None, g=False):
        """Return a dict of options for the window.

        For familiarity with tmux, the option ``option`` param forwards to pick
        a single option, forwarding to :meth:`Window.show_window_option`.

        :param option: optional. show a single option.
        :type option: str
        :param g: Pass ``-g`` flag for global variable
        :type g: bool
        :rtype: :py:obj:`dict`

        """

        tmux_args = tuple()

        if g:
            tmux_args += ('-g',)

        if option:
            return self.show_window_option(option, g=g)
        else:
            tmux_args += ('show-window-options',)
            cmd = self.cmd(
                *tmux_args
            ).stdout

        # The shlex.split function splits the args at spaces, while also
        # retaining quoted sub-strings.
        #   shlex.split('this is "a test"') => ['this', 'is', 'a test']
        cmd = [tuple(shlex.split(item)) for item in cmd]

        window_options = dict(cmd)

        for key, value in window_options.items():
            if value.isdigit():
                window_options[key] = int(value)

        return window_options
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号