def get_ledger(self, name, is_full=false):
     cmd = ['ledger', str(name)]
     if is_full:
         cmd.append('full')
     response = self._command(*cmd)
     result = response.get('ledger')
     if result:
         return result
     error = response['error']
     etext = _error_text.get(error)
     if etext:
         error = '%s (%s)' % (etext, error)
     log.fatal(_error_text.get(error, error))
def search(server):
    """yields a stream of ledger numbers that match the given condition."""
    condition = lambda number: args.condition(server, number)
    ledgers = server.ledgers
    if args.binary:
        try:
            position = search.first if args.position == 'first' else search.last
            yield search.binary_search(
                ledgers[0], ledgers[-1], condition, position)
        except:
            log.fatal('no ledgers matching condition "%s".' % condition,
                      file=sys.stderr)
    else:
        for x in search.linear_search(ledgers, condition):
            yield x