Parse a string, imports the module and returns the class.

    >>> parse_class('hashlib.md5')
    <built-in function openssl_md5>
766832
def parse_class(val):
    
    module, class_name = val.rsplit('.', 1)
    module = importlib.import_module(module)
    try:
        return getattr(module, class_name)
    except AttributeError:
        raise ValueError('"%s" is not a valid member of %s' % (
            class_name, qualname(module))
        )
886137
def json_to_class(cls, json_str):
    

    obj_raw = json.loads(json_str)

    return deserialize(cls, obj_raw)
879718
def string_class(cls):
    
    if not PY3:
        if '__str__' not in cls.__dict__:
            raise TypeError('the given class has no __str__ method')
        cls.__unicode__, cls.__string__ = (
            cls.__str__, lambda self: self.__unicode__().encode('utf-8'))
    return cls
305592
def import_class(name):
    

    module, _, klass = name.rpartition('.')
    mod = import_module(module)
    return getattr(mod, klass)
292448
def parse_data
      # NOTE: Don't print @data. Not even in debug output. The same goes for +@keypair+.
      # We don't want private keys to end up somewhere we don't expect them. 
      raise OpenSSL::PKey::PKeyError, "No key data" if @data.nil? 
      @data.strip!
      @data =~ /\A-----BEGIN (\w+?) (P\w+?) KEY-----$/  # \A matches the string beginning (^ works on lines)
      raise OpenSSL::PKey::PKeyError, "Bad key data" unless $1 && $2
      raise OpenSSL::PKey::PKeyError, "Unknown type #{$1}" unless Rye::Key.supported_authentication?($1)
      raise OpenSSL::PKey::PKeyError, "Unknown value #{$2}" unless Rye::Key.supported_keytype?($2)
      @authtype, @keytype = $1, $2
      @keypair = OpenSSL::PKey::RSA.new(@data) if self.rsa?
      @keypair = OpenSSL::PKey::DSA.new(@data) if self.dsa?
    end
1016402
def _convert_from(data):
    
    try:
        module, klass_name = data['__class__'].rsplit('.', 1)
        klass = getattr(import_module(module), klass_name)
    except (ImportError, AttributeError, KeyError):
        # But I still haven't found what I'm looking for
        #
        # Waiting for three different exceptions here. KeyError will
        # raise if can't find the "__class__" entry in the json `data`
        # dictionary. ImportError happens when the module present in the
        # dotted name can't be resolved. Finally, the AttributeError
        # happens when we can find the module, but couldn't find the
        # class on it.
        return data
    return deserialize(klass, data['__value__'])
259633
def parse_module_class(self):
        
        cname = self.class_name
        match = re.match(self.CLASS_REGEX, cname)
        if not match:
            raise ValueError(f'not a fully qualified class name: {cname}')
        return match.groups()
43206
def parse_string(contents, name='tmp.cpp', **kwargs):
    
    idx = clang.cindex.Index.create()
    tu = idx.parse(name, unsaved_files=[(name, contents)], **kwargs)
    return _ensure_parse_valid(tu)
359763
def _from_string(cls, serialized):
        
        parse = cls.parse_url(serialized)

        if parse['version_guid']:
            parse['version_guid'] = cls.as_object_id(parse['version_guid'])

        return cls(**{key: parse.get(key) for key in cls.KEY_FIELDS})
277105
def class_string(self, klass):
        ''''''
        if isinstance(klass, string_types):
            return klass
        return klass.__module__ + '.' + klass.__name__
217828
def _from_string(cls, serialized):
        
        # Allow access to _from_string protected method
        library_key = LibraryLocator._from_string(serialized)  # pylint: disable=protected-access
        parsed_parts = LibraryLocator.parse_url(serialized)

        block_id = parsed_parts.get('block_id', None)
        if block_id is None:
            raise InvalidKeyError(cls, serialized)

        block_type = parsed_parts.get('block_type')
        if block_type is None:
            raise InvalidKeyError(cls, serialized)

        return cls(library_key, parsed_parts.get('block_type'), block_id)
594412
def str_to_python_object(input_str):
    
    if not input_str:
        return None
    if six.PY3 and isinstance(input_str, six.binary_type):
        input_str = to_str(input_str)
    if not isinstance(input_str, six.string_types):
        # gosh, we didn't get a string, we can't convert anything but strings
        # we're going to assume that what we got is actually what was wanted
        # as the output
        return input_str
    input_str = str_quote_stripper(input_str)
    if '.' not in input_str and input_str in known_mapping_str_to_type:
        return known_mapping_str_to_type[input_str]
    parts = [x.strip() for x in input_str.split('.') if x.strip()]
    try:
        try:
            # first try as a complete module
            package = __import__(input_str)
        except ImportError:
            # it must be a class from a module
            if len(parts) == 1:
                # since it has only one part, it must be a class from __main__
                parts = ('__main__', input_str)
            package = __import__('.'.join(parts[:-1]), globals(), locals(), [])
        obj = package
        for name in parts[1:]:
            obj = getattr(obj, name)
        return obj
    except AttributeError as x:
        raise CannotConvertError("%s cannot be found" % input_str)
    except ImportError as x:
        raise CannotConvertError(str(x))
107979
def str_to_class(class_name):
    
    mod_str, cls_str = class_name.rsplit('.', 1)
    mod = __import__(mod_str, globals(), locals(), [''])
    cls = getattr(mod, cls_str)
    return cls
1344145
def loads(cls, str):
        
        d = json.loads(str)
        return cls.create(d)
22055
def from_string(cls, string, exists=False, asynchronous=False, verbose=False):
        
        result = cls.parse(string)

        if result.scheme not in cls.TYPES:
            raise CopyError("Invalid scheme: %s" % (result.scheme))

        return cls.TYPES[result.scheme](result, exists, asynchronous, verbose)
514389
def parse(key_string: str) -> 'Key':
        
        parts = key_string.split(Key.PARTITION)
        key_type = KeyType.DIMENSION
        if parts[3]:
            key_type = KeyType.TIMESTAMP
        return Key(key_type, parts[0], parts[1], parts[2].split(Key.DIMENSION_PARTITION)
                   if parts[2] else [],
                   parser.parse(parts[3]) if parts[3] else None)
16273
def class_from_string(name):
    '''
    
    '''
    module_name, class_name = name.rsplit('.', 1)
    __import__(module_name)
    module = sys.modules[module_name]
    return getattr(module, class_name)