Returns a dictionary of leases by current owner.
436365
def count_leases_by_owner(self, leases):  # pylint: disable=no-self-use
        
        owners = [l.owner for l in leases]
        return dict(Counter(owners))
621015
def ownership(self, ownership):
        
        error_msg = 'ownership must be a list of dictionaries'
        if ownership:
            if not isinstance(ownership, list):
                raise TypeError(error_msg)
            if not all([isinstance(item, dict) for item in ownership]):
                raise TypeError(error_msg)
            if not all([item.get('party_id') for item in ownership]):
                raise ValueError('Ownership missing one or more party_ids')
            if not all([item.get('split') for item in ownership]):
                raise ValueError('Ownership missing one or more splits')
            if sum([item.get('split') for item in ownership]) != Decimal('1'):
                raise ValueError('Ownership must sum up to 100%')
        self._ownership = ownership
257945
def owned_objects(self):
        
        return (
            [
                self,
                self.__dict__,
                self._head,
                self._tail,
                self._out_edges,
                self._out_edges._keys,
                self._out_edges._values,
                self._in_edges,
                self._in_edges._keys,
                self._in_edges._values,
                self._vertices,
                self._vertices._elements,
                self._edges,
            ] +
            list(six.itervalues(self._out_edges)) +
            list(six.itervalues(self._in_edges))
        )
1202129
def _get_ownership(self, data):
        
        rank = self.comm.rank

        B = [(rank, idx) for (idx, c) in enumerate(data) if c is not None]
        C = self.comm.allreduce(B)
        ownership = [None] * len(data)
        for c in C:
            ownership[c[1]] = c[0]
        return ownership
819849
def owners(self):
        ''''''
        return [o.strip() for o in self.owner.split(self.OWNER_ID_SEPARATOR)]
193162
def lease(self):
        
        self._request_queue.put(
            requests.LeaseRequest(ack_id=self._ack_id, byte_size=self.size)
        )
1116934
def _get_dict(obj):
    
    has_slots = hasattr(obj, '__slots__')
    if has_slots:
        d = {k:getattr(obj, k) for k in obj.__slots__}
    else:
        d = obj.__dict__
    return has_slots, d
1168957
def relations(cls):
        
        return [c.key for c in cls.__mapper__.iterate_properties
                if isinstance(c, RelationshipProperty)]
486656
def collections(record, key, value):
    """"""
    return {
        'primary': value.get('a'),
        'secondary': value.get('b'),
        'deleted': value.get('c'),
    }
1370775
def get_property(self):
        """"""

        scope = self

        def fget(self):
            """Call the HasProperties _get method"""
            return self._get(scope.name)

        return property(fget=fget, doc=scope.sphinx())
137011
def owned_expansions(self):
        """"""

        owned = {}
        for el in self.expansion_locations:
            def is_near_to_expansion(t):
                return t.position.distance_to(el) < self.EXPANSION_GAP_THRESHOLD

            th = next((x for x in self.townhalls if is_near_to_expansion(x)), None)
            if th:
                owned[el] = th

        return owned
393850
def properties(self):
        """"""
        value = self._schema.get("properties", {})
        if not isinstance(value, dict):
            raise SchemaError(
                "properties value {0!r} is not an object".format(value))
        return value
350510
def properties(self):
        
        properties = defaultdict(list)
        for pattern in self.patterns:
            for key, values in pattern.properties.items():
                extend_safe(properties[key], values)
        for rule in self.rules:
            for key, values in rule.properties.items():
                extend_safe(properties[key], values)
        return properties
920664
def get_outputs_by_public_key(self, public_key):
        """"""
        txs = list(query.get_owned_ids(self.connection, public_key))
        return [TransactionLink(tx['id'], index)
                for tx in txs
                for index, output in enumerate(tx['outputs'])
                if condition_details_has_owner(output['condition']['details'],
                                               public_key)]
910824
def get_queryset(self, request):
        """"""
        qs = super(TenantAdmin, self).get_queryset(request)
        if not request.user.is_superuser:
            tenants_by_group_manager_role = qs.filter(
                group__tenantrole__user=request.user,
                group__tenantrole__role=TenantRole.ROLE_GROUP_MANAGER
            )
            tenants_by_tenant_manager_role = qs.filter(
                tenantrole__user=request.user,
                tenantrole__role=TenantRole.ROLE_TENANT_MANAGER
            )
            return tenants_by_group_manager_role | tenants_by_tenant_manager_role
        return qs
1346559
def get_accounts_context(self):
        """"""
        income_parent = Account.objects.get(name='Income')
        housemate_parent = Account.objects.get(name='Housemate Income')
        expense_parent = Account.objects.get(name='Expenses')
        current_liabilities_parent = Account.objects.get(name='Current Liabilities')
        long_term_liabilities_parent = Account.objects.get(name='Long Term Liabilities')

        return dict(
            housemate_accounts=Account.objects.filter(parent=housemate_parent),
            expense_accounts=expense_parent.get_descendants(),
            current_liability_accounts=Account.objects.filter(parent=current_liabilities_parent),
            long_term_liability_accounts=Account.objects.filter(parent=long_term_liabilities_parent),
            other_income_accounts=Account.objects.filter(~Q(pk=housemate_parent.pk), parent=income_parent)
        )
297890
def handle_lease(queue_name):
    """"""
    owner = request.form.get('owner', request.remote_addr, type=str)
    try:
        task_list = work_queue.lease(
            queue_name,
            owner,
            request.form.get('count', 1, type=int),
            request.form.get('timeout', 60, type=int))
    except work_queue.Error, e:
        return utils.jsonify_error(e)

    if not task_list:
        return flask.jsonify(tasks=[])

    db.session.commit()
    task_ids = [t['task_id'] for t in task_list]
    logging.debug('Task leased: queue=%r, task_ids=%r, owner=%r',
                  queue_name, task_ids, owner)
    return flask.jsonify(tasks=task_list)