mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
ui: add _isatty method to easily disable cooked I/O
This commit is contained in:
parent
e54da6574b
commit
b267442ddb
@ -492,6 +492,11 @@ class ui(object):
|
||||
try: self.ferr.flush()
|
||||
except (IOError, ValueError): pass
|
||||
|
||||
def _isatty(self, fh):
|
||||
if self.configbool('ui', 'nontty', False):
|
||||
return False
|
||||
return util.isatty(fh)
|
||||
|
||||
def interactive(self):
|
||||
'''is interactive input allowed?
|
||||
|
||||
@ -510,7 +515,7 @@ class ui(object):
|
||||
if i is None:
|
||||
# some environments replace stdin without implementing isatty
|
||||
# usually those are non-interactive
|
||||
return util.isatty(self.fin)
|
||||
return self._isatty(self.fin)
|
||||
|
||||
return i
|
||||
|
||||
@ -548,12 +553,12 @@ class ui(object):
|
||||
if i is None:
|
||||
# some environments replace stdout without implementing isatty
|
||||
# usually those are non-interactive
|
||||
return util.isatty(self.fout)
|
||||
return self._isatty(self.fout)
|
||||
|
||||
return i
|
||||
|
||||
def _readline(self, prompt=''):
|
||||
if util.isatty(self.fin):
|
||||
if self._isatty(self.fin):
|
||||
try:
|
||||
# magically add command line editing support, where
|
||||
# available
|
||||
|
Loading…
Reference in New Issue
Block a user