Populate info from serialized string
8230
function Unserialize(&$serialized)
    {
        // load the util from the serialized code
        $tmp = unserialize(base64_decode($serialized));
        $this->Type = $tmp->Type;
        $this->Username = $tmp->Username;
        $this->Password = $tmp->Password;
        $this->ConnectionString = $tmp->ConnectionString;
        $this->DBName = $tmp->DBName;
        $this->Type = $tmp->Type;
        $this->TablePrefix = $tmp->TablePrefix;
   		$this->Charset = $tmp->Charset;
   		$this->BootstrapSQL = $tmp->BootstrapSQL;
   		$this->Multibyte = $tmp->Multibyte;
        }
1261991
def from_string(cls, s):
        
        # Extract num and unit string.
        s = s.strip()
        for i, char in enumerate(s):
            if char.isalpha() or char.isspace():
                break
        else:
            raise Exception("Unit is missing in string %s" % s)
        num, unit = float(s[:i]), s[i:]

        # Find unit type (set it to None if it cannot be detected)
        for unit_type, d in BASE_UNITS.items():
            if unit in d:
                break
        else:
            unit_type = None

        return cls(num, unit, unit_type=unit_type)
1223027
def get_info(self):
        """"""
        re_info = re.compile(r'\[.*\]')

        self._write_cmd('v')
        while True:
            line = self._serial.readline()
            try:
                line = line.encode().decode('utf-8')
            except AttributeError:
                line = line.decode('utf-8')

            match = re_info.match(line)
            if match:
                return self._parse_info(line)
884082
private static int parseNanos(long serialized)
    {
        int zeros = ((int) serialized) & 0b111;
        int result = (int) (serialized >>> 3);
        if (zeros != 0) {
            for (int i = 0; i <= zeros; ++i) {
                result *= 10;
            }
        }
        return result;
    }
1102091
def get_serialized_info(self):
    """"""
    # Add the additional length dimension to every serialized features

    def add_length_dim(serialized_info):
      """Add the length dimension to the serialized_info.

      Args:
        serialized_info: One of tf.io.FixedLenFeature, tf.io.VarLenFeature,...

      Returns:
        new_serialized_info: serialized_info with extended first dimension
      """
      if isinstance(serialized_info, tf.io.FixedLenFeature):
        if self._length is not None:
          return tf.io.FixedLenFeature(
              shape=(self._length,) + serialized_info.shape,
              dtype=serialized_info.dtype,
          )
        else:
          return tf.io.FixedLenSequenceFeature(
              shape=serialized_info.shape,
              dtype=serialized_info.dtype,
              allow_missing=True,
          )
      elif isinstance(serialized_info, tf.io.VarLenFeature):
        return serialized_info
      else:
        raise ValueError(
            'FixedLenSequenceFeature not supported inside SequenceDict'
        )
      return serialized_info

    tensor_info = super(SequenceDict, self).get_serialized_info()
    return utils.map_nested(add_length_dim, tensor_info)
890777
function gotData() {
  var currentString = serial.readLine();  // read the incoming data
  trim(currentString);                    // trim off trailing whitespace
  if (!currentString) return;             // if the incoming string is empty, do no more
  console.log(currentString);
  if (!isNaN(currentString)) {  // make sure the string is a number (i.e. NOT Not a Number (NaN))
    textXpos = currentString;   // save the currentString to use for the text position in draw()
  }
}
713191
def populate_values(self):
        '''
        
        '''
        obj = self._get_base_state()
        self.base_state = json.dumps(obj)
968759
def get_string_from_data(self, offset, data):
        """"""
        s = self.get_bytes_from_data(offset, data)
        end = s.find(b'\0')
        if end >= 0:
            s = s[:end]
        return s
257099
def serialize(script_string):
    '''
    
    '''
    string_tokens = script_string.split()
    serialized_script = bytearray()

    for token in string_tokens:
        if token == 'OP_CODESEPARATOR' or token == 'OP_PUSHDATA4':
            raise NotImplementedError('{} is a bad idea.'.format(token))

        if token in riemann.network.CODE_TO_INT_OVERWRITE:
            serialized_script.extend(
                [riemann.network.CODE_TO_INT_OVERWRITE[token]])

        elif token in CODE_TO_INT:
            serialized_script.extend([CODE_TO_INT[token]])

        else:
            token_bytes = bytes.fromhex(token)

            if len(token_bytes) <= 75:
                op = 'OP_PUSH_{}'.format(len(token_bytes))
                serialized_script.extend([CODE_TO_INT[op]])
                serialized_script.extend(token_bytes)

            elif len(token_bytes) > 75 and len(token_bytes) <= 255:
                op = 'OP_PUSHDATA1'
                serialized_script.extend([CODE_TO_INT[op]])
                serialized_script.extend(utils.i2le(len(token_bytes)))
                serialized_script.extend(token_bytes)

            elif len(token_bytes) > 255 and len(token_bytes) <= 1000:
                op = 'OP_PUSHDATA2'
                serialized_script.extend([CODE_TO_INT[op]])
                serialized_script.extend(
                    utils.i2le_padded(len(token_bytes), 2))
                serialized_script.extend(token_bytes)

            else:
                raise NotImplementedError(
                    'Hex string too long to serialize.')

    return serialized_script
1324007
def parse_info(response):
    ""
    info = {}
    response = nativestr(response)

    def get_value(value):
        if ',' not in value or '=' not in value:
            try:
                if '.' in value:
                    return float(value)
                else:
                    return int(value)
            except ValueError:
                return value
        else:
            sub_dict = {}
            for item in value.split(','):
                k, v = item.rsplit('=', 1)
                sub_dict[k] = get_value(v)
            return sub_dict

    for line in response.splitlines():
        if line and not line.startswith('#'):
            if line.find(':') != -1:
                key, value = line.split(':', 1)
                info[key] = get_value(value)
            else:
                # if the line isn't splittable, append it to the "__raw__" key
                info.setdefault('__raw__', []).append(line)

    return info
1176512
function dictify(serializedFormArray) {
  var o = {};
  $.each(serializedFormArray, function() {
    if (o[this.name] !== undefined) {
      if (!o[this.name].push) {
        o[this.name] = [o[this.name]];
      }
      o[this.name].push(this.value || '');
    } else {
      o[this.name] = this.value || '';
    }
  });
  return o;
}
1191774
function serializeStringFields(fields) {
  let length = 0;
  fields.forEach((field) => {
    length += (field.length + 4);
  });
  let buffer = new Buffer(4 + length);
  let offset = base_serializers.uint32(length, buffer, 0);

  fields.forEach((field) => {
    offset = base_serializers.string(field, buffer, offset);
  });
  return buffer;
}
116140
private void parseString(final String eventSerialized) {
        final StringTokenizer st = new StringTokenizer(eventSerialized, ClassUtility.SEPARATOR);
        if (st.countTokens() >= 5) {
            sequence(Integer.parseInt(st.nextToken()))
                                                      .eventType(JRebirthEventType.valueOf(st.nextToken()))
                                                      .source(st.nextToken())
                                                      .target(st.nextToken())
                                                      .eventData(st.nextToken());
        }
    }
221149
def from_string(cls, id, format, raw_content, compressed=False,
                    encoded=False):
        """"""
        content = cls(id, format, compressed, encoded)
        content._raw_content = raw_content
        return content
625822
def from_dict(cls, serialized):
        '''
        '''
        if serialized is None:
            return None
        macaroon = serialized.get('Macaroon')
        if macaroon is not None:
            macaroon = bakery.Macaroon.from_dict(macaroon)
        path = serialized.get('MacaroonPath')
        cookie_name_suffix = serialized.get('CookieNameSuffix')
        visit_url = serialized.get('VisitURL')
        wait_url = serialized.get('WaitURL')
        interaction_methods = serialized.get('InteractionMethods')
        return ErrorInfo(macaroon=macaroon, macaroon_path=path,
                         cookie_name_suffix=cookie_name_suffix,
                         visit_url=visit_url, wait_url=wait_url,
                         interaction_methods=interaction_methods)
1342736
def from_string(cls, string):
        """"""
        if string is None:
            string = ''

        if not isinstance(string, six.string_types):
            raise TypeError('string has to be a string type, got: {}'.format(type(string)))

        dictionary = {}
        tokens = [token.strip() for token in shlex.split(string)]

        def list_tuples(some_iterable):
            items, nexts = itertools.tee(some_iterable, 2)
            nexts = itertools.chain(itertools.islice(nexts, 1, None), [None])
            return list(zip(items, nexts))

        for token_current, token_next in list_tuples(tokens):

            # If current token starts with a dash, it is a value so we skip it
            if not token_current.startswith('-'):
                continue

            # If the next token is None or starts with a dash, the current token must be a flag, so the value is True
            if not token_next or token_next.startswith('-'):
                dictionary[token_current.lstrip('-')] = True

            # Otherwise the current token is an option with the next token being its value
            else:
                dictionary[token_current.lstrip('-')] = token_next

        return cls.from_dictionary(dictionary)
841510
def from_string(cls, string):
        

        # find enum value
        for attr in dir(cls):
            value = getattr(cls, attr)
            if value == string:
                return value

        # if not found, log warning and return the value passed in
        logger.warning("{} is not a valid enum value for {}.".format(string, cls.__name__))
        return string