def clean(ctx, venv=False, extra=''): """Perform house-keeping.""" notify.banner("Cleaning up project files") # Stop any left-over watchdog if os.path.exists(TEST_FOLDER): ctx.run("cd {} && . .env && inv view --kill".format(TEST_FOLDER)) # Add patterns based on given parameters venv_dirs = ['.venv'] patterns = [TEST_FOLDER + '/', 'pip-selfcheck.json', '**/*~'] if venv: patterns.extend([i + '/' for i in venv_dirs]) if extra: patterns.extend(shlex.split(extra)) # Build fileset patterns = [antglob.includes(i) for i in patterns] if not venv: # Do not scan venv dirs when not cleaning them patterns.extend([antglob.excludes(i + '/') for i in venv_dirs]) fileset = antglob.FileSet('.', patterns) # Iterate over matches and remove them for name in fileset: notify.info('rm {0}'.format(name)) if name.endswith('/'): shutil.rmtree(name) else: os.unlink(name)
def clean(ctx, docs=False, venv=False, extra=""): """Perform house-keeping.""" notify.banner("Cleaning up project files") # Add patterns based on given parameters venv_dirs = [".venv"] patterns = ["new-script/", "pip-selfcheck.json", "**/*~"] if docs: patterns.append("docs/_build/") if venv: patterns.extend([i + "/" for i in venv_dirs]) if extra: patterns.extend(shlex.split(extra)) # Build fileset patterns = [antglob.includes(i) for i in patterns] if not venv: # Do not scan venv dirs when not cleaning them patterns.extend([antglob.excludes(i + "/") for i in venv_dirs]) fileset = antglob.FileSet(".", patterns) # Iterate over matches and remove them for name in fileset: notify.info("rm {0}".format(name)) if name.endswith("/"): shutil.rmtree(name) else: os.unlink(name)
def clean(ctx, venv=False, extra=''): """Perform house-keeping.""" notify.banner("Cleaning up project files") ctx.run("invoke view --kill") # Add patterns based on given parameters venv_dirs = ['bin', 'include', 'lib', 'share', 'local', '.venv'] patterns = ['_html/', 'pip-selfcheck.json'] excludes = ['.git/', '.hg/', '.svn/'] if venv: patterns.extend([i + '/' for i in venv_dirs]) if extra: patterns.extend(shlex.split(extra)) # Build fileset patterns = [antglob.includes(i) for i in patterns] + [antglob.excludes(i) for i in excludes] if not venv: # Do not scan venv dirs when not cleaning them patterns.extend([antglob.excludes(i + '/') for i in venv_dirs]) fileset = antglob.FileSet(BASEDIR, patterns) # Iterate over matches and remove them for name in fileset: notify.info('rm {0}'.format(name)) if name.endswith('/'): shutil.rmtree(os.path.join(BASEDIR, name)) else: os.unlink(os.path.join(BASEDIR, name))
def clean(ctx, docs=False, venv=False, extra=''): """Perform house-keeping.""" notify.banner("Cleaning up project files") # Add patterns based on given parameters venv_dirs = ['.venv'] patterns = ['new-project/', 'pip-selfcheck.json', '**/*~'] if docs: patterns.append('docs/_build/') if venv: patterns.extend([i + '/' for i in venv_dirs]) if extra: patterns.extend(shlex.split(extra)) # Build fileset patterns = [antglob.includes(i) for i in patterns] if not venv: # Do not scan venv dirs when not cleaning them patterns.extend([antglob.excludes(i + '/') for i in venv_dirs]) fileset = antglob.FileSet('.', patterns) # Iterate over matches and remove them for name in fileset: notify.info('rm {0}'.format(name)) if name.endswith('/'): shutil.rmtree(name) else: os.unlink(name)
def test(ctx): """Perform integration tests.""" # ctx.run("touch '{{cookiecutter.repo_name}}/empty-testfile'") ctx.run("py.test") # ctx.run("rm '{{cookiecutter.repo_name}}/empty-testfile'") with pushd("new-script"): # assert not os.path.exists('empty-testfile'), "empty file is removed" if os.environ.get("TRAVIS", "") == "true": venv_bin = "" notify.info("Installing archetype requirements...") ctx.run("pip --log pip-install.log -q install -r dev-requirements.txt") ctx.run("invoke --echo --pty build check") else: venv_bin = ".venv/new-script/bin/" ctx.run("bash -c '. .env --yes --develop && invoke build check'") ctx.run(venv_bin + "new-script --help") ctx.run(venv_bin + "new-script --version")
def test(ctx): """Perform integration tests.""" #ctx.run("touch '{{cookiecutter.repo_name}}/empty-testfile'") ctx.run("py.test") #ctx.run("rm '{{cookiecutter.repo_name}}/empty-testfile'") with pushd('new-script'): #assert not os.path.exists('empty-testfile'), "empty file is removed" if os.environ.get('TRAVIS', '') == 'true': venv_bin = '' notify.info("Installing archetype requirements...") ctx.run("pip --log pip-install.log -q install -r dev-requirements.txt") ctx.run("invoke --echo --pty build check") else: venv_bin = '.venv/new-script/bin/' ctx.run("bash -c '. .env --yes --develop && invoke build check'") ctx.run(venv_bin + "new-script --help") ctx.run(venv_bin + "new-script --version")
def test(ctx): """Perform integration tests.""" ctx.run("touch '{{cookiecutter.repo_name}}/empty-testfile'") ctx.run("py.test") ctx.run("rm '{{cookiecutter.repo_name}}/empty-testfile'") with pushd('new-project'): assert not os.path.exists('empty-testfile'), "empty file is removed" if os.environ.get('TRAVIS', '') == 'true': venv_bin = '' notify.info("Installing archetype requirements...") ctx.run("pip --log pip-install.log -q install -r dev-requirements.txt") ctx.run("invoke --echo --pty ci") else: venv_bin = '.venv/new-project/bin/' ctx.run("bash -c '. .env --yes --develop && invoke ci'") ctx.run(venv_bin + "new-project --help") ctx.run(venv_bin + "new-project --version") ctx.run(venv_bin + "new-project help")