

def _write_fields(field_descriptors, out):
    'Write fields for Message types.\n\n  Args:\n    field_descriptors: List of FieldDescriptor objects from which to generate\n      fields.\n    out: Indent writer used for generating text.\n  '
    (out << '')
    for field in (field_descriptors or []):
        type_format = ''
        label_format = ''
        message_field = _MESSAGE_FIELD_MAP.get(field.type_name)
        if message_field:
            module = 'message_types'
            field_type = message_field
        else:
            module = 'messages'
            field_type = messages.Field.lookup_field_type_by_variant(field.variant)
        if (field_type in (messages.EnumField, messages.MessageField)):
            type_format = ("'%s', " % field.type_name)
        if (field.label == descriptor.FieldDescriptor.Label.REQUIRED):
            label_format = ', required=True'
        elif (field.label == descriptor.FieldDescriptor.Label.REPEATED):
            label_format = ', repeated=True'
        if (field_type.DEFAULT_VARIANT != field.variant):
            variant_format = (', variant=messages.Variant.%s' % field.variant)
        else:
            variant_format = ''
        if field.default_value:
            if (field_type in [messages.BytesField, messages.StringField]):
                default_value = repr(field.default_value)
            elif (field_type is messages.EnumField):
                try:
                    default_value = str(int(field.default_value))
                except ValueError:
                    default_value = repr(field.default_value)
            else:
                default_value = field.default_value
            default_format = (', default=%s' % (default_value,))
        else:
            default_format = ''
        (out << ('%s = %s.%s(%s%s%s%s%s)' % (field.name, type_format, field_type.__name__, type_format, field.number, label_format, variant_format, default_format)))

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/generate_python.py _write_fields/VarMisuse@313/533 `module`->`type_format`