Deserialize from TOML into Python data structure.

    :param stream_or_string: toml stream or string to deserialize.
    :param options: options given to lower pytoml module.
973862
def deserialize(stream_or_string, **options):
    '''
    
    '''

    try:
        if not isinstance(stream_or_string, (bytes, six.string_types)):
            return toml.load(stream_or_string, **options)

        if isinstance(stream_or_string, bytes):
            stream_or_string = stream_or_string.decode('utf-8')

        return toml.loads(stream_or_string)
    except Exception as error:
        raise DeserializationError(error)
211689
function MetaCharsetReplacerStream(options) {
    options = options || {};
    this.encoding = options.encoding = 'utf8'; // this is the *output* encoding
    options.decodeStrings = false; // don't turn my strings back into a buffer!
    Transform.call(this, options);
}
407273
def deserialize_unicode(data):
        
        # We might be here because we have an enum modeled as string,
        # and we try to deserialize a partial dict with enum inside
        if isinstance(data, Enum):
            return data

        # Consider this is real string
        try:
            if isinstance(data, unicode):
                return data
        except NameError:
            return str(data)
        else:
            return str(data)
1069599
def __deserialize_date(self, string):
        
        try:
            from dateutil.parser import parse
            return parse(string).date()
        except ImportError:
            return string
        except ValueError:
            raise ApiException(
                status=0,
                reason="Failed to parse `{0}` into a date object".format(string)
            )
1097472
def deserialize(stream_or_string, **options):
    '''
    
    '''

    if six.PY3:
        cp = configparser.ConfigParser(**options)
    else:
        cp = configparser.SafeConfigParser(**options)

    try:
        if not isinstance(stream_or_string, (bytes, six.string_types)):
            if six.PY3:
                cp.read_file(stream_or_string)
            else:
                cp.readfp(stream_or_string)
        else:
            if six.PY3:
                cp.read_file(six.moves.StringIO(stream_or_string))
            else:
                # python2's ConfigParser cannot parse a config from a string
                cp.readfp(six.moves.StringIO(stream_or_string))
        data = {}
        for section_name in cp.sections():
            section = {}
            for k, v in cp.items(section_name):
                section[k] = v
            data[section_name] = section
        return data
    except Exception as error:
        raise DeserializationError(error)
834277
def deserialize_from_http_generics(cls, body_bytes, headers):
        # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any
        
        # Try to use content-type from headers if available
        content_type = None
        if 'content-type' in headers:
            content_type = headers['content-type'].split(";")[0].strip().lower()
        # Ouch, this server did not declare what it sent...
        # Let's guess it's JSON...
        # Also, since Autorest was considering that an empty body was a valid JSON,
        # need that test as well....
        else:
            content_type = "application/json"

        if body_bytes:
            return cls.deserialize_from_text(body_bytes, content_type)
        return None
227193
def parse(source):
    
    if isinstance(source, str):
        return parse_stream(six.StringIO(source))
    else:
        return parse_stream(source)
1030626
def internal_reader(self, input_stream):
        
        for input_line in input_stream:
            yield list(map(self.deserialize, input_line.split("\t")))
905380
def load_config(filename=None):
    
    try:
        with _config_stream(filename) as handle:
            filename = handle.name
            return deserialize_config(handle.read())
    except (OSError, toml.TomlDecodeError, UnicodeDecodeError) as exc:
        raise ConfigError(
            'Error loading configuration from {}'.format(filename)) from exc
1135437
def _loads(self, string):
        
        if not self.serialized:
            return self._decode(string)
        if string is not None:
            try:
                return self.serializer.loads(string)
            except TypeError:
                #: catches bytes errors with the builtin json library
                return self.serializer.loads(self._decode(string))
            except pickle.UnpicklingError as e:
                #: incr and decr methods create issues when pickle serialized
                #  It's a terrible idea for a serialized instance
                #  to be performing incr and decr methods, but I think
                #  it makes sense to catch the error regardless
                decoded = self._decode(string)
                if decoded.isdigit():
                    return decoded
                raise pickle.UnpicklingError(e)
174124
def parse(cls, stream):
        
        stream_rdr = cls._make_stream_reader(stream)
        ifd0_offset = stream_rdr.read_long(4)
        ifd_entries = _IfdEntries.from_stream(stream_rdr, ifd0_offset)
        return cls(ifd_entries)
1286382
def parse_string(string, options = {}, &block)
      parse_io(StringIO.new(string), options, &block)
    end
103039
function objectMode( value, options ) {
		if ( arguments.length < 2 ) {
			options = {};
		}
		options.objectMode = true;
		return new Stream( value, options );
	}
733949
def from_json(cls, raw):
        
        if raw is None:
            return None

        bcls = None
        _type = raw.get('type')
        try:
            bcls = cls._blob_type_map[BlobType(_type)]
        except (KeyError, ValueError) as e:
            logger.warning('Unknown blob type: %s', _type)
            if DEBUG:
                raise_from(exception.ParseException('Parse error for %s' % (_type), raw), e)
            return None
        blob = bcls()
        blob.load(raw)

        return blob
417502
function OSMStream(options) {
  if (!(this instanceof OSMStream)) return new OSMStream(options);

  Transform.call(this, options);

  var primaryElements = ['node', 'way', 'relation']; // emit-ables
  var subElementName = ['tag', 'nd', 'member'];

  // size of bytes read from source so far
  this.bytesRead = 0;
  // size of bytes written to stream so far
  this.bytesWritten = 0;

  // initialize parser and its event handlers
  this._parser = new expat.Parser();

  this._parser.on('pipe', (function onParserPipe(src) {
    logger('_parser received pipe from ', src.path || '<unknown pipe>');
  }).bind(this));

  this._parser.on('startElement', (function onParserStartElement(name, attrs) {
    var funcname = ['__parse_', name].join('');
    if ((primaryElements.indexOf(name) > -1 && (OSMStream.prototype[funcname])) ||
      (subElementName.indexOf(name) > -1 && this._currentElement !== null && (OSMStream.prototype[funcname]))) {
      OSMStream.prototype[funcname].call(this, attrs);
    }
  }).bind(this));

  this._parser.on('endElement', (function onParserEndElement(name) {
    if ((primaryElements.indexOf(name) < 0)) return;

    var clone = extend({}, this._currentElement);
    this._currentElement = null;

    var pushData = function pushData(data) {
      if (!data) return;

      if (this.listeners('writeable').length > 0) {
        this.emit('writeable', data, (function onWriteable(data) {
          this.__push(data);
        }).bind(this));
      } else {
        this.__push(data);
      }

    }.bind(this);

    if (this.listeners(name).length > 0) {
      this.emit(name, clone, (function onElement(data) {
        pushData(data);
      }.bind(this)));
    } else {
      pushData(clone);
    }
  }).bind(this));

  this._parser.on('error', (function onParserError(err) {
    this.emit('error', err);
  }).bind(this));

  this._parser.on('end', (function onParserEnd() {
  }).bind(this));

  this.on('pipe', (function onPipe(src) {
    if (src === this._parser) return;
    // attaching stream pipe to parser
    logger('Received pipe from ', src.toString(), ', attaching pipe to _parser');
    src.pipe(this._parser);
    this._parser.pipe(this);
  }).bind(this));

}
377122
def get_datastream_data(self, datastream, options):
        

        response_format=None
        if options and 'format' in options and options['format'] is not None:
            response_format = options['format']
            options['format'] = None

        url = '/datastream/' + str(datastream) + '/data'
        response = self.http.downstream(url, response_format)
        return response
424915
def parse(self, stream, media_type=None, parser_context=None):
        
        parser_context = parser_context or {}
        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
        data = QueryDict(stream.read(), encoding=encoding)
        return data