当前位置: 首页>>代码示例>>Python>>正文


Python Formatter.get_width方法代码示例

本文整理汇总了Python中Formatter.get_width方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.get_width方法的具体用法?Python Formatter.get_width怎么用?Python Formatter.get_width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Formatter的用法示例。


在下文中一共展示了Formatter.get_width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: man

# 需要导入模块: import Formatter [as 别名]
# 或者: from Formatter import get_width [as 别名]
    def man(self, pattern):
        """Call viewer.sh to view man page"""
        try:
            os.makedirs(Environ.man_dir)
        except:
            pass

        avail = os.listdir(Environ.man_dir)

        if not os.path.exists(Environ.index_db):
            raise RuntimeError("can't find index.db")

        conn = sqlite3.connect(Environ.index_db)
        cursor = conn.cursor()

        # Try direct match
        try:
            page_name, url = cursor.execute(
                "SELECT name,url FROM CPPMAN WHERE" ' name="%s" ORDER BY LENGTH(name)' % pattern
            ).fetchone()
        except TypeError:
            # Try standard library
            try:
                page_name, url = cursor.execute(
                    "SELECT name,url FROM CPPMAN" ' WHERE name="std::%s" ORDER BY LENGTH(name)' % pattern
                ).fetchone()
            except TypeError:
                try:
                    page_name, url = cursor.execute(
                        "SELECT name,url FROM " 'CPPMAN WHERE name LIKE "%%%s%%" ORDER BY LENGTH(name)' % pattern
                    ).fetchone()
                except TypeError:
                    raise RuntimeError("No manual entry for " + pattern)
        finally:
            conn.close()

        page_name = page_name.replace("/", "_")
        if page_name + ".3.gz" not in avail or self.forced:
            self.cache_man_page(url, page_name)
            self.update_mandb()

        pager = Environ.pager if sys.stdout.isatty() else Environ.renderer

        # Call viewer
        pid = os.fork()
        if pid == 0:
            os.execl(
                "/bin/sh",
                "/bin/sh",
                pager,
                Environ.man_dir + page_name + ".3.gz",
                str(Formatter.get_width()),
                Environ.pager_config,
                page_name,
            )
        return pid
开发者ID:Mondego,项目名称:pyreco,代码行数:58,代码来源:allPythonContent.py

示例2: man

# 需要导入模块: import Formatter [as 别名]
# 或者: from Formatter import get_width [as 别名]
    def man(self, pattern):
        """Call viewer.sh to view man page"""
        try:
            os.makedirs(Environ.man_dir)
        except: pass

        avail = os.listdir(Environ.man_dir)

        if not os.path.exists(Environ.index_db):
            raise RuntimeError("can't find index.db")

        conn = sqlite3.connect(Environ.index_db)
        cursor = conn.cursor()

        # Try direct match
        try:
            page_name, url = cursor.execute('SELECT name,url FROM CPPMAN WHERE'
                    ' name="%s" ORDER BY LENGTH(name)' % pattern).fetchone()
        except TypeError:
            # Try standard library
            try:
                page_name, url = cursor.execute('SELECT name,url FROM CPPMAN'
                        ' WHERE name="std::%s" ORDER BY LENGTH(name)'
                        % pattern).fetchone()
            except TypeError:
                try:
                    page_name, url = cursor.execute('SELECT name,url FROM '
                        'CPPMAN WHERE name LIKE "%%%s%%" ORDER BY LENGTH(name)'
                        % pattern).fetchone()
                except TypeError:
                    raise RuntimeError('No manual entry for ' + pattern)

        finally:
            conn.close()

        page_name = page_name.replace('/', '_')
        #if page_name + '.3.gz' not in avail or self.forced:
            #self.cache_man_page(url, page_name)
            #self.update_mandb()

        pager = Environ.pager if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() else Environ.renderer

        # Call viewer
        #pid = os.fork()
        #if pid == 0:
            #out = os.execl('/bin/sh', '/bin/sh', pager,
                           #page_name + '.3.gz',
                           #str(Formatter.get_width()), Environ.pager_config,
                           #page_name)
        p = subprocess.Popen([pager, page_name + '.3.gz', str(Formatter.get_width()), Environ.pager_config, page_name], stdout=subprocess.PIPE)
        return {'page':page_name, 'out':p.stdout.read()}
开发者ID:zhenbinwu,项目名称:benwu,代码行数:53,代码来源:cppman.py


注:本文中的Formatter.get_width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。