-def prep_project_link(args, stderr, project_exists=check_project_exists):
- # Given the user's command line arguments, return a dictionary with data
- # to create the desired project link for this Collection, or None.
- # Raises ValueError if the arguments request something impossible.
- making_collection = not (args.raw or args.stream)
- any_link_spec = args.project_uuid or args.name
- if not making_collection:
- if any_link_spec:
- raise ValueError("Requested a Link without creating a Collection")
- return None
- elif not any_link_spec:
- stderr.write(
- "arv-put: No --project-uuid or --name specified. This data will be cached\n"
- "in Keep. You will need to find this upload by its locator(s) later.\n")
- return None
- elif not args.project_uuid:
- raise ValueError("--name requires --project-uuid")
- elif not project_exists(args.project_uuid):
- raise ValueError("Project {} not found".format(args.project_uuid))
- link = {'tail_uuid': args.project_uuid, 'link_class': 'name'}
- if args.name:
- link['name'] = args.name
- return link