Пример #1
0
 def test_add_license_existing(self):
     runner = CliRunner()
     with runner.isolated_filesystem():
         with self.assertRaises(click.BadParameter):
             shell('touch LICENSE')
             add_license('.', 'MIT')
         self.assertTrue(exists(Path.cwd() / 'LICENSE'))
Пример #2
0
 def test_add_license(self):
     runner = CliRunner()
     with runner.isolated_filesystem():
         shell('touch setup.py')
         cwd = Path.cwd()
         add_license(cwd, 'MIT')
         self.assertTrue(exists(cwd / 'LICENSE'))
Пример #3
0
def create_project(name, no_git, no_install, author, description, license):
    """ Create a Python project structure in the current working directory.

    Parameters
    ----------
    name: str
        Name of the project. Also the main package name.

    no_git: bool
        If true, do not create local git repository.

    no_install: bool
        If true, do not pip-install in editable mode.

    author: str
        Author of the project.

    description:
        Short description of the project. Used for README and setup.py.
    """

    path = pathlib.Path.cwd() / name
    if os.path.exists(path):
        raise Exception('ERROR: Path already exists.')

    templates = pathlib.Path(__file__).parent / 'templates'
    subs = {
        'PROJECT_NAME': name,
        'YEAR': datetime.date.today().year,
        'VERSION': '0.0.1',
        'MODULE_NAME': 'main',
        'AUTHOR': author,
        'DESCRIPTION': description
    }

    create_project_structure(name, path, subs, templates)

    if license != 'None':
        add_license(path, license)

    create_docs(path, name, author)
    build_documentation(name)

    if not no_git:
        create_git_repo(name)

    if not no_install:
        pip_install_project(name)

    click.secho('Happy coding!', fg='blue')
Пример #4
0
def add_license_command(name):
    """Add a license to the current project."""
    add_license(pathlib.Path.cwd(), name)
Пример #5
0
 def test_add_license_no_setup_py(self):
     runner = CliRunner()
     with runner.isolated_filesystem():
         add_license('.', 'MIT')
         self.assertTrue(exists(Path.cwd() / 'LICENSE'))
Пример #6
0
 def test_add_license_with_string(self):
     runner = CliRunner()
     with runner.isolated_filesystem():
         shell('touch setup.py')
         add_license('.', 'MIT')
         self.assertTrue(exists(Path.cwd() / 'LICENSE'))