Get the number of names owned by an address throughout history
        Return {'status': True, 'count': ...} on success
        Return {'error': ...} on failure
172383
def rpc_get_num_historic_names_by_address(self, address, **con_info):
        
        if not check_address(address):
            return {'error': 'Invalid address', 'http_status': 400}

        db = get_db_state(self.working_dir)
        ret = db.get_num_historic_names_by_address(address)
        db.close()

        if ret is None:
            ret = 0

        return self.success_response( {'count': ret} )
582657
def get_all_names( self, offset=None, count=None, include_expired=False ):
        
        if offset is not None and offset < 0:
            offset = None

        if count is not None and count < 0:
            count = None 

        cur = self.db.cursor()
        names = namedb_get_all_names( cur, self.lastblock, offset=offset, count=count, include_expired=include_expired )
        return names
437843
def get_name_DID_info(self, name):
        
        db = get_db_state(self.working_dir)
        did_info = db.get_name_DID_info(name)
        if did_info is None:
            return {'error': 'No such name', 'http_status': 404}

        return did_info
90012
def get_count(self):
        
        params = self.get_params()
        params["offset"] = self.low_mark
        params["limit"] = 1

        r = self.resource._meta.api.http_resource("GET", self.resource._meta.resource_name, params=params)
        data = self.resource._meta.api.resource_deserialize(r.text)

        number = data["meta"]["total_count"]

        # Apply offset and limit constraints manually, since using limit/offset
        # in the API doesn't change the total_count output.
        number = max(0, number - self.low_mark)
        if self.high_mark is not None:
            number = min(number, self.high_mark - self.low_mark)

        return number
658715
def count(self, value):
        
        if self.__modified_data__ is not None:
            return self.__modified_data__.count(value)
        return self.__original_data__.count(value)
805330
def get_owner_asset_ids(self, address):
        
        block_filter = self._get_event_filter(owner=address)
        log_items = block_filter.get_all_entries(max_tries=5)
        did_list = []
        for log_i in log_items:
            did_list.append(id_to_did(log_i.args['_did']))

        return did_list
1284839
def namedb_get_history( cur, history_id, offset=None, count=None, reverse=False ):
    
    # get history in increasing order by block_id and then vtxindex
    history_rows = namedb_get_history_rows( cur, history_id, offset=offset, count=count, reverse=reverse )
    return namedb_history_extract( history_rows )
986642
def get_history(self):
        """"""
        self.load_history()
        return map(lambda x: (x, self.history[x]), self.ordered_history)
1368936
def count(self):
        
        params = self.dump()
        params['limit'] = 0
        params['count'] = 1
        content = self._do_request(params)
        return content['count']
13410
def count(self, view, include=None):
        
        return self._get(self._build_url(self.endpoint.count(id=view, include=include)))
350560
def in_use_connection_count(self, address):
        
        try:
            connections = self.connections[address]
        except KeyError:
            return 0
        else:
            return sum(1 if connection.in_use else 0 for connection in connections)
51354
def get_owners(self):
        
        response = self._client.session.get(
            '{url}/list/owners'.format(url=self.endpoint_url)
        )
        return self.process_response(response)
458806
def namedb_get_num_history_rows( cur, history_id ):
    
    ret = []
    select_query = "SELECT COUNT(*) FROM history WHERE history_id = ? ORDER BY block_id ASC, vtxindex ASC;"
    args = (history_id,)

    count = namedb_select_count_rows( cur, select_query, args )
    return count
705414
def _get_next(self, history):
        """"""
        orig_history = history
        if not history:
            return helper.START
        history = history[-(self._n-1):]
        while history and not self._T.get(history):
            history = history[1:]
        kv = [(k, v) for k, v in self._T.items(history)
              if not (k in reserved_words or k == history)]
        total = sum(v for k, v in kv)
        while total == 0 and len(history) > 0:
            history = history[1:]
            kv = [(k, v) for k, v in self._T.items(history)
                  if not (k in reserved_words or k == history)]
            total = sum(v for k, v in kv)
        assert total > 0, "Sorry there is no n-gram with {!r}".format(orig_history)
        d = defaultdict(float)
        total = self._T.get(history)
        for k, v in kv:
            k = k[len(history):]
            d[k] += (v+1)/(total + N_VALID_CHARS-1)
        return d
123719
def rpc_get_historic_names_by_address(self, address, offset, count, **con_info):
        
        if not check_address(address):
            return {'error': 'Invalid address', 'http_status': 400}

        if not check_offset(offset):
            return {'error': 'invalid offset', 'http_status': 400}

        if not check_count(count, 10):
            return {'error': 'invalid count', 'http_status': 400}

        db = get_db_state(self.working_dir)
        names = db.get_historic_names_by_address(address, offset, count)
        db.close()

        if names is None:
            names = []

        return self.success_response( {'names': names} )
1166934
def namedb_get_history_rows( cur, history_id, offset=None, count=None, reverse=False ):
    
    ret = []
    if not reverse:
        select_query = "SELECT * FROM history WHERE history_id = ? ORDER BY block_id ASC, vtxindex ASC"
    else:
        select_query = "SELECT * FROM history WHERE history_id = ? ORDER BY block_id DESC, vtxindex DESC"

    args = (history_id,)

    if count is not None:
        select_query += " LIMIT ?"
        args += (count,)

        if offset is not None:
            select_query += " OFFSET ?"
            args += (offset,)

    select_query += ";"

    history_rows = namedb_query_execute( cur, select_query, args)
    for r in history_rows:
        rd = dict(r)
        ret.append(rd)

    return ret
536182
def _getValueCounts(mapping):
    
    return Counter({k: len(v) for k, v in viewitems(mapping)})