def pager(text, color=None):
stdout = _default_text_stdout()<EOL>if not isatty(sys.stdin) or not isatty(stdout):<EOL><INDENT>return _nullpager(stdout, text, color)<EOL><DEDENT>pager_cmd = (os.environ.get('<STR_LIT>', None) or '<STR_LIT>').strip()<EOL>if pager_cmd:<EOL><INDENT>if WIN:<EOL><INDENT>return _tempfilepager(text, pager_cmd, color)<EOL><DEDENT>return _pipepager(text, pager_cmd, color)<EOL><DEDENT>if os.environ.get('<STR_LIT>') in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>return _nullpager(stdout, text, color)<EOL><DEDENT>if WIN or sys.platform.startswith('<STR_LIT>'):<EOL><INDENT>return _tempfilepager(text, '<STR_LIT>', color)<EOL><DEDENT>if hasattr(os, '<STR_LIT>') and os.system('<STR_LIT>') == <NUM_LIT:0>:<EOL><INDENT>return _pipepager(text, '<STR_LIT>', color)<EOL><DEDENT>import tempfile<EOL>fd, filename = tempfile.mkstemp()<EOL>os.close(fd)<EOL>try:<EOL><INDENT>if hasattr(os, '<STR_LIT>') and os.system('<STR_LIT>' % filename) == <NUM_LIT:0>:<EOL><INDENT>return _pipepager(text, '<STR_LIT>', color)<EOL><DEDENT>return _nullpager(stdout, text, color)<EOL><DEDENT>finally:<EOL><INDENT>os.unlink(filename)<EOL><DEDENT>
Decide what method to use for paging through text.