Change variables to proper types.
192725
protected function parseValue($value){
		switch( true ){
			case ($value === 'false' || $value === 'true'):
				return  ( $value === 'true' ) ? true : false ;
			
			case ctype_digit($value):
				return (int) $value; 

			case is_float($value):
				return (float) $value;

			default:
				return $value;
		}
	}
1062985
def replace_types(text):
    """"""
    if not hasattr(replace_types, '_replacer'):
        replace_types._replacer = build_replacer()
    return replace_types._replacer(text)
983822
def update(self, attrs):
        """"""
        ########################################################################
        def convertStrToDict(strVal):
            if isinstance(strVal, dict): return strVal
            strVal = re.sub("[\{\}]+", "", str(strVal))
            regexCol = re.compile(":")
            terms = re.split("[,\s]+", strVal)
            keyvals = [re.split(regexCol, t) for t in terms]
            x = re.compile("['\"]")
            ret = {}
            boolTrue  = re.compile("true" , flags=re.IGNORECASE)
            boolFalse = re.compile("false", flags=re.IGNORECASE)
            for k, v in keyvals:
                k = re.sub(x, "", k)
                v = re.sub(x, "", v)
                if   re.search(boolTrue, v):    v = True
                elif re.search(boolFalse, v):   v = False
                else:
                    if '.' in v:
                        try:                    v = float(v)
                        except:                 pass
                    else:
                        try:                    v = int(v)
                        except:                 pass
                ret[k] = v
            return ret
        ########################################################################
        self._validateAttrs(attrs)
        for k,v in iteritems(attrs):
            typecast = type( getattr(self, k) )
            if typecast==bool and v=="False":   newval = False # "False" evalued as boolean is True because its length > 0
            elif issubclass(typecast, c.RestrictedType): # let the RestrictedType handle the type setting, value matching
                                                newval = typecast(v)
            elif "<" in str(v) or v==None:      newval = typecast(v)
            elif k == "initCmd":                newval = str(v) # specifically don't mangle the command as specified
            elif k == "initOptions":            newval = convertStrToDict(v)
            else:                               newval = typecast(str(v).lower())
            setattr(self, k, newval)
        if self.isComputer: pass
        elif "difficulty" in attrs and attrs["difficulty"]!=None: # the final state of this PlayerRecord cannot be a non-computer and specify a difficulty
            raise ValueError("%s type %s=%s does not have a difficulty"%(
                self.__class__.__name__, self.type.__class__.__name__, self.type.type))
        else: self.difficulty = c.ComputerDifficulties(None)
256877
def var(ctx, clear_target, clear_all):
    """"""

    install_var(str(ctx.obj['instance']), clear_target, clear_all)
37600
private void initializeVars() {
        mNodeKey = mWtx.getNode().getDataKey();
        mFound = false;
        mIsRightSibling = false;
        mKeyMatches = -1;
    }
1165131
function type(variable) {
                var regExp      = /\s([a-zA-Z]+)/,
                    str         = {}.toString.call(variable),
                    typeBig     = str.match(regExp)[1],
                    result      = typeBig.toLowerCase();
                
                return result;
            }
121562
private function initialiseVariables(): void
    {
        $this->entityInterfaceFqn = $this->namespaceHelper->getEntityInterfaceFromEntityFqn($this->entityFqn);
        list($className, , $subDirs) = $this->namespaceHelper->parseFullyQualifiedName(
            $this->entityFqn,
            $this->srcSubFolderName,
            $this->projectRootNamespace
        );

        $this->singularNamespacedName = $this->namespaceHelper->getSingularNamespacedName(
            $this->entityFqn,
            $subDirs
        );
        $this->pluralNamespacedName   = $this->namespaceHelper->getPluralNamespacedName(
            $this->entityFqn,
            $subDirs
        );
        $this->setDestinationDirectory(
            $className,
            $subDirs
        );
        $plural                  = \ucfirst(MappingHelper::getPluralForFqn($this->entityFqn));
        $singular                = \ucfirst(MappingHelper::getSingularForFqn($this->entityFqn));
        $nsNoEntities            = \implode('\\', \array_slice($subDirs, 2));
        $this->singularNamespace = \ltrim($nsNoEntities . '\\' . $singular, '\\');
        $this->pluralNamespace   = \ltrim($nsNoEntities . '\\' . $plural, '\\');
        $this->dirsToRename      = [];
        $this->filesCreated      = [];
    }
1329175
def infix(*kinds):
    """"""
    def wrap(fn):
        try:
            fn.infix_kinds.extend(kinds)
        except AttributeError:
            fn.infix_kinds = list(kinds)
        return fn
    return wrap
394627
def setAllowedTypes(self, allowed_types):
        """"""
        for (assoc_type, session_type) in allowed_types:
            checkSessionType(assoc_type, session_type)

        self.allowed_types = allowed_types
1138081
public synchronized void updateVariableCache(Map<String, Object> variables) {
        boolean dirty = false;
        for (Map.Entry<String, Object> entry : variables.entrySet()) {
            String variableName = entry.getKey();
            // skip any variables defined in server.xml
            if (configVariables.containsKey(variableName)) {
                continue;
            }
            Object variableValue = entry.getValue();
            if (!isVariableCached(variableName, variableValue)) {
                variableCache.put(variableName, variableValue);
                dirty = true;
            }
        }
        if (dirty) {
            saveVariableCache();
        }
    }
215402
def replace_vars(config, env):
  
  if isinstance(config, dict):
    for k, v in list(config.items()):
      if isinstance(v, dict) or isinstance(v, list) or isinstance(v, tuple):
        replace_vars(v, env)
      elif isinstance(v, basestring):
        config[k] = expand_var(v, env)
  elif isinstance(config, list):
    for i, v in enumerate(config):
      if isinstance(v, dict) or isinstance(v, list) or isinstance(v, tuple):
        replace_vars(v, env)
      elif isinstance(v, basestring):
        config[i] = expand_var(v, env)
  elif isinstance(config, tuple):
    # TODO(gram): figure out how to handle these if the tuple elements are scalar
    for v in config:
      if isinstance(v, dict) or isinstance(v, list) or isinstance(v, tuple):
        replace_vars(v, env)
1270226
def fix_type(typ, size, additional=None):
    """"""
    if additional is not None:
        my_types = types + additional
    else:
        my_types = types

    for t, info in my_types:
        if callable(t):
            matches = t(typ)
        else:
            matches = t == typ

        if matches:
            if callable(info):
                fmt_str, true_size = info(size)
            else:
                fmt_str, true_size = info
            assert size == true_size, ('{}: Got size {} instead of {}'.format(typ, size,
                                                                              true_size))
            return fmt_str.format(size=size)

    raise ValueError('No type match! ({})'.format(typ))
1221827
def _variable_type_to_read_fn(vartype, records):
    
    fn_map = {"String": "read_string", "Array[String]": "read_lines",
              "Array[Array[String]]": "read_tsv",
              "Object": "read_object", "Array[Object]": "read_objects",
              "Array[Array[Object]]": "read_objects",
              "Int": "read_int", "Float": "read_float"}
    for rec_name in records.keys():
        fn_map["%s" % rec_name] = "read_struct"
        fn_map["Array[%s]" % rec_name] = "read_struct"
        fn_map["Array[Array[%s]]" % rec_name] = "read_struct"
    # Read in Files as Strings
    vartype = vartype.replace("File", "String")
    # Can't read arrays of Ints/Floats
    vartype = vartype.replace("Array[Int]", "Array[String]")
    vartype = vartype.replace("Array[Float]", "Array[String]")
    return fn_map[vartype]
459315
def types(self):
        
        output = set()
        for var in self.values():
            if var.has_value():
                output.update(var.types())
        return list(output)
754247
function typeVarNames(t) {
    return Z.concat (
      t.type === VARIABLE ? [t.name] : [],
      Z.chain (function(k) { return typeVarNames (t.types[k]); }, t.keys)
    );
  }
1141078
void setDataType(Session session, Type type) {

        if (opType == OpTypes.VALUE) {
            valueData = type.convertToType(session, valueData, dataType);
        }

        dataType = type;
    }
1062054
def set_variable_type(index, type)
      case type
      when :continuous
        Cbc.Cbc_setContinuous @ptr, index
      when :integer, :binary
        Cbc.Cbc_setInteger @ptr, index
      else
        fail :type
      end
    end