val =
        :param dict val: {"content":"", "name":"", "ext":"", "type":""}
        :return:
189638
def clean_value(self, val):
        
        if isinstance(val, dict):
            if self.random_name:
                val['random_name'] = self.random_name
            if 'file_name' in val.keys():
                val['name'] = val.pop('file_name')
                val['content'] = val.pop('file_content')
            return self.file_manager().store_file(**val)

        # If val is not instance of dict, it should be return itself because the val is the key of
        # the file
        try:
            return str(val)
        except ValueError:
            raise ValidationError("%r could not be cast to string" % val)
50270
def deserialize_dict(self, attr, dict_type):
        
        if isinstance(attr, list):
            return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr}

        if isinstance(attr, ET.Element):
            # Transform <Key>value</Key> into {"Key": "value"}
            attr = {el.tag: el.text for el in attr}
        return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()}
173077
def from_val(val_schema):
    """"""
    definition = getattr(val_schema, "definition", val_schema) if isinstance(
        val_schema, BaseSchema) else val_schema
    if isinstance(definition, dict):
        return _dict_to_teleport(definition)

    if isinstance(definition, list):
        # teleport only supports a single type by default
        if len(definition) == 1:
            return {"Array": from_val(definition[0])}

    if definition in VAL_PRIMITIVES:
        return VAL_PRIMITIVES[definition]

    raise SerializationError(
        "Serializing %r not (yet) supported." % definition)
1149294
def _format_param_val(self, param_val):
        
        if isinstance(param_val, list):
            return ' '.join(str(x) for x in param_val)
        else:
            return str(param_val)
871769
def content(self, value):
        
        self._validator.validate_message_dict(value)
        self._content = value
131376
def _render_value(self, val, context, delimiters=None):
        
        if not is_string(val):
            # In case the template is an integer, for example.
            val = self.to_str(val)
        if type(val) is not unicode:
            val = self.literal(val)
        return self.render(val, context, delimiters)
212031
def urlquote(val):
    
    if val is None: return ''
    if not isinstance(val, unicode): val = str(val)
    else: val = val.encode('utf-8')
    return urllib.quote(val)
627988
def _parse_address(self, val):
        

        ret = {
            'type': None,
            'value': None
        }

        try:

            ret['type'] = val[1]['type']

        except (KeyError, ValueError, TypeError):

                pass

        try:

            ret['value'] = val[1]['label']

        except (KeyError, ValueError, TypeError):

            ret['value'] = '\n'.join(val[3]).strip()

        try:

            self.vars['address'].append(ret)

        except AttributeError:

            self.vars['address'] = []
            self.vars['address'].append(ret)
295299
function stringifyVal(val) {
  return JSON.stringify(
    val,
    (key, val) => {
      if (typeof val === 'function') {
        if (val.name) {
          return `[Function: ${val.name}]: ${val.toString()}`
        } else {
          return `[Function]: ${val.toString()}`
        }
      }
      return val
    },
    2
  )
}
486824
def tojson(val, indent=None):
    '''
    
    '''
    options = {'ensure_ascii': True}
    if indent is not None:
        options['indent'] = indent
    return (
        salt.utils.json.dumps(
            val, **options
        ).replace('<', '\\u003c')
         .replace('>', '\\u003e')
         .replace('&', '\\u0026')
         .replace("'", '\\u0027')
    )
172121
def _handle_key_value(t_dict, key, value):
    
    if key in t_dict:
        val = t_dict[key]
        if isinstance(val, str):
            val = [val]
        val.append(value)
        return val
    return value
397684
def _compile_key_val(self, data, indent_level):
        """"""
        buffer = ''
        for (key, val) in data.items():
            buffer += self._indent * indent_level
            # TODO: assumes key is a string
            buffer += key + ':'

            if isinstance(val, dict):
                buffer += '\n'
                buffer += self._compile_key_val(val, indent_level+1)
            elif (
                isinstance(val, list) and
                any(isinstance(i, (dict, list)) for i in val)
            ):
                buffer += self._compile_list(val, indent_level+1)
            else:
                buffer += ' '
                buffer += self._compile_value(val, indent_level)
                buffer += '\n'

        return buffer
394247
def translate_dict(cls, val):
        """"""
        escaped = ', '.join(
            ["{} -> {}".format(cls.translate_str(k), cls.translate(v)) for k, v in val.items()]
        )
        return 'Map({})'.format(escaped)
1230199
def _type_to_str(self, type):
        
        for key, val in self.TYPE_NAMES.items():
            if key == type:
                return val
962944
def to_representation(self, value):
        
        return {
            six.text_type(key): self.child.to_representation(val)
            for key, val in value.items()
        }
642220
def create_empty(cls, val=0x00):
        
        userdata_dict = {}
        for i in range(1, 15):
            key = 'd{}'.format(i)
            userdata_dict.update({key: val})
        return userdata_dict
1277415
def from_dict(cls, val):
        
        if isinstance(val, dict2):
            return val

        elif isinstance(val, dict):
            res = cls()
            for k, v in val.items():
                res[k] = cls.from_dict(v)
            return res

        elif isinstance(val, list):
            res = []
            for item in val:
                res.append(cls.from_dict(item))
            return res
        else:
            return val