Process the given `string` using the Nodeprep (`RFC 6122`_) profile. In the
    error cases defined in `RFC 3454`_ (stringprep), a :class:`ValueError` is
    raised.
509380
def nodeprep(string, allow_unassigned=False):
    

    chars = list(string)
    _nodeprep_do_mapping(chars)
    do_normalization(chars)
    check_prohibited_output(
        chars,
        (
            stringprep.in_table_c11,
            stringprep.in_table_c12,
            stringprep.in_table_c21,
            stringprep.in_table_c22,
            stringprep.in_table_c3,
            stringprep.in_table_c4,
            stringprep.in_table_c5,
            stringprep.in_table_c6,
            stringprep.in_table_c7,
            stringprep.in_table_c8,
            stringprep.in_table_c9,
            lambda x: x in _nodeprep_prohibited
        ))
    check_bidi(chars)

    if not allow_unassigned:
        check_unassigned(
            chars,
            (
                stringprep.in_table_a1,
            )
        )

    return "".join(chars)
138847
def fromHexString(cls, value, internalFormat=False, prepend=None):
        
        try:
            value = SizedInteger(value, 16).setBitLength(len(value) * 4)

        except ValueError:
            raise error.PyAsn1Error('%s.fromHexString() error: %s' % (cls.__name__, sys.exc_info()[1]))

        if prepend is not None:
            value = SizedInteger(
                (SizedInteger(prepend) << len(value)) | value
            ).setBitLength(len(prepend) + len(value))

        if not internalFormat:
            value = cls(value)

        return value
318123
def from_str(string):
        
        match = re.match(r'^START READING (\w+) FROM \w+ (\d+)$', string)
        if match:
            return SetReadingEvent(match.group(1), int(match.group(2)))
        else:
            raise EventParseError
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)
531891
def fromOctetString(cls, value, internalFormat=False, prepend=None, padding=0):
        
        value = SizedInteger(integer.from_bytes(value) >> padding).setBitLength(len(value) * 8 - padding)

        if prepend is not None:
            value = SizedInteger(
                (SizedInteger(prepend) << len(value)) | value
            ).setBitLength(len(prepend) + len(value))

        if not internalFormat:
            value = cls(value)

        return value
911289
def handle_string(self, strreq):
        '''
        
        '''

        #convert to jsonrpc-dict
        req = None
        try:
            req = json.loads(strreq)
        except:
            logging.debug('JSONRPC: Format Exception:')
            logging.debug('-----------------\n' + traceback.format_exc())
            return json.dumps(SLOJSONRPCError(-32700).to_json())

        #handle single request
        if isinstance(req, dict):
            return json.dumps(self.handle_request(req))
        #handle multiple requests
        elif isinstance(req, list):
            for r in req:
                if not isinstance(r, dict):
                    logging.debug('JSONRPC: Fmt Error: Item ' +
                                  '"%s" in request is no dictionary.' % str(r))
                    return json.dumps(SLOJSONRPCError(-32700).to_json())
                try:
                    self._validate_format(r)
                    self._validate_params(r)
                except SLOJSONRPCError as e:
                    return json.dumps(e.to_json(r.get('id', None)))

            res = []
            for r in req:
                res.append(self.handle_request(r, validate=False))
            return json.dumps(res)
        #invalid request
        else:
            return json.dumps(SLOJSONRPCError(-32700).to_json())
199760
def decode(string, encoding=None, errors=None):
    
    if encoding is None:
        encoding = getpreferredencoding()
    if errors is None:
        errors = getpreferrederrors()
    return string.decode(encoding, errors)
168140
def read_string(source, start):
    # type: (Source, int) -> Token
    
    body = source.body
    body_length = len(body)

    position = start + 1
    chunk_start = position
    code = 0  # type: Optional[int]
    value = []  # type: List[str]
    append = value.append

    while position < body_length:
        code = char_code_at(body, position)
        if code in (
            None,
            # LineTerminator
            0x000A,
            0x000D,
            # Quote
            34,
        ):
            break

        if code < 0x0020 and code != 0x0009:  # type: ignore
            raise GraphQLSyntaxError(
                source,
                position,
                u"Invalid character within String: {}.".format(print_char_code(code)),
            )

        position += 1
        if code == 92:  # \
            append(body[chunk_start : position - 1])

            code = char_code_at(body, position)
            escaped = ESCAPED_CHAR_CODES.get(code)  # type: ignore
            if escaped is not None:
                append(escaped)

            elif code == 117:  # u
                char_code = uni_char_code(
                    char_code_at(body, position + 1) or 0,
                    char_code_at(body, position + 2) or 0,
                    char_code_at(body, position + 3) or 0,
                    char_code_at(body, position + 4) or 0,
                )

                if char_code < 0:
                    raise GraphQLSyntaxError(
                        source,
                        position,
                        u"Invalid character escape sequence: \\u{}.".format(
                            body[position + 1 : position + 5]
                        ),
                    )

                append(unichr(char_code))
                position += 4
            else:
                raise GraphQLSyntaxError(
                    source,
                    position,
                    u"Invalid character escape sequence: \\{}.".format(
                        unichr(code)  # type: ignore
                    ),
                )

            position += 1
            chunk_start = position

    if code != 34:  # Quote (")
        raise GraphQLSyntaxError(source, position, "Unterminated string")

    append(body[chunk_start:position])
    return Token(TokenKind.STRING, start, position + 1, u"".join(value))
994066
def parse(self, string, strict=True):
        '''
        '''
        if isinstance(string, bytes):
            errors = 'strict' if strict else 'replace'
            string = string.decode(self.encoding, errors=errors)

        if not self.raw:
            self.raw = string
        else:
            self.raw += string

        lines = unfold_lines(string).splitlines()
        for line in lines:
            if line:
                if ':' not in line:
                    if strict:
                        raise ValueError('Field missing colon.')
                    else:
                        continue

                name, value = line.split(':', 1)
                name = name.strip()
                value = value.strip()
                self.add(name, value)
616135
def get_prep_value(self, value):
		
		if value is None or value == "":
			return None
		if isinstance(value, six.string_types):
			value = _hex_string_to_unsigned_integer(value)
		if _using_signed_storage():
			value = _unsigned_to_signed_integer(value)
		return value
1033678
def from_string(cls, string, version):
        
        header, payload = string.split("\n",1)
        if payload[0] == '\n': # There's an extra
            payload = payload[1:]
        if int(version) == 1:
            arc_header_re = ARC1_HEADER_RE
        elif int(version) == 2:
            arc_header_re = ARC2_HEADER_RE

        matches = arc_header_re.search(header)
        headers = matches.groupdict()
        arc_header = ARCHeader(**headers)
        return cls(header = arc_header, payload = payload, version = version)
502889
function parse(string) {
  if (!string || typeof string !== 'string') {
    throw new TypeError('argument string is required')
  }

  var match = dispositionTypeRegExp.exec(string)

  if (!match) {
    throw new TypeError('invalid type format')
  }

  // normalize type
  var index = match[0].length
  var type = match[1].toLowerCase()

  var key
  var names = []
  var params = {}
  var value

  // calculate index to start at
  index = paramRegExp.lastIndex = match[0].substr(-1) === ';'
    ? index - 1
    : index

  // match parameters
  while (match = paramRegExp.exec(string)) {
    if (match.index !== index) {
      throw new TypeError('invalid parameter format')
    }

    index += match[0].length
    key = match[1].toLowerCase()
    value = match[2]

    if (names.indexOf(key) !== -1) {
      throw new TypeError('invalid duplicate parameter')
    }

    names.push(key)

    if (key.indexOf('*') + 1 === key.length) {
      // decode extended value
      key = key.slice(0, -1)
      value = decodefield(value)

      // overwrite existing value
      params[key] = value
      continue
    }

    if (typeof params[key] === 'string') {
      continue
    }

    if (value[0] === '"') {
      // remove quotes and escapes
      value = value
        .substr(1, value.length - 2)
        .replace(qescRegExp, '$1')
    }

    params[key] = value
  }

  if (index !== -1 && index !== string.length) {
    throw new TypeError('invalid parameter format')
  }

  return new ContentDisposition(type, params)
}
440265
def __convert_string(node):
    """"""
    converted = __convert_node(node, default_flags=vsflags(VSFlags.UserValue))

    return __check_for_flag(converted)
801596
def prep_value(self, value):
        
        if value in MULTI_EMAIL_FIELD_EMPTY_VALUES:
            return ""
        elif isinstance(value, six.string_types):
            return value
        elif isinstance(value, list):
            return "\n".join(value)
        raise ValidationError('Invalid format.')
1006009
def Parse(self, value):
    

    value_line = value.split(' ')
    if len(value_line) < 3:
      raise TextFSMTemplateError('Expect at least 3 tokens on line.')

    if not value_line[2].startswith('('):
      # Options are present
      options = value_line[1]
      for option in options.split(','):
        self._AddOption(option)
      # Call option OnCreateOptions callbacks
      _ = [option.OnCreateOptions() for option in self.options]

      self.name = value_line[2]
      self.regex = ' '.join(value_line[3:])
    else:
      # There were no valid options, so there are no options.
      # Treat this argument as the name.
      self.name = value_line[1]
      self.regex = ' '.join(value_line[2:])

    if len(self.name) > self.max_name_len:
      raise TextFSMTemplateError(
          "Invalid Value name '%s' or name too long." % self.name)

    if (not re.match(r'^\(.*\)$', self.regex) or
        self.regex.count('(') != self.regex.count(')')):
      raise TextFSMTemplateError(
          "Value '%s' must be contained within a '()' pair." % self.regex)

    self.template = re.sub(r'^\(', '(?P<%s>' % self.name, self.regex)

    # Compile and store the regex object only on List-type values for use in nested matching
    if any(map(lambda x: isinstance(x, TextFSMOptions.List), self.options)):
        try:
            self.compiled_regex = re.compile(self.regex)
        except re.error as e:
            raise TextFSMTemplateError(str(e))
6943
function parse (string) {
  if (!string || typeof string !== 'string') {
    throw new TypeError('argument string is required')
  }

  var match = DISPOSITION_TYPE_REGEXP.exec(string)

  if (!match) {
    throw new TypeError('invalid type format')
  }

  // normalize type
  var index = match[0].length
  var type = match[1].toLowerCase()

  var key
  var names = []
  var params = {}
  var value

  // calculate index to start at
  index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'
    ? index - 1
    : index

  // match parameters
  while ((match = PARAM_REGEXP.exec(string))) {
    if (match.index !== index) {
      throw new TypeError('invalid parameter format')
    }

    index += match[0].length
    key = match[1].toLowerCase()
    value = match[2]

    if (names.indexOf(key) !== -1) {
      throw new TypeError('invalid duplicate parameter')
    }

    names.push(key)

    if (key.indexOf('*') + 1 === key.length) {
      // decode extended value
      key = key.slice(0, -1)
      value = decodefield(value)

      // overwrite existing value
      params[key] = value
      continue
    }

    if (typeof params[key] === 'string') {
      continue
    }

    if (value[0] === '"') {
      // remove quotes and escapes
      value = value
        .substr(1, value.length - 2)
        .replace(QESC_REGEXP, '$1')
    }

    params[key] = value
  }

  if (index !== -1 && index !== string.length) {
    throw new TypeError('invalid parameter format')
  }

  return new ContentDisposition(type, params)
}
722312
def convert_string_value_to_type_value(string_value, data_type):
    
    from ast import literal_eval

    try:
        if data_type in (str, type(None)):
            converted_value = str(string_value)
        elif data_type == int:
            converted_value = int(string_value)
        elif data_type == float:
            converted_value = float(string_value)
        elif data_type == bool:
            converted_value = bool(literal_eval(string_value))
        elif data_type in (list, dict, tuple):
            converted_value = literal_eval(string_value)
            if type(converted_value) != data_type:
                raise ValueError("Invalid syntax: {0}".format(string_value))
        elif data_type == object:
            try:
                converted_value = literal_eval(string_value)
            except (ValueError, SyntaxError):
                converted_value = literal_eval('"' + string_value + '"')
        elif isinstance(data_type, type):  # Try native type conversion
            converted_value = data_type(string_value)
        elif isclass(data_type):  # Call class constructor
            converted_value = data_type(string_value)
        else:
            raise ValueError("No conversion from string '{0}' to data type '{0}' defined".format(
                string_value, data_type.__name__))
    except (ValueError, SyntaxError, TypeError) as e:
        raise AttributeError("Can't convert '{0}' to type '{1}': {2}".format(string_value, data_type.__name__, e))
    return converted_value