def new(cls, filename):
if hasattr(settings, 'LEDGER_BIN'):
ledger_bin = settings.LEDGER_BIN
else:
ledger_bin = sh.which('ledger')
return Ledger(sh.Command(ledger_bin).bake(_tty_out=False, no_color=True, file=filename), filename=filename)
python类which()的实例源码
def get_executable_path(executable):
path = sh.which(executable)
if path is None:
raise Exception("Can't find '{}' executable, is it in your $PATH?".format(executable))
return str(path)