Translate a teleport Struct into a val subschema.
163245
def _translate_struct(inner_dict):
    """"""
    try:
        optional = inner_dict['optional'].items()
        required = inner_dict['required'].items()
    except KeyError as ex:
        raise DeserializationError("Missing key: {}".format(ex))
    except AttributeError as ex:
        raise DeserializationError(
            "Invalid Structure: {}".format(inner_dict))

    val_dict = {k: _translate(v) for k, v in required}
    val_dict.update({Optional(k): _translate(v) for k, v in optional})
    return val_dict
384770
def uint32(self, val):
        """"""
        try:
            self.msg += [pack("!I", val)]
        except struct.error:
            raise ValueError("Expected uint32")
        return self
1052314
def map_val(dest, src, key, default=None, src_key=None):
    """"""
    if not src_key:
        src_key = key

    if src_key in src:
        dest[key] = src[src_key]
    else:
        if default is not None:
            dest[key] = default
360671
def _StructPackDecoder(wire_type, format):
  

  value_size = struct.calcsize(format)
  local_unpack = struct.unpack

  # Reusing _SimpleDecoder is slightly slower than copying a bunch of code, but
  # not enough to make a significant difference.

  # Note that we expect someone up-stack to catch struct.error and convert
  # it to _DecodeError -- this way we don't have to set up exception-
  # handling blocks every time we parse one value.

  def InnerDecode(buffer, pos):
    new_pos = pos + value_size
    result = local_unpack(format, buffer[pos:new_pos])[0]
    return (result, new_pos)
  return _SimpleDecoder(wire_type, InnerDecode)
696141
def _StructPackEncoder(wire_type, format):
  

  value_size = struct.calcsize(format)

  def SpecificEncoder(field_number, is_repeated, is_packed):
    local_struct_pack = struct.pack
    if is_packed:
      tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
      local_EncodeVarint = _EncodeVarint
      def EncodePackedField(write, value):
        write(tag_bytes)
        local_EncodeVarint(write, len(value) * value_size)
        for element in value:
          write(local_struct_pack(format, element))
      return EncodePackedField
    elif is_repeated:
      tag_bytes = TagBytes(field_number, wire_type)
      def EncodeRepeatedField(write, value):
        for element in value:
          write(tag_bytes)
          write(local_struct_pack(format, element))
      return EncodeRepeatedField
    else:
      tag_bytes = TagBytes(field_number, wire_type)
      def EncodeField(write, value):
        write(tag_bytes)
        return write(local_struct_pack(format, value))
      return EncodeField

  return SpecificEncoder
763548
def into(self, val: str) -> Union['ApiNode', 'ApiEndpoint']:
        """"""
        if val in self.paths:
            return self.paths[val]
        if self.param:
            return self.param
        raise IndexError(_("Value {} is missing from api").format(val))
1151567
def translate(patterns, *, flags=0):
    """"""

    flags = _flag_transform(flags)
    return _wcparse.translate(_wcparse.split(patterns, flags), flags)
73173
public void translate(Vector3f t) {
		this.m03 += t.getX();
		this.m13 += t.getY();
		this.m23 += t.getZ();
	}
578143
function translate(load){
			var filename;
			//!steal-remove-start
			filename = getFilename(load.name);
			//!steal-remove-end

			var result = parse(load.source, this, zoneOpts);

			// Add any import specifiers to the load.
			addImportSpecifiers(load, result);
			load.metadata.originalSource = load.source;

			// Register dynamic imports for the slim loader config
			var localLoader = loader.localLoader || loader;
			if (localLoader.slimConfig) {
				localLoader.slimConfig.needsDynamicLoader = true;

				var toMap = localLoader.slimConfig.toMap;
				Array.prototype.push.apply(toMap, result.rawImports);
				Array.prototype.push.apply(toMap, result.dynamicImports);
			}

			// For live-reload, determine if we should reload the viewModel
			hasDynamicImports = result.dynamicImports.length > 0;

			return Promise.all([
				addBundles(result.dynamicImports, load.name),
				Promise.all(result.imports)
			]).then(function(pResults){
				var exportedValuesDef = Object.keys(result.ases)
				.map(function(name){
					return "\"" + name + "\": {\n" +
					"\t\t\tenumerable: true,\n" +
					"\t\t\tconfigurable: true,\n" +
					"\t\t\twritable: true,\n" +
					"\t\t\tvalue: " + name + "['default'] || " + name + "\n" +
					"\t\t}";
				}).join(",\n");

				var output = template({
					imports: JSON.stringify(pResults[1]),
					isDevelopment: isDevelopment || false,
					routeData: result.viewModel.routeData || "",
					args: result.args.join(", "),
					zoneOpts: JSON.stringify(zoneOpts),
					intermediate: JSON.stringify(result.intermediate),
					ases: exportedValuesDef ? exportedValuesDef + "," : "",
					filename: filename
				});

				return output;
			});
		}
945240
private String _serializeStruct(Struct struct, Set<Object> done) throws ConverterException {
	StringBuilder sb = new StringBuilder(goIn() + "<struct>");

	Iterator<Key> it = struct.keyIterator();

	deep++;
	while (it.hasNext()) {
	    Key key = it.next();
	    sb.append(goIn() + "<var name=" + del + XMLUtil.escapeXMLString(key.toString()) + del + ">");
	    sb.append(_serialize(struct.get(key, null), done));
	    sb.append(goIn() + "</var>");
	}
	deep--;

	sb.append(goIn() + "</struct>");
	return sb.toString();
    }
47452
private void maybeUpdateExportObjectLiteral(NodeTraversal t, Node n) {
    if (!currentScript.isModule) {
      return;
    }

    Node parent = n.getParent();
    Node rhs = parent.getLastChild();

    if (rhs.isObjectLit()) {
      for (Node c = rhs.getFirstChild(); c != null; c = c.getNext()) {
        if (c.isComputedProp()) {
          t.report(c, INVALID_EXPORT_COMPUTED_PROPERTY);
        } else if (c.isStringKey()) {
          if (!c.hasChildren()) {
            c.addChildToBack(IR.name(c.getString()).useSourceInfoFrom(c));
          }
          Node value = c.getFirstChild();
          maybeUpdateExportDeclToNode(t, c, value);
        }
      }
    }
  }
661041
def translate_labels(val):
    '''
    
    '''
    if not isinstance(val, dict):
        if not isinstance(val, list):
            val = split(val)
        new_val = {}
        for item in val:
            if isinstance(item, dict):
                if len(item) != 1:
                    raise SaltInvocationError('Invalid label(s)')
                key = next(iter(item))
                val = item[key]
            else:
                try:
                    key, val = split(item, '=', 1)
                except ValueError:
                    key = item
                    val = ''
            if not isinstance(key, six.string_types):
                key = six.text_type(key)
            if not isinstance(val, six.string_types):
                val = six.text_type(val)
            new_val[key] = val
        val = new_val
    return val
512579
def translate(self):
        """"""
        varnames = set()
        ident = self.ident
        funcnames = set([ident])

        arg_exprs = []
        for arg in self.args:
            subexprs, subvars, subfuncs = arg.translate()
            varnames.update(subvars)
            funcnames.update(subfuncs)

            # Create a subexpression that joins the result components of
            # the arguments.
            arg_exprs.append(ex_call(
                ast.Attribute(ex_literal(u''), 'join', ast.Load()),
                [ex_call(
                    'map',
                    [
                        ex_rvalue(str.__name__),
                        ast.List(subexprs, ast.Load()),
                    ]
                )],
            ))

        subexpr_call = ex_call(
            FUNCTION_PREFIX + ident,
            arg_exprs
        )
        return [subexpr_call], varnames, funcnames
1083724
def translate(cls, val):
        """"""
        if val is None:
            return cls.translate_none(val)
        elif isinstance(val, string_types):
            return cls.translate_str(val)
        # Needs to be before integer checks
        elif isinstance(val, bool):
            return cls.translate_bool(val)
        elif isinstance(val, integer_types):
            return cls.translate_int(val)
        elif isinstance(val, float):
            return cls.translate_float(val)
        elif isinstance(val, dict):
            return cls.translate_dict(val)
        elif isinstance(val, list):
            return cls.translate_list(val)
        # Use this generic translation as a last resort
        return cls.translate_escaped_str(val)
794887
function parseStruct (struct) {
  var s = struct.substring(1, struct.length-1)
    , equalIndex = s.indexOf('=')
    , rtn = {
        name: s.substring(0, equalIndex)
      , props: []
    }
  s = s.substring(equalIndex+1);

  var curProp = [], numBrackets = 0, entries = [];

  for (var i=0; i < s.length; i++) {
    var cur = s[i];
    switch (cur) {
      case '"':
        if (numBrackets > 0)
          curProp.push(cur);
        else {
          entries.push(curProp.join(''));
          curProp = [];
          numBrackets = 0;
        }
        break;
      case '{':
      case '[':
      case '(':
        numBrackets++;
        curProp.push(cur);
        break;
      case '}':
      case ']':
      case ')':
        numBrackets--;
        curProp.push(cur);
        break;
      default:
        curProp.push(cur);
        break;
    }
  }
  entries.push(curProp.join(''));
  curProp = [];
  numBrackets = 0;

  for (var i=1; i < entries.length; i+=2) {
    rtn.props.push([entries[i], entries[i+1]]);
  }
  return rtn
}
276512
def _translate(teleport_value):
    """"""
    if isinstance(teleport_value, dict):
        return _translate_composite(teleport_value)

    if teleport_value in PRIMITIVES:
        return PRIMITIVES[teleport_value]

    raise DeserializationError(
        "Could not interpret %r as a teleport schema." % teleport_value)
1314800
@Override public ValFrame apply(Env env, Env.StackHelp stk, AstRoot asts[]) {
    Frame fr = stk.track(asts[1].exec(env)).getFrame();
    int[] cols = ((AstParameter)asts[2]).columns(fr.names());
    int[] sortAsc;
    if (asts[3] instanceof AstNumList)
      sortAsc = ((AstNumList) asts[3]).expand4();
    else
      sortAsc = new int[]{(int) ((AstNum) asts[3]).getNum()};  // R client can send 1 element for some reason
    
    assert sortAsc.length==cols.length;
    return new ValFrame(Merge.sort(fr,cols, sortAsc));
  }