Skip to content

Commit

Permalink
Reduce nested ifs in find_pager
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymoteusz Jankowski committed Dec 1, 2019
1 parent 3e163f1 commit a6a3cbc
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions dvc/dagascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,19 @@


def find_pager():
if sys.stdout.isatty():
if is_exec_found(DEFAULT_PAGER):
pager_cmd = os.getenv(DVC_PAGER, DEFAULT_PAGER_FORMATTED)
if not sys.stdout.isatty():
return pydoc.plainpager

def less_pager(text):
return pydoc.tempfilepager(pydoc.plain(text), pager_cmd)
if is_exec_found(DEFAULT_PAGER):
pager_cmd = os.getenv(DVC_PAGER, DEFAULT_PAGER_FORMATTED)

pager = less_pager
else:
logger.info(boxify(DVC_PAGER_INFO, border_color="yellow"))
pager = pydoc.plainpager
else:
pager = pydoc.plainpager
return pager
def less_pager(text):
return pydoc.tempfilepager(pydoc.plain(text), pager_cmd)

return less_pager

logger.info(boxify(DVC_PAGER_INFO, border_color="yellow"))
return pydoc.plainpager


class VertexViewer(object):
Expand Down

0 comments on commit a6a3cbc

Please sign in to comment.