code: def setup_repo():
      r
      print('\n [setup_repo]!')
      from functools import partial
      import utool as ut
      code_dpath  = ut.truepath(ut.get_argval('--code-dir', default='~/code'))
      _code_dpath = ut.unexpanduser(code_dpath)
      repo_fname = (ut.get_argval(('--repo', '--repo-name'), type_=str))
      repo_dpath = join(code_dpath, repo_fname)
      modname = ut.get_argval('--modname', default=repo_fname)
      ut.ensuredir(repo_dpath, verbose=True)
      _regencmd = 'python -m utool --tf setup_repo --repo={repo_fname} --codedir={_code_dpath} --modname={modname}'
      flake8_noqacmd = 'flake8' + ':noqa'
      regencmd = _regencmd.format(**locals())
      with ut.ChdirContext(repo_dpath):
          locals_ = locals()
          force = True
          _ensure_text = partial(ensure_text, repo_dpath='.', force=None, locals_=locals_)
          _ensure_text(
              fname='todo.md',
              text=ut.codeblock(
                  r'''
                  * Add TODOS!
                  ''')
          )
          _ensure_text(
              fname='README.md',
              text=ut.codeblock(
                  r'''
                  ''')
          )
          _ensure_text(
              fname='setup.py',
              chmod='+x',
              text=ut.codeblock(
                  r'''
                  from __future__ import absolute_import, division, print_function, unicode_literals
                  from setuptools import setup
                  try:
                      from utool import util_setup
                  except ImportError:
                      print('ERROR: setup requires utool')
                      raise
                  INSTALL_REQUIRES = [
                  ]
                  CLUTTER_PATTERNS = [
                  ]
                  if __name__ == '__main__':
                      kwargs = util_setup.setuptools_setup(
                          setup_fpath=__file__,
                          name='{modname}',
                          packages=util_setup.find_packages(),
                          version=util_setup.parse_package_for_version('{modname}'),
                          license=util_setup.read_license('LICENSE'),
                          long_description=util_setup.parse_readme('README.md'),
                          ext_modules=util_setup.find_ext_modules(),
                          cmdclass=util_setup.get_cmdclass(),
                          keywords='',
                          install_requires=INSTALL_REQUIRES,
                          clutter_patterns=CLUTTER_PATTERNS,
                          classifiers=[],
                      )
                      setup(**kwargs)
                  '''
              )
          )
          _ensure_text(
              fname='.gitignore',
              text=ut.codeblock(
                  r'''
                  *.py[cod]
                  *.so
                  *.egg
                  *.egg-info
                  dist
                  build
                  eggs
                  parts
                  bin
                  var
                  sdist
                  develop-eggs
                  .installed.cfg
                  lib
                  lib64
                  __pycache__
                  pip-log.txt
                  logs
                  .coverage
                  .tox
                  nosetests.xml
                  *.mo
                  .mr.developer.cfg
                  .project
                  .pydevproject
                  .DS_Store
                  *.dump.txt
                  *.sqlite3
                  *.lprof
                  *.prof
                  *.flann
                  *.npz
                  _timeings.txt
                  failed.txt
                  *.orig
                  _doc
                  timeings.txt
                  failed_doctests.txt
                  '''
              )
          )
          _ensure_text(
              fname=join(repo_dpath, modname, '__init__.py'),
              text=ut.codeblock(
                  r'''
                  from __future__ import absolute_import, division, print_function, unicode_literals
                  import sys
                  __version__ = '0.0.0'
                  IMPORT_TUPLES = [
                  ]
                  __DYNAMIC__ = '--nodyn' not in sys.argv
                  DOELSE = False
                  if __DYNAMIC__:
                      from utool._internal import util_importer
                      ignore_endswith = []
                      import_execstr = util_importer.dynamic_import(
                          __name__, IMPORT_TUPLES, ignore_endswith=ignore_endswith)
                      exec(import_execstr)
                      DOELSE = False
                  else:
                      DOELSE = True
                  if DOELSE:
                      pass
                  '''
              )
          )
          _ensure_text(
              fname=join(repo_dpath, modname, '__main__.py'),
              chmod='+x',
              text=ut.codeblock(
                  r'''
                  from __future__ import absolute_import, division, print_function, unicode_literals
                  def {modname}_main():
                      ignore_prefix = []
                      ignore_suffix = []
                      import utool as ut
                      ut.main_function_tester('{modname}', ignore_prefix, ignore_suffix)
                  if __name__ == '__main__':
                      print('Running {modname} main')
                      {modname}_main()
                  '''
              )
          )
          _ensure_text(
              fname='run_tests.py',
              chmod='+x',
              text=ut.codeblock(
                  r'''
                  from __future__ import absolute_import, division, print_function
                  import sys
                  import utool as ut
                  def run_tests():
                      import sys
                      ut.change_term_title('RUN {modname} TESTS')
                      exclude_doctests_fnames = set([
                      ])
                      exclude_dirs = [
                          '_broken', 'old', 'tests', 'timeits',
                          '_scripts', '_timeits', '_doc', 'notebook',
                      ]
                      dpath_list = ['{modname}']
                      doctest_modname_list = ut.find_doctestable_modnames(
                          dpath_list, exclude_doctests_fnames, exclude_dirs)
                      coverage = ut.get_argflag(('--coverage', '--cov',))
                      if coverage:
                          import coverage
                          cov = coverage.Coverage(source=doctest_modname_list)
                          cov.start()
                          print('Starting coverage')
                          exclude_lines = [
                              'pragma: no cover',
                              'def __repr__',
                              'if self.debug:',
                              'if settings.DEBUG',
                              'raise AssertionError',
                              'raise NotImplementedError',
                              'if 0:',
                              'if ut.VERBOSE',
                              'if _debug:',
                              'if __name__ == .__main__.:',
                              'print(.*)',
                          ]
                          for line in exclude_lines:
                              cov.exclude(line)
                      for modname in doctest_modname_list:
                          exec('import ' + modname, globals())
                      module_list = [sys.modules[name] for name in doctest_modname_list]
                      nPass, nTotal, failed_cmd_list = ut.doctest_module_list(module_list)
                      if coverage:
                          print('Stoping coverage')
                          cov.stop()
                          print('Saving coverage')
                          cov.save()
                          print('Generating coverage html report')
                          cov.html_report()
                      if nPass != nTotal:
                          return 1
                      else:
                          return 0
                  if __name__ == '__main__':
                      import multiprocessing
                      multiprocessing.freeze_support()
                      retcode = run_tests()
                      sys.exit(retcode)
                  '''
              )
          )
      ut.ensuredir(join(repo_dpath, modname), verbose=True)