def get_dict_from_str(string):
    """
    Converts repo_from string into dictionary.
    Expected strings:
    'repo'
    'namespace/repo'
    'fork/username/repo'
    'fork/username/namespace/repo'
    """
    if string:
        words = string.split('/')
        if len(words) == 4:
            fork, username, namespace, repo = words
            return {'username': username, 'namespace': namespace, 'repo': repo}
        elif len(words) == 3:
            fork, username, repo = words
            return {'username': username, 'namespace': None, 'repo': repo}
        elif len(words) == 2:
            namespace, repo = words
            return {'username': None, 'namespace': namespace, 'repo': repo}
        elif len(words) == 1:
            repo, = words
            return {'username': None, 'namespace': None, 'repo': repo}
        else:
            raise Exception('Wrong formatted repo path')
