class_docstr: Import CLTK corpora.
class_docstr_tok: ["Import","CLTK","corpora","."]
docstr: Clone or update a git repo defined by user.
  TODO: This code is very redundant with what's in import_corpus(),
  could be refactored.
docstr_tok: ["Clone","or","update","a","git","repo","defined","by","user",".","TODO",":","This","code","is","very","redundant","with","what","'s","in","import_corpus","(",")",",","could","be","refactored","."]
code: def _git_user_defined_corpus(
      self, corpus_name, corpus_type, uri: str, branch="master"
  ):
      """Clone or update a git repo defined by user.
      TODO: This code is very redundant with what's in import_corpus(),
      could be refactored.
      """
      type_dir_rel = os.path.join(
          CLTK_DATA_DIR, self.language, corpus_type
      )
      type_dir = os.path.expanduser(type_dir_rel)
      repo_name = uri.split("/")[
          -1
      ]  # eg, 'latin_corpus_newton_example.git'
      repo_name = repo_name.rstrip(".git")
      target_dir = os.path.join(type_dir, repo_name)
      target_file = os.path.join(type_dir, repo_name, "README.md")
      # check if corpus already present
      # if not, clone
      if not os.path.isfile(target_file):
          if not os.path.isdir(type_dir):
              os.makedirs(type_dir)
          try:
              msg = "Cloning '{}' from '{}'".format(corpus_name, uri)
              logger.info(msg)
              Repo.clone_from(
                  uri,
                  target_dir,
                  branch=branch,
                  depth=1,
                  progress=ProgressPrinter(),
              )
          except CorpusImportError as corpus_imp_err:
              msg = "Git clone of '{}' failed: '{}'".format(
                  uri, corpus_imp_err
              )
              logger.error(msg)
      # if corpus is present, pull latest
      else:
          try:
              repo = Repo(target_dir)
              assert not repo.bare  # or: assert repo.exists()
              git_origin = repo.remotes.origin
              msg = "Pulling latest '{}' from '{}'.".format(
                  corpus_name, uri
              )
              logger.info(msg)
              git_origin.pull()
          except CorpusImportError as corpus_imp_err:
              msg = "Git pull of '{}' failed: '{}'".format(
                  uri, corpus_imp_err
              )
              logger.error(msg)
  
imports: import errno
  import os
  import shutil
  import sys
  from urllib.parse import urljoin
  import yaml
  from git import RemoteProgress, Repo
  from cltk.core.cltk_logger import logger
  from cltk.core.exceptions import CorpusImportError
  from cltk.languages.utils import get_lang
  from cltk.utils.utils import CLTK_DATA_DIR
label_desc: Use image node_id 8 for calling the FetchCorpus obj's underlying member method code with example usage: obj._git_user_defined_corpus(corpus_name, corpus_type, uri, branch) without return types