Displays an account tree.

  Args:
    account: dict The account to display.
    accounts: dict Map from customerId to account.
    links: dict Map from customerId to child links.
    depth: int Depth of the current account in the tree.
427228
def DisplayAccountTree(account, accounts, links, depth=0):
  
  prefix = '-' * depth * 2
  print '%s%s, %s' % (prefix, account['customerId'], account['name'])
  if account['customerId'] in links:
    for child_link in links[account['customerId']]:
      child_account = accounts[child_link['clientCustomerId']]
      DisplayAccountTree(child_account, accounts, links, depth + 1)
630408
def nodes(self, alias, depth=10, bank_id=None):
        
        if bank_id:
            return self._root + self._safe_alias(alias) + '/child/nodes/' + bank_id + '?descendentlevels=' + str(depth)
        else:
            return self._root + self._safe_alias(alias) + '/root/nodes?descendentlevels=' + str(depth)
289897
def get_all_children(self, fullname: str) -> List[Account]:
        
        # find the account by fullname
        root_acct = self.get_by_fullname(fullname)
        if not root_acct:
            raise NameError("Account not found in book!")

        acct_agg = self.get_account_aggregate(root_acct)
        result = acct_agg.get_all_child_accounts_as_array()
        # for child in root_acct.children:
        #     log(DEBUG, "found child %s", child.fullname)
        return result
514456
def account_lists(self, id):
        
        id = self.__unpack_id(id)
        params = self.__generate_params(locals(), ['id'])
        url = '/api/v1/accounts/{0}/lists'.format(str(id))
        return self.__api_request('GET', url, params)
1124912
def get_all(cls, include_disabled=True):
        
        if cls == BaseAccount:
            raise InquisitorError('get_all on BaseAccount is not supported')

        account_type_id = db.AccountType.find_one(account_type=cls.account_type).account_type_id
        qry = db.Account.order_by(desc(Account.enabled), Account.account_type_id, Account.account_name)

        if not include_disabled:
            qry = qry.filter(Account.enabled == 1)

        accounts = qry.find(Account.account_type_id == account_type_id)

        return {res.account_id: cls(res) for res in accounts}
18219
private void printDatabase(Account acc, int level, PrintStream stream) {
        String buf = "";

        for (int i = 0; i < level; i++)
            buf += " ";

        buf += "+";
        buf += acc.getName() + "[" + acc.getUrl() + "] (" + acc.getPatterns().size() + " patterns)";

        stream.println(buf);

        for (Account account : acc.getChildren())
            printDatabase(account, level + 2, stream);
    }

    public List<Account> findPathToAccountById(String id) {
        LinkedList<Account> result = getRootInLinkedList();
        findAccountById(result, id);
        // reverse the list, so that its,<root> -> parent -> ... -> Found Account
        List<Account> retValue = new ArrayList<Account>(result.size());
        Iterator<Account> iter = result.descendingIterator();
        while (iter.hasNext()) retValue.add(iter.next());
        return retValue;
    }

    public List<Account> getAllAccounts() {
        Set<Account> acc = new HashSet<Account>();
        getAllAccounts(getRootAccount(), acc);
        List<Account> sorted = new ArrayList<Account>(acc);
        Collections.sort(sorted, new Comparator<Account>() {
            @Override
            public int compare(Account o1, Account o2) {
                return o1.getName().compareToIgnoreCase(o2.getName());
            }
        });
        return sorted;
    }

    private void getAllAccounts(Account base, Collection<Account> into) {
        for (Account c : base.getChildren()) {
            if ( c.hasChildren() ) {
                getAllAccounts(c, into);
            } else {
                into.add(c);
            }
        }
    }


    /**
     * Locates an account, given an id.
     *
     * @param id The account id (unique hash).
     * @return The account if found, else null.
     */
    public Account findAccountById(String id) {
        return findAccountById(getRootInLinkedList(), id);
    }

    /**
     * Internal function to recurse through accounts looking for an id.
     *
     * @param stack  The path to the current parent
     * @param id     The id to look for.
     * @return The Account if found, else null.
     */
    private Account findAccountById(LinkedList<Account> stack, String id) {
        final Account parent = stack.peek();
        if (parent == null) {
            if ( ! stack.isEmpty() ) stack.pop();
            return null;
        }
        for (Account child : parent.getChildren()) {
            if (child.getId().equals(id)) {
                stack.push(child);
                return child;
            }
            if (child.getChildren().size() > 0) {
                stack.push(child);
                Account foundAccount = findAccountById(stack, id);
                if (foundAccount != null)
                    return foundAccount;
            }
        }
        stack.pop();
        return null;
    }

    private LinkedList<Account> getRootInLinkedList() {
        LinkedList<Account> stack = new LinkedList<Account>();
        stack.add(rootAccount);
        return stack;
    }

    /**
     * Searches the database for any account with a matching URL.
     *
     * @param url The regex to search with.
     * @return The account if found, else null.
     */
    public Account findAccountByUrl(String url) {
        return findAccountByUrl(rootAccount, url);
    }

    /**
     * Internal function to aid in searching.  This will find the first account in the tree starting at parent
     * that matches the url given.
     *
     * @param parent - The parent to start searching with.
     * @param url    - Url to search for
     * @return the matching account (maybe the parent), or Null if no matching account was found.
     */
    private Account findAccountByUrl(Account parent, String url) {
        // First search the parent
        if (AccountPatternMatcher.matchUrl(parent, url) && !parent.isRoot())
            return parent;
        for (Account child : parent.getChildren()) {
            Account foundAccount = findAccountByUrl(child, url);
            if (foundAccount != null)
                return foundAccount;
        }
        return null;
    }
580180
def account(self):
        
        data = self.query(Account.key)
        return Account(self, data)
400299
def accounts(self):
        
        d = {}

        if False and not self._account_password:
            from ambry.dbexceptions import ConfigurationError
            raise ConfigurationError(
                "Can't access accounts without setting an account password"
                " either in the accounts.password config, or in the AMBRY_ACCOUNT_PASSWORD"
                " env var.")

        for act in self.database.session.query(Account).all():
            if self._account_password:
                act.secret_password = self._account_password
            e = act.dict
            a_id = e['account_id']
            d[a_id] = e

        return d
335579
def for_account_hash(parent, account_hash):
        
        account = AccountProxy(parent)
        account.account_hash = account_hash
        if account.acquire():
            return account
        return None
752759
def vesting(ctx, account):
    
    account = Account(account, full=True)
    t = [["vesting_id", "claimable"]]
    for vest in account["vesting_balances"]:
        vesting = Vesting(vest)
        t.append([vesting["id"], str(vesting.claimable)])
    print_table(t)
462934
def accountSummary(self, account: str = '') -> List[AccountValue]:
        
        if not self.wrapper.acctSummary:
            # loaded on demand since it takes ca. 250 ms
            self.reqAccountSummary()
        if account:
            return [v for v in self.wrapper.acctSummary.values()
                    if v.account == account]
        else:
            return list(self.wrapper.acctSummary.values())
479276
public void removeAccount(Account accountToDelete) {
        // Thou shalt not delete root
        if (accountToDelete.getId().equals(rootAccount.getId()))
            return;

        Account parent = findParent(accountToDelete);
        if (parent != null) {
            removeAccount(parent, accountToDelete);
            setDirty(true);
        }
    }
355904
def account(self):
        
        resp = self._call(endpoint='account')
        return Account(resp['credits'], resp['jobs_completed'], resp['jobs_processing'])
1141774
def account_overview(object):
    """"""
    return Layout(
        Container(
            Row(
                Column2(
                    Panel(
                        'Avatar',
                        Img(src="{}{}".format(settings.MEDIA_URL, object.avatar)),
                        collapse=True,
                    ),
                ),
                Column10(
                    Panel(
                        'Account information',
                        DescriptionList(
                            'email',
                            'first_name',
                            'last_name',
                        ),
                    )
                ),
            )
        )
    )
236237
def tree():
    
    session = AppAggregate().open_session()
    classes = session.query(AssetClass).all()
    # Get the root classes
    root = []
    for ac in classes:
        if ac.parentid is None:
            root.append(ac)
        # logger.debug(ac.parentid)
    # header
    print_row("id", "asset class", "allocation", "level")
    print(f"-------------------------------")

    for ac in root:
        print_item_with_children(ac, classes, 0)
416824
def __get_all_child_accounts_as_array(self, account: Account) -> List[Account]:
        
        result = []
        # ignore placeholders ? - what if a brokerage account has cash/stocks division?
        # if not account.placeholder:
        # continue
        result.append(account)

        for child in account.children:
            sub_accounts = self.__get_all_child_accounts_as_array(child)
            result += sub_accounts

        return result
42397
def balance(ctx, accounts):
    
    t = PrettyTable(["Account", "Amount"])
    t.align = "r"
    for a in accounts:
        account = Account(a, peerplays_instance=ctx.peerplays)
        for b in account.balances:
            t.add_row([str(a), str(b)])
    click.echo(str(t))