How to use the pydash._ function in pydash

To help you get started, we’ve selected a few pydash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ForestAdmin / forest-django / forest / serializers / View on Github external
def is_compound_document_included(self, included, item):
        return _.find(self.payload.get('included', {}), {
            'id': item.get('id'),
            'type': item.get('type')
github dgilland / pydash / src / pydash / View on Github external
        float: Calculated variance.


        >>> variance([1, 18, 20, 4])

    .. versionadded:: 2.1.0
    avg = mean(array)

    def var(x):
        return power(x - avg, 2)

    return pyd._(array).map_(var).mean().value()
github codejamninja / sphinx-markdown-builder / sphinx_markdown_builder / View on Github external
def depart_thead(self, node):
        for i in range(len(self.table_entries)):
            length = 0
            for row in self.table_rows:
                if len(row.children) > i:
                    entry_length = len(row.children[i].astext())
                    if entry_length > length:
                        length = entry_length
            self.add('| ' + ''.join(, lambda: '-')) + ' ')
        self.table_entries = []
github madvas / gae-angular-material-starter / main / api / v1 / View on Github external
def put(self, key):
        """Updates user's properties"""
        update_properties = ['name', 'bio', 'email', 'location', 'facebook', 'github',
                             'gplus', 'linkedin', 'twitter', 'instagram']
        if auth.is_admin():
            update_properties += ['verified', 'active', 'admin']

        new_data = _.pick(request.json, update_properties)
        return make_empty_ok_response()
github ForestAdmin / forest-django / forest / serializers / View on Github external
def pick(self, obj, attributes):
        def map_function(value, key):
            return self.key_for_attribute(key)

        return _.map_keys(_.pick(obj, attributes), map_function)
github ForestAdmin / forest-django / forest / serializers / View on Github external
def key_for_attribute(self, attribute):
        def transform_callback(acc, value, key):
            if self._is_complex_type(value):
                acc[self.key_for_attribute(key)] = self.key_for_attribute(value)
                acc[self.key_for_attribute(key)] = value
            return acc, value, key

        def map_function(item):
            if self._is_complex_type(item):
                return self.key_for_attribute(item)
                return item

        if _.is_dict(attribute):
            return _.transform(attribute, transform_callback)

        elif _.is_list(attribute):
            map(map_function, attribute)

            if _.is_function(self.opts.get('key_for_attribute')):
                return self.opts['key_for_attribute'](attribute)
                caserized = inflector.caserize(attribute, self.opts)
                return caserized
github ForestAdmin / forest-django / forest / serializers / View on Github external
def serialize_nested(self, dest, current, attribute, opts):

        embeds = []
        attributes = []

        if opts and opts.get('attributes'):
            embeds = filter(lambda x: opts.get(x), opts['attributes'])
            attributes = filter(lambda x: opts.get(x) is None, opts['attributes'])
            attributes = _.keys(dest)

        ret = {}
        if attributes:
            ret['attributes'] = self.pick(dest, attributes)

        for embed in embeds:
            if self._is_complex_type(dest[embed]):
                self.serialize(ret, dest, embed, opts[embed])

        return ret['attributes']
github ForestAdmin / forest-django / forest / serializers / View on Github external
if opts.get('relationship_meta'):
                dest['relationships'][self.key_for_attribute(attribute)]['meta'] = \
                    self.get_meta(current['attribute'], opts['relationship_meta'])
            if _.is_list(current[attribute]):
                if len(current[attribute]) and _.is_dict(current[attribute][0]):
                    def map_current(item):
                        return self.serialize_nested(item, current, attribute,
                    data = map(map_current, current[attribute])
                    data = current[attribute]

                dest['attributes'][self.key_for_attribute(attribute)] = data
            elif _.is_dict(current[attribute]):
                data = self.serialize_nested(current[attribute], current,
                                            attribute, opts)
                dest['attributes'][self.key_for_attribute(attribute)] = data
                dest['attributes'][self.key_for_attribute(attribute)] = current[attribute]


The kitchen sink of Python utility libraries for doing "stuff" in a functional way. Based on the Lo-Dash Javascript library.

Latest version published 2 months ago

Package Health Score

88 / 100
Full package analysis