def test_exclusive_walk_includes_prebuilt_pyc(): """Ensure exclusive_walk keeps prebuilt .pyc files""" source_files = [ data_path("paths/source/A.pyc"), data_path("paths/source/A.py"), data_path("paths/source/subdir/B.pyc"), data_path("paths/source/subdir/B.py"), data_path("paths/source/C.pyc"), data_path("paths/source/subdir/D.pyc"), data_path("paths/source/__pycache__/E.pyc"), ] make_files(*source_files) walked_files = [] for root, subdirs, files in paths.exclusive_walk(data_path("paths")): for file in files: walked_files.append(paths.normalize(root, file)) expected_files = [ data_path("paths/source/A.py"), data_path("paths/source/subdir/B.py"), data_path("paths/source/C.pyc"), data_path("paths/source/subdir/D.pyc"), ] assert set(expected_files) == set(walked_files)
def run(self, args): where = paths.normalize(args.where) if os.path.isdir(where): cli.echo() cli.echo('Error: Can not create module in existing directory.') sys.exit(1) default_name, default_version = parse_module_path(where) cli.echo() cli.echo('This command will guide you through creating a new module.') cli.echo() name = cli.prompt(' Module Name [%s]: ' % default_name) version = cli.prompt(' Version [%s]: ' % default_version.string) description = cli.prompt(' Description []: ') author = cli.prompt(' Author []: ') email = cli.prompt(' Email []: ') cli.echo() cli.echo('- Creating your new Module...', end='') module = api.create( where=where, name=name or default_name, version=version or default_version.string, description=description, author=author, email=email, ) cli.echo('OK!') cli.echo() cli.echo(' ' + module.path) cli.echo() cli.echo('Steps you might take before publishing...') cli.echo() cli.echo(' - Include binaries your module depends on') cli.echo(' - Edit the module.yml file') cli.echo(' - Add variables to the environment section') cli.echo(' - Add other modules to the requires section') cli.echo(' - Add python hooks like post_activate') cli.echo()
def run(self, args): where = paths.normalize(args.where) if os.path.isdir(where): core.echo() core.echo("Error: Can not create module in existing directory.") core.exit(1) default_name, default_version = parse_module_path(where) core.echo() core.echo("This command will guide you through creating a new module.") core.echo() name = core.prompt(" Module Name [%s]: " % default_name) version = core.prompt(" Version [%s]: " % default_version.string) description = core.prompt(" Description []: ") author = core.prompt(" Author []: ") email = core.prompt(" Email []: ") core.echo() core.echo("- Creating your new Module...", end="") module = api.create( where=where, name=name or default_name, version=version or default_version.string, description=description, author=author, email=email, ) core.echo("OK!") core.echo() core.echo(" " + module.path) core.echo() core.echo("Steps you might take before publishing...") core.echo() core.echo(" - Include binaries your module depends on") core.echo(" - Edit the module.yml file") core.echo(" - Add variables to the environment section") core.echo(" - Add other modules to the requires section") core.echo(" - Add python hooks like post_activate") core.echo()
def run(self, args): try: if not args.from_repo: module_spec = api.resolve([args.module])[0] else: from_repo = api.get_repo(args.from_repo) module_spec = from_repo.find(args.module)[0] except Exception: core.echo() core.echo("Error: Failed to resolve " + args.module) core.exit(1) where = paths.normalize(args.where or ".", module_spec.real_name) if os.path.isdir(where): core.echo("Error: Directory already exists - " + where) core.exit(1) core.echo("- Cloning %s..." % module_spec.real_name) core.echo() try: module = module_spec.repo.download( module_spec, where=where, overwrite=args.overwrite, ) except Exception as e: core.echo() core.echo("Error: " + str(e)) core.exit(1) core.echo() core.echo("Navigate to the following folder to make changes:") core.echo(" " + module.path) core.echo() core.echo("Use one of the following commands to publish your changes:") core.echo(" cpenv publish .") core.echo(' cpenv publish . --to_repo="repo_name"')
def data_path(*args): return paths.normalize(os.path.dirname(__file__), "data", *args)