def add_path_info( self, output_file, mode, entity, output_type, task_type=None, name="main", extension="", representation="", nb_elements=1, separator="/", ): folder_path = file_tree_service.get_output_folder_path( entity, mode=mode, output_type=output_type, task_type=task_type, revision=output_file["revision"], representation=representation, name=name, sep=separator, ) file_name = file_tree_service.get_output_file_name( entity, mode=mode, revision=output_file["revision"], output_type=output_type, task_type=task_type, name=name, nb_elements=nb_elements, ) output_file = files_service.update_output_file( output_file["id"], { "path": "%s%s%s%s" % (folder_path, separator, file_name, extension) }, ) output_file.update({"folder_path": folder_path, "file_name": file_name}) return output_file
def post(self, entity_id): args = self.get_arguments() try: entity = entities_service.get_entity(entity_id) user_service.check_project_access(entity["project_id"]) output_type = files_service.get_output_type(args["output_type_id"]) task_type = tasks_service.get_task_type(args["task_type_id"]) entity = entities_service.get_entity(entity_id) is_revision_set_by_user = args["revision"] != 0 if not is_revision_set_by_user: revision = files_service.get_next_output_file_revision( entity_id, args["name"]) else: revision = args["revision"] folder_path = file_tree_service.get_output_folder_path( entity, mode=args["mode"], output_type=output_type, task_type=task_type, name=args["name"], representation=args["representation"], sep=args["separator"], revision=args["revision"], ) file_name = file_tree_service.get_output_file_name( entity, mode=args["mode"], revision=revision, output_type=output_type, task_type=task_type, name=args["name"], ) except MalformedFileTreeException as exception: return ( { "message": str(exception), "received_data": request.json }, 400, ) return {"folder_path": folder_path, "file_name": file_name}, 200
def test_get_output_file_name_asset(self): file_name = file_tree_service.get_output_file_name( self.asset.serialize(), name="main", revision=3) self.assertEqual(file_name, "cosmos_landromat_props_tree_geometry_main_v003")