def test_get_tags(): tags = get_tags() assert len(tags) % 6 == 0 assert TestTag in tags assert TestTag.Common in tags assert TestTag.Before in tags assert TestTag.After in tags assert TestTag.Before.Common in tags assert TestTag.After.Common in tags TestTag.name = None with pytest.raises(InvalidTagDefinitionError): get_tags()
def test_get_tags(): tags = [ tag for tag in get_tags() if tag not in (ExperimentalTag, DisabledTag) ] assert len(tags) % 6 == 0 assert TestTag in tags assert TestTag.Common in tags assert TestTag.Before in tags assert TestTag.After in tags assert TestTag.Before.Common in tags assert TestTag.After.Common in tags TestTag.name = None with pytest.raises(InvalidTagDefinitionError): get_tags()
def cli(args): base_dir = find_project_basedir('.') repository = scan_repo(base_dir) repository.load() actors = [actor for actor in repository.actors] models = [model for model in get_models() if _is_local(base_dir, model)] topics = [topic for topic in get_topics() if _is_local(base_dir, topic)] tags = [tag for tag in get_tags() if _is_local(base_dir, tag)] if not args.json: _print_group('Models', models) _print_group('Topics', topics) _print_group('Actors', actors, name_resolver=lambda x: x.class_name, path_resolver=_get_actor_path) _print_group('Tags', tags) else: output = { 'project': get_project_name(base_dir), 'base_dir': base_dir, 'topics': {topic.__name__: _get_topic_details(topic) for topic in topics}, 'models': {model.__name__: _get_model_details(model) for model in models}, 'actors': {actor.class_name: _get_actor_details(actor) for actor in actors}, 'tags': {tag.name: _get_tag_details(tag) for tag in tags} } json_mod.dump(output, sys.stdout, indent=2)
def cli(args): base_dir = find_repository_basedir('.') repository = find_and_scan_repositories(base_dir, include_locals=True) try: repository.load() except LeappError as exc: sys.stderr.write(exc.message) sys.exit(1) actors = [actor for actor in repository.actors] topics = [ topic for topic in get_topics() if _is_local(repository, topic, base_dir, all_repos=args.all) ] models = [ model for model in get_models() if _is_local(repository, model, base_dir, all_repos=args.all) ] tags = [ tag for tag in get_tags() if _is_local(repository, tag, base_dir, all_repos=args.all) ] workflows = [ workflow for workflow in get_workflows() if _is_local(repository, workflow, base_dir, all_repos=args.all) ] if not args.json: sys.stdout.write( 'Repository:\n Name: {repository}\n Path: {base_dir}\n\n'.format( repository=get_repository_name(base_dir), base_dir=base_dir)) _print_group('Actors', actors, name_resolver=lambda x: x.class_name, path_resolver=_get_actor_path) _print_group('Models', models) _print_group('Tags', tags) _print_group('Topics', topics) _print_group('Workflows', workflows) else: output = { 'repository': get_repository_name(base_dir), 'base_dir': base_dir, 'topics': dict((topic.__name__, _get_topic_details(topic)) for topic in topics), 'models': dict((model.__name__, _get_model_details(model)) for model in models), 'actors': dict((actor.class_name, _get_actor_details(actor)) for actor in actors), 'tags': dict((tag.name, _get_tag_details(tag)) for tag in tags), 'workflows': dict((workflow.__name__, _get_workflow_details(workflow)) for workflow in workflows) } json_mod.dump(output, sys.stdout, indent=2)
def cli(args): logging.basicConfig(level=logging.WARNING, stream=sys.stderr) base_dir = find_repository_basedir('.') if args.safe and args.json: sys.stderr.write( 'The options --safe and --json are currently mutually exclusive\n') sys.exit(1) if args.safe: sys.stdout.write( 'Repository:\n Name: {repository}\n Path: {base_dir}\n\n'.format( repository=get_repository_name(base_dir), base_dir=base_dir)) safe_discover(base_dir) sys.exit(0) repository = find_and_scan_repositories(base_dir, include_locals=True) try: repository.load() except LeappError as exc: sys.stderr.write(exc.message) sys.stderr.write('\n') sys.exit(1) actors = repository.actors topics = [ topic for topic in get_topics() if _is_local(repository, topic, base_dir, all_repos=args.all) ] models = [ model for model in get_models() if _is_local(repository, model, base_dir, all_repos=args.all) ] tags = [ tag for tag in get_tags() if _is_local(repository, tag, base_dir, all_repos=args.all) ] workflows = [ workflow for workflow in get_workflows() if _is_local(repository, workflow, base_dir, all_repos=args.all) ] if not args.json: sys.stdout.write( 'Repository:\n Name: {repository}\n Path: {base_dir}\n\n'.format( repository=get_repository_name(base_dir), base_dir=base_dir)) _print_group('Actors', actors, name_resolver=lambda x: x.class_name, path_resolver=_get_actor_path) _print_group('Models', models) _print_group('Tags', tags) _print_group('Topics', topics) _print_group('Workflows', workflows) else: output = { 'repository': get_repository_name(base_dir), 'base_dir': base_dir, 'topics': dict((topic.__name__, _get_topic_details(topic)) for topic in topics), 'models': dict((model.__name__, _get_model_details(model)) for model in models), 'actors': dict((actor.class_name, _get_actor_details(actor)) for actor in actors), 'tags': dict((tag.name, _get_tag_details(tag)) for tag in tags), 'workflows': dict((workflow.__name__, _get_workflow_details(workflow)) for workflow in workflows) } json.dump(output, sys.stdout, indent=2) sys.stdout.write('\n')