original_docstring: 
          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.
          
docstring: 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.
docstring_tokens: 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 .
code: 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, self.role))
                  return new
  
          self.gitdir = salt.utils.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 KeyError:
              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
code_tokens: def init_remote ( self ) : if self . url . startswith ( 'ssh://' ) : self . url = 'git+' + self . url new = False if not os . listdir ( self . cachedir ) : self . repo = dulwich . repo . Repo . init ( self . cachedir ) new = True else : try : self . repo = dulwich . repo . Repo ( self . cachedir ) except dulwich . repo . NotGitRepository : log . error ( _INVALID_REPO . format ( self . cachedir , self . url , self . role ) ) return new self . gitdir = salt . utils . path_join ( self . repo . path , '.git' ) try : conf = self . get_conf ( ) conf . get ( ( 'remote' , 'origin' ) , 'url' ) except KeyError : try : conf . set ( 'http' , 'sslVerify' , self . ssl_verify ) 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
short_docstring: Initialize/attach to a remote using dulwich.
short_docstring_tokens: Initialize / attach to a remote using dulwich .
comment: '''
          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.
          '''$SEP$# Dulwich will throw an error if 'ssh://' is used, so make the URL$SEP$# use git+ssh:// as dulwich expects$SEP$# Repo cachedir is empty, initialize a new repo there$SEP$# Repo cachedir exists, try to attach$SEP$# Read in config file and look for the remote$SEP$# Add remote manually, there is no function/object to do this