# Path: bakery/cookies/exceptions.py
# class InvalidRepositoryError(ValueError):
#     pass
# 
# class InvalidContentFileEncoding(ValueError):
#     pass


import json
import pytz
import uuid
import http.client
from base64 import standard_b64decode
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.timezone import make_aware
from github import Github
from bakery.cookies.exceptions import (InvalidRepositoryError,
                                       InvalidContentFileEncoding)

    return Github(**credentials)

#: Server-wide authenticated GitHub state
github_setup = _github_setup()


def get_repo_from_url(url, gh_setup=github_setup):
    """
    Given an URL like (ssh://)git@github.com/user/repo.git or any other url
    that defines the root of a repository, this function returns the PyGithub
    resource describing that object.

    One can use :func:`get_cookie_data_from_repo` or
    :func:`get_mapping_file_from_repo` to get further information about that
    repository such as the content of the ``cookiecutter.json`` file.

    :param str url: The root URL to a github repository
    :param gh_setup: If not the server-wide authentiaction :data:`github_setup`
        should be used, this parameter can be set to another, e.g. user
        authenticated PyGithub object
    :return: Returns an instance of a ``PyGithub.Repository``.
    :raises: ``InvalidRepositoryError`` if the given URL does not match a known
        GitHub URL.
    """
    if 'git@github.com' in url:
        identifier = 'git@github.com'
    elif 'https://github.com/' in url:
        identifier = 'https://github.com'
    else:

# Path: bakery/cookies/exceptions.py
# class InvalidRepositoryError(ValueError):
#     pass
# 
# class InvalidContentFileEncoding(ValueError):
#     pass


# Path: bakery/utils/vcs/gh.py
import json
import pytz
import uuid
import http.client
from base64 import standard_b64decode
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.timezone import make_aware
from github import Github
from bakery.cookies.exceptions import (InvalidRepositoryError,
                                       InvalidContentFileEncoding)


    return Github(**credentials)

#: Server-wide authenticated GitHub state
github_setup = _github_setup()


def get_repo_from_url(url, gh_setup=github_setup):
    """
    Given an URL like (ssh://)git@github.com/user/repo.git or any other url
    that defines the root of a repository, this function returns the PyGithub
    resource describing that object.

    One can use :func:`get_cookie_data_from_repo` or
    :func:`get_mapping_file_from_repo` to get further information about that
    repository such as the content of the ``cookiecutter.json`` file.

    :param str url: The root URL to a github repository
    :param gh_setup: If not the server-wide authentiaction :data:`github_setup`
        should be used, this parameter can be set to another, e.g. user
        authenticated PyGithub object
    :return: Returns an instance of a ``PyGithub.Repository``.
    :raises: ``InvalidRepositoryError`` if the given URL does not match a known
        GitHub URL.
    """
    if 'git@github.com' in url:
        identifier = 'git@github.com'
    elif 'https://github.com/' in url:
        identifier = 'https://github.com'
    else:

        raise InvalidRepositoryError('{0} is not a valid GitHub URL'.format(url))