def init_remote(self):
        '''
        Initialize/attach to a remote using dulwich. Return a boolean which
        will let the calling function know whether or not a new repo was
        initialized by this function.
        '''
        if self.url.startswith('ssh://'):
            # Dulwich will throw an error if 'ssh://' is used, so make the URL
            # use git+ssh:// as dulwich expects
            self.url = 'git+' + self.url
        new = False
        if not os.listdir(self.cachedir):
            # Repo cachedir is empty, initialize a new repo there
            self.repo = dulwich.repo.Repo.init(self.cachedir)
            new = True
        else:
            # Repo cachedir exists, try to attach
            try:
                self.repo = dulwich.repo.Repo(self.cachedir)
            except dulwich.repo.NotGitRepository:
                log.error(_INVALID_REPO.format(self.cachedir, self.url))
                return new

        self.gitdir = os.path.join(self.repo.path, '.git')

        # Read in config file and look for the remote
        try:
            conf = self.get_conf()
            conf.get(('remote', 'origin'), 'url')
        except __HOLE__:
            try:
                conf.set('http', 'sslVerify', self.ssl_verify)
                # Add remote manually, there is no function/object to do this
                conf.set(
                    'remote "origin"',
                    'fetch',
                    '+refs/heads/*:refs/remotes/origin/*'
                )
                conf.set('remote "origin"', 'url', self.url)
                conf.set('remote "origin"', 'pushurl', self.url)
                conf.write_to_path()
            except os.error:
                pass
            else:
                new = True
        except os.error:
            pass
        return new
dataset/ETHPy150Open saltstack/salt/salt/utils/gitfs.py/Dulwich.init_remote