()
Decide what method to use for paging through text.
Decide what method to use for paging through text.
Decide what method to use for paging through text .
def getpager():
    """Decide what method to use for paging through text."""
    if not hasattr(sys.stdin, "isatty"):
        return plainpager
    if not hasattr(sys.stdout, "isatty"):
        return plainpager
    if not sys.stdin.isatty() or not sys.stdout.isatty():
        return plainpager
    use_pager = os.environ.get('MANPAGER') or os.environ.get('PAGER')
    if use_pager:
        if sys.platform == 'win32': # pipes completely broken in Windows
            return lambda text: tempfilepager(plain(text), use_pager)
        elif os.environ.get('TERM') in ('dumb', 'emacs'):
            return lambda text: pipepager(plain(text), use_pager)
        else:
            return lambda text: pipepager(text, use_pager)
    if os.environ.get('TERM') in ('dumb', 'emacs'):
        return plainpager
    if sys.platform == 'win32':
        return lambda text: tempfilepager(plain(text), 'more <')
    if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
        return lambda text: pipepager(text, 'less')

    import tempfile
    (fd, filename) = tempfile.mkstemp()
    os.close(fd)
    try:
        if hasattr(os, 'system') and os.system('more "%s"' % filename) == 0:
            return lambda text: pipepager(text, 'more')
        else:
            return ttypager
    finally:
        os.unlink(filename)
def getpager ( ) : if not hasattr ( sys . stdin , "isatty" ) : return plainpager if not hasattr ( sys . stdout , "isatty" ) : return plainpager if not sys . stdin . isatty ( ) or not sys . stdout . isatty ( ) : return plainpager use_pager = os . environ . get ( 'MANPAGER' ) or os . environ . get ( 'PAGER' ) if use_pager : if sys . platform == 'win32' : # pipes completely broken in Windows return lambda text : tempfilepager ( plain ( text ) , use_pager ) elif os . environ . get ( 'TERM' ) in ( 'dumb' , 'emacs' ) : return lambda text : pipepager ( plain ( text ) , use_pager ) else : return lambda text : pipepager ( text , use_pager ) if os . environ . get ( 'TERM' ) in ( 'dumb' , 'emacs' ) : return plainpager if sys . platform == 'win32' : return lambda text : tempfilepager ( plain ( text ) , 'more <' ) if hasattr ( os , 'system' ) and os . system ( '(less) 2>/dev/null' ) == 0 : return lambda text : pipepager ( text , 'less' ) import tempfile ( fd , filename ) = tempfile . mkstemp ( ) os . close ( fd ) try : if hasattr ( os , 'system' ) and os . system ( 'more "%s"' % filename ) == 0 : return lambda text : pipepager ( text , 'more' ) else : return ttypager finally : os . unlink ( filename )