Lower standard folded output fields into GremlinFoldedContextField objects.
762355
def lower_folded_outputs(ir_blocks):
    """"""
    folds, remaining_ir_blocks = extract_folds_from_ir_blocks(ir_blocks)

    if not remaining_ir_blocks:
        raise AssertionError(u'Expected at least one non-folded block to remain: {} {} '
                             u'{}'.format(folds, remaining_ir_blocks, ir_blocks))
    output_block = remaining_ir_blocks[-1]
    if not isinstance(output_block, ConstructResult):
        raise AssertionError(u'Expected the last non-folded block to be ConstructResult, '
                             u'but instead was: {} {} '
                             u'{}'.format(type(output_block), output_block, ir_blocks))

    # Turn folded Filter blocks into GremlinFoldedFilter blocks.
    converted_folds = {
        base_fold_location.get_location_name()[0]: _convert_folded_blocks(folded_ir_blocks)
        for base_fold_location, folded_ir_blocks in six.iteritems(folds)
    }

    new_output_fields = dict()
    for output_name, output_expression in six.iteritems(output_block.fields):
        new_output_expression = output_expression

        # Turn FoldedContextField expressions into GremlinFoldedContextField ones.
        if isinstance(output_expression, FoldedContextField):
            # Get the matching folded IR blocks and put them in the new context field.
            base_fold_location_name = output_expression.fold_scope_location.get_location_name()[0]
            folded_ir_blocks = converted_folds[base_fold_location_name]
            new_output_expression = GremlinFoldedContextField(
                output_expression.fold_scope_location, folded_ir_blocks,
                output_expression.field_type)

        new_output_fields[output_name] = new_output_expression

    new_ir_blocks = remaining_ir_blocks[:-1]
    new_ir_blocks.append(ConstructResult(new_output_fields))
    return new_ir_blocks
464705
def get_rendered_fields(self, ctx=None):
        '''
        
        '''
        if ctx is None:
            ctx = RenderContext()
        ctx.push(self)
        result = []
        for f in self._fields:
            if len(f.render(ctx)):
                result.append(f)
        ctx.pop()
        return result
994450
def to_lower(cls):  # NOQA
        

        email = cls.get_fields_by_class(EmailType)
        lower = cls.get_fields_by_prop('lower', True) + email

        return list(set(email + lower))
337433
def prefixed_collapsible_map(m, prefix):
    
    if m == values.unset:
        return {}

    def flatten_dict(d, result={}, prv_keys=[]):
        for k, v in d.items():
            if isinstance(v, dict):
                flatten_dict(v, result, prv_keys + [k])
            else:
                result['.'.join(prv_keys + [k])] = v

        return result

    if isinstance(m, dict):
        flattened = flatten_dict(m)
        return {'{}.{}'.format(prefix, k): v for k, v in flattened.items()}

    return {}
1034828
static void render(List<AbstractConfigValue> stack, StringBuilder sb, int indent, boolean atRoot, String atKey,
            ConfigRenderOptions options) {
        boolean commentMerge = options.getComments();
        if (commentMerge) {
            sb.append("# unresolved merge of " + stack.size() + " values follows (\n");
            if (atKey == null) {
                indent(sb, indent, options);
                sb.append("# this unresolved merge will not be parseable because it's at the root of the object\n");
                indent(sb, indent, options);
                sb.append("# the HOCON format has no way to list multiple root objects in a single file\n");
            }
        }

        List<AbstractConfigValue> reversed = new ArrayList<AbstractConfigValue>();
        reversed.addAll(stack);
        Collections.reverse(reversed);

        int i = 0;
        for (AbstractConfigValue v : reversed) {
            if (commentMerge) {
                indent(sb, indent, options);
                if (atKey != null) {
                    sb.append("#     unmerged value " + i + " for key "
                            + ConfigImplUtil.renderJsonString(atKey) + " from ");
                } else {
                    sb.append("#     unmerged value " + i + " from ");
                }
                i += 1;
                sb.append(v.origin().description());
                sb.append("\n");

                for (String comment : v.origin().comments()) {
                    indent(sb, indent, options);
                    sb.append("# ");
                    sb.append(comment);
                    sb.append("\n");
                }
            }
            indent(sb, indent, options);

            if (atKey != null) {
                sb.append(ConfigImplUtil.renderJsonString(atKey));
                if (options.getFormatted())
                    sb.append(" : ");
                else
                    sb.append(":");
            }
            v.render(sb, indent, atRoot, options);
            sb.append(",");
            if (options.getFormatted())
                sb.append('\n');
        }
        // chop comma or newline
        sb.setLength(sb.length() - 1);
        if (options.getFormatted()) {
            sb.setLength(sb.length() - 1); // also chop comma
            sb.append("\n"); // put a newline back
        }
        if (commentMerge) {
            indent(sb, indent, options);
            sb.append("# ) end of unresolved merge\n");
        }
    }
727056
def normal_fields(self):
        """"""
        return {f:v for f, v in self.fields.items() if not f.startswith('_')}
817434
def fold_references(mapped_external_entity, references, organization)
      references = format_references(references)
      mapped_external_entity = mapped_external_entity.with_indifferent_access

      # Use both record_references and id_references + the id
      (references.values.flatten + ['id']).each do |reference|
        fold_references_helper(mapped_external_entity, reference.split('/'), organization)
      end

      mapped_external_entity
    end
1162456
def prepare_fields(fields):
    
    def process_item(value):
        if not isinstance(value, NUMERIC_TYPES):
            if isinstance(value, six.string_types):
                # encode utf-8 to unicode, if necessary
                return force_text(value)
            else:
                if isinstance(value, dict):
                    return prepare_fields(value)
                elif isinstance(value, list):
                    return list(map(process_item, value))

                return six.text_type(value)
        return value

    return dict((key, process_item(value))
                for key, value
                in fields.items())
243873
def _remap_fields(cls, kwargs):
        """"""
        mapped = {}
        for key in kwargs:
            if key in cls._remap:
                mapped[cls._remap[key]] = kwargs[key]
            else:
                mapped[key] = kwargs[key]
        return mapped
416952
def bind_fields_to_model_cls(cls, model_fields):
        """"""
        return dict(
            (field.name, field.bind_model_cls(cls)) for field in model_fields)
240785
def to_gremlin(self):
        """"""
        self.validate()
        template_data = {
            'direction': self.direction,
            'edge_name': self.edge_name,
            'inverse_direction': 'in' if self.direction == 'out' else 'out'
        }
        return (u'collectMany{{entry -> entry.{direction}_{edge_name}'
                u'.collect{{edge -> edge.{inverse_direction}V.next()}}}}'
                .format(**template_data))
374442
def to_gremlin(self):
        """"""
        self.validate()

        local_object_name = self.get_local_object_gremlin_name()

        if self.field_name == '@this':
            return local_object_name

        if '@' in self.field_name:
            return u'{}[\'{}\']'.format(local_object_name, self.field_name)
        else:
            return u'{}.{}'.format(local_object_name, self.field_name)
87475
def dump(self, fields=None, exclude=None):
        
        exclude = exclude or []
        d = {}
        if fields and self._primary_field not in fields:
            fields = list(fields)
            fields.append(self._primary_field)
        for k, v in self.properties.items():
            if ((not fields) or (k in fields)) and (not exclude or (k not in exclude)):
                if not isinstance(v, ManyToMany):
                    t = v.get_value_for_datastore(self)
                    if t is Lazy:
                        self.refresh()
                        t = v.get_value_for_datastore(self)
                    if isinstance(t, Model):
                        t = t._key
                    d[k] = v.to_str(t)
                else:
                    if fields:
                       d[k] = ','.join([str(x) for x in getattr(self, v._lazy_value(), [])])
        if self._primary_field and d and self._primary_field not in d:
            d[self._primary_field] = str(self._key)
        return d
853591
private void computeDefaultSerializableFields(DocEnv env,
                                                  ClassSymbol def,
                                                  ClassDocImpl cd) {
        for (Symbol sym : def.members().getSymbols(NON_RECURSIVE)) {
            if (sym != null && sym.kind == VAR) {
                VarSymbol f = (VarSymbol)sym;
                if ((f.flags() & Flags.STATIC) == 0 &&
                    (f.flags() & Flags.TRANSIENT) == 0) {
                    //### No modifier filtering applied here.
                    FieldDocImpl fd = env.getFieldDoc(f);
                    //### Add to beginning.
                    //### Preserve order used by old 'javadoc'.
                    fields.prepend(fd);
                }
            }
        }
    }
621122
def validate(self):
        """"""
        if not isinstance(self.fold_scope_location, FoldScopeLocation):
            raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format(
                type(self.fold_scope_location), self.fold_scope_location))

        allowed_block_types = (GremlinFoldedFilter, GremlinFoldedTraverse, Backtrack)
        for block in self.folded_ir_blocks:
            if not isinstance(block, allowed_block_types):
                raise AssertionError(
                    u'Found invalid block of type {} in folded_ir_blocks: {} '
                    u'Allowed types are {}.'
                    .format(type(block), self.folded_ir_blocks, allowed_block_types))

        if not isinstance(self.field_type, GraphQLList):
            raise ValueError(u'Invalid value of "field_type", expected a list type but got: '
                             u'{}'.format(self.field_type))

        inner_type = strip_non_null_from_type(self.field_type.of_type)
        if isinstance(inner_type, GraphQLList):
            raise GraphQLCompilationError(
                u'Outputting list-valued fields in a @fold context is currently '
                u'not supported: {} {}'.format(self.fold_scope_location, self.field_type.of_type))
327511
def lower_context_field_existence(ir_blocks, query_metadata_table):
    """"""
    def regular_visitor_fn(expression):
        """Expression visitor function that rewrites ContextFieldExistence expressions."""
        if not isinstance(expression, ContextFieldExistence):
            return expression

        location_type = query_metadata_table.get_location_info(expression.location).type

        # Since this function is only used in blocks that aren't ConstructResult,
        # the location check is performed using a regular ContextField expression.
        return BinaryComposition(
            u'!=',
            ContextField(expression.location, location_type),
            NullLiteral)

    def construct_result_visitor_fn(expression):
        """Expression visitor function that rewrites ContextFieldExistence expressions."""
        if not isinstance(expression, ContextFieldExistence):
            return expression

        location_type = query_metadata_table.get_location_info(expression.location).type

        # Since this function is only used in ConstructResult blocks,
        # the location check is performed using the special OutputContextVertex expression.
        return BinaryComposition(
            u'!=',
            OutputContextVertex(expression.location, location_type),
            NullLiteral)

    new_ir_blocks = []
    for block in ir_blocks:
        new_block = None
        if isinstance(block, ConstructResult):
            new_block = block.visit_and_update_expressions(construct_result_visitor_fn)
        else:
            new_block = block.visit_and_update_expressions(regular_visitor_fn)
        new_ir_blocks.append(new_block)

    return new_ir_blocks
333169
def model_fields(model, allow_pk=False, only=None, exclude=None,
                 field_args=None, converter=None):
    
    converter = converter or ModelConverter()
    field_args = field_args or {}

    model_fields = list(model._meta.sorted_fields)
    if not allow_pk:
        model_fields.pop(0)

    if only:
        model_fields = [x for x in model_fields if x.name in only]
    elif exclude:
        model_fields = [x for x in model_fields if x.name not in exclude]

    field_dict = {}
    for model_field in model_fields:
        name, field = converter.convert(
            model,
            model_field,
            field_args.get(model_field.name))
        field_dict[name] = field

    return field_dict