recursive function to get the fields in the correct order based on the wsdl definitions
15596
function getFields(def, obj) {
		var a = {};
		
		// if not an object, return the value
		if (!_.isObject(obj)) {
			return obj;
		}
		
		// check for type override
		var defType = _.get(obj, 'attributes.xsi:type') || _.get(obj, 'attributes.type');
		defType     = defType ? defType.replace(/^vim25\:/i, '') : null;

		// if there is a type override and it is a valid type, set the def to that type
		// and add the type to the attributes
		if (defType && _.has(_client.types, defType)) {
			def = _client.types[defType]();
			a.attributes = {
				'xsi:type': defType
			};
		}
		
		// loop through each field in the type definition and look for fields
		// that were supplied by the user
		_.forEach(def, function(v, k) {
			if (_.has(obj, k)) {
				if (Array.isArray(obj[k])) {
					a[k] = _.map(obj[k], function(o) {
						return getFields(v, o);
					});
				}
				else if (_.isObject(v) && _.isObject(obj[k])) {
					a[k] = getFields(v, obj[k]);
				}
				else {
					a[k] = obj[k];
				}
			}
		});
		
		// return the new arguments object
		return a;
	}
331463
def get_fields(self):
        """"""
        fields = super(DataSerializer, self).get_fields()

        # Hide collections/entities fields on list views as fetching them may be expensive.
        if self.parent is not None:
            del fields['collections']
            del fields['entities']

        return fields
306680
def order_results_by(*fields):
    
    def decorator(f):
        @functools.wraps(f)
        def wrapper(*args, **kw):
            result = f(*args, **kw)
            return result.order_by(*fields)
        return wrapper
    return decorator
1162917
def _GetOrderedEntries(data):
  

  # The raw data dictionary has two kinds of keys: strings (which correspond to
  # field name) or integers (if the name is unknown). In Python 3 it is not
  # possible to compare integers and strings to each other, so we first tag each
  # with either a 0 or 1 (so named fields are going to be serialized first) and
  # let the lexicographical ordering of the tuples take care of the rest.
  def Tag(field):
    """Tags field name with a number to make comparison possible."""

    # TODO: We use `string_types` here because in Python 2
    # attribute names (which are passed e.g. through keyword arguments) are
    # represented as `bytes` whereas in Python 3 it is `unicode`. This should
    # be replaced with `str` once support for Python 2 is dropped.
    if isinstance(field, string_types):
      return 0, field
    if isinstance(field, int):
      return 1, field

    message = "Unexpected field '{}' of type '{}'".format(field, type(field))
    raise TypeError(message)

  for field in sorted(iterkeys(data), key=Tag):
    yield data[field]
19885
def separate_fields(fields):
    
    flat_fields = {}
    nested_fields = {}

    # exclude "id" and "meta" elements
    for k, v in fields.items():
        # TODO: remove dependence on KEYS_TO_INCLUDE
        if k not in KEYS_TO_EXCLUDE:
            if type(v) not in [type({}), type([])]:
                flat_fields.update({k: v})
            else:
                nested_fields.update({k: v})

    return flat_fields, nested_fields
1082237
function (items, query, fields, exact) {
        var self = this;
        var isTarget = function (fieldName) {
          return fields.indexOf(fieldName) !== -1;
        };
        if (query === '') {
          return items;
        }
        fields = fields || ['name', 'owner', 'description', 'keyword'];
        return _.filter(items, function (item) {
          if ((isTarget('name') && self.matchedInString(query, item.name, exact)) ||
              (isTarget('owner') && self.matchedInString(query, item.owner, exact)) ||
              (isTarget('description') && self.matchedInString(query, item.description, exact)) ||
              (isTarget('keyword') && self.matchedInArray(query, item.keywords, exact))) {
            return true;
          }
          return false;
        });
      }
1198797
function dict(schema, defaults, options) {
  if (kindOf(schema) !== 'array' || schema.length !== 2) {
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `Dict structs must be defined as an array with two elements, but you passed: ${schema}`
      )
    } else {
      throw new Error(`Invalid schema: ${schema}`)
    }
  }

  const obj = scalar('object', undefined, options)
  const keys = any(schema[0], undefined, options)
  const values = any(schema[1], undefined, options)
  const name = 'dict'
  const type = `dict<${keys.type},${values.type}>`
  const validate = value => {
    const resolved = resolveDefaults(defaults)
    value = resolved ? { ...resolved, ...value } : value
    const [error] = obj.validate(value)

    if (error) {
      error.type = type
      return [error]
    }

    const ret = {}
    const errors = []

    for (let k in value) {
      const v = value[k]
      const [e, r] = keys.validate(k)

      if (e) {
        const allE = e.errors || [e]
        allE.forEach(singleE => {
          singleE.path = [k].concat(singleE.path)
          singleE.data = value
          errors.push(singleE)
        })
        continue
      }

      k = r
      const [e2, r2] = values.validate(v)

      if (e2) {
        const allE2 = e2.errors || [e2]
        allE2.forEach(singleE => {
          singleE.path = [k].concat(singleE.path)
          singleE.data = value
          errors.push(singleE)
        })
        continue
      }

      ret[k] = r2
    }

    if (errors.length) {
      const first = errors[0]
      first.errors = errors
      return [first]
    }

    return [undefined, ret]
  }

  return new Kind(name, type, validate)
}
957553
def _parse_fields(self, result, field_name):
        
        field_list = []
        for key, value in result.get('schema', {}).get(field_name, {}).items():
            if key not in field_list:
                field_list.append(key)
        return field_list
143785
def order(self, last):
        ''''''
        desc = last.desc
        field = last.name
        nested = last.nested
        nested_args = []
        while nested:
            meta = nested.model._meta
            nested_args.extend((self.backend.basekey(meta), nested.name))
            last = nested
            nested = nested.nested
        method = 'ALPHA' if last.field.internal_type == 'text' else ''
        if field == last.model._meta.pkname():
            field = ''
        return {'field': field,
                'method': method,
                'desc': desc,
                'nested': nested_args}
230811
public function dataFields()
    {
        if (empty($this->sequentialSet)) {
            $fields = [];
            $this->recursiveWalk(function (FormField $field) use (&$fields) {
                if (!$field->hasData()) {
                    return;
                }
                $name = $field->getName();
                if (isset($fields[$name])) {
                    $this->fieldNameError($field, __FUNCTION__);
                }
                $fields[$name] = $field;
            });
            $this->sequentialSet = $fields;
        }
        return $this->sequentialSet;
    }
922144
function(fieldOrSpec) {
  var fieldHash = {};
  var indexes = [];
  var keys;

  // Get all the fields accordingly
  if ('string' === typeof fieldOrSpec) {
    // 'type'
    indexes.push(fieldOrSpec + '_' + 1);
    fieldHash[fieldOrSpec] = 1;
  } else if (Array.isArray(fieldOrSpec)) {
    fieldOrSpec.forEach(function(f) {
      if ('string' === typeof f) {
        // [{location:'2d'}, 'type']
        indexes.push(f + '_' + 1);
        fieldHash[f] = 1;
      } else if (Array.isArray(f)) {
        // [['location', '2d'],['type', 1]]
        indexes.push(f[0] + '_' + (f[1] || 1));
        fieldHash[f[0]] = f[1] || 1;
      } else if (isObject(f)) {
        // [{location:'2d'}, {type:1}]
        keys = Object.keys(f);
        keys.forEach(function(k) {
          indexes.push(k + '_' + f[k]);
          fieldHash[k] = f[k];
        });
      } else {
        // undefined (ignore)
      }
    });
  } else if (isObject(fieldOrSpec)) {
    // {location:'2d', type:1}
    keys = Object.keys(fieldOrSpec);
    keys.forEach(function(key) {
      indexes.push(key + '_' + fieldOrSpec[key]);
      fieldHash[key] = fieldOrSpec[key];
    });
  }

  return {
    name: indexes.join('_'),
    keys: keys,
    fieldHash: fieldHash
  };
}
1181955
def array name, values
      array_attrs = {
        'soapenc:arrayType' => "xsd:string[#{values.length}]",
        'xsi:type'          => 'wsdl:ArrayOfString'
      }
      builder.tag! name, array_attrs do |tag|
        values.each { |value| tag.item value }
      end
      self
    end
272086
private void groupFieldtoDoc(UNode                parentNode,
                                 FieldDefinition      groupFieldDef,
                                 Set<FieldDefinition> deferredFields) {
        // Prerequisities:
        assert parentNode != null;
        assert groupFieldDef != null && groupFieldDef.isGroupField();
        assert deferredFields != null && deferredFields.size() > 0;
        
        UNode groupNode = parentNode.addMapNode(groupFieldDef.getName(), "field");
        for (FieldDefinition nestedFieldDef : groupFieldDef.getNestedFields()) {
            if (!deferredFields.contains(nestedFieldDef)) {
                continue;
            }
            if (nestedFieldDef.isGroupField()) {
                groupFieldtoDoc(groupNode, nestedFieldDef, deferredFields);
            } else {
                leafFieldtoDoc(groupNode, nestedFieldDef.getName());
            }
        }
    }
700972
private function parseWsdl(): void
    {
        $this->printer->writeln('Parsing WSDL.');
        $client = new \SoapClient((string) $this->wsdl);

        foreach ($client->__getTypes() as $rawType) {
            $type = $this->parser->parseType($rawType);

            if ($type instanceof Struct) {
                $this->wsdl->addStruct($type);
            } elseif ($type instanceof Property) {
                $this->wsdl->addSimpleType($type);
            }
        }

        foreach ($client->__getFunctions() as $rawFunction) {
            $method = $this->parser->parseFunction($rawFunction);
            $this->wsdl->addMethod($method);
        }
    }
826308
private void mapSerialFieldTagImplsToFieldDocImpls(FieldDocImpl spfDoc,
                                                       DocEnv env,
                                                       ClassSymbol def) {
        Names names = def.name.table.names;

        SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
        for (int i = 0; i < sfTag.length; i++) {
            if (sfTag[i].fieldName() == null || sfTag[i].fieldType() == null) // ignore malformed @serialField tags
                continue;

            Name fieldName = names.fromString(sfTag[i].fieldName());

            // Look for a FieldDocImpl that is documented by serialFieldTagImpl.
            for (Scope.Entry e = def.members().lookup(fieldName); e.scope != null; e = e.next()) {
                if (e.sym.kind == Kinds.VAR) {
                    VarSymbol f = (VarSymbol)e.sym;
                    FieldDocImpl fdi = env.getFieldDoc(f);
                    ((SerialFieldTagImpl)(sfTag[i])).mapToFieldDocImpl(fdi);
                    break;
                }
            }
        }
    }
1136022
def get_field_type(field):
    
    if isinstance(field, core_filters.MappedMultipleChoiceFilter):
        return ' | '.join(['"%s"' % f for f in sorted(field.mapped_to_model)])
    if isinstance(field, OrderingFilter) or isinstance(field, ChoiceFilter):
        return ' | '.join(['"%s"' % f[0] for f in field.extra['choices']])
    if isinstance(field, ChoiceField):
        return ' | '.join(['"%s"' % f for f in sorted(field.choices)])
    if isinstance(field, HyperlinkedRelatedField):
        if field.view_name.endswith('detail'):
            return 'link to %s' % reverse(field.view_name,
                                          kwargs={'%s' % field.lookup_field: "'%s'" % field.lookup_field})
        return reverse(field.view_name)
    if isinstance(field, structure_filters.ServiceTypeFilter):
        return ' | '.join(['"%s"' % f for f in SupportedServices.get_filter_mapping().keys()])
    if isinstance(field, ResourceTypeFilter):
        return ' | '.join(['"%s"' % f for f in SupportedServices.get_resource_models().keys()])
    if isinstance(field, core_serializers.GenericRelatedField):
        links = []
        for model in field.related_models:
            detail_view_name = core_utils.get_detail_view_name(model)
            for f in field.lookup_fields:
                try:
                    link = reverse(detail_view_name, kwargs={'%s' % f: "'%s'" % f})
                except NoReverseMatch:
                    pass
                else:
                    links.append(link)
                    break
        path = ', '.join(links)
        if path:
            return 'link to any: %s' % path
    if isinstance(field, core_filters.ContentTypeFilter):
        return "string in form 'app_label'.'model_name'"
    if isinstance(field, ModelMultipleChoiceFilter):
        return get_field_type(field.field)
    if isinstance(field, ListSerializer):
        return 'list of [%s]' % get_field_type(field.child)
    if isinstance(field, ManyRelatedField):
        return 'list of [%s]' % get_field_type(field.child_relation)
    if isinstance(field, ModelField):
        return get_field_type(field.model_field)

    name = field.__class__.__name__
    for w in ('Filter', 'Field', 'Serializer'):
        name = name.replace(w, '')
    return FIELDS.get(name, name)
955792
def publictypes(self):
        
        for t in self.wsdl.schema.types.values():
            if t in self.params:
                continue
            if t in self.types:
                continue
            item = (t, t)
            self.types.append(item)
        self.types.sort(key=lambda x: x[0].name)