當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。