Hi, I'm trying to create a file which lists all the code files in my project. The source code is mounted in a container which is passed the function below
CODE_FILE_LIST is a string which is just the name of my output file
async def list_code_files(self, ctx: dagger.Container) -> dagger.Container: file_list = [] files = await ctx.directory("/src").glob('**/*.c|**/*.cpp') for file in files: if 'CVI' not in file: file_list.append(file.replace("\\", "/")) with open(self.CODE_FILE_LIST, 'w') as f: for file_path in file_list: f.write(f"Code found at {file_path}\n") return ctx.with_file(f"/src/{self.CODE_FILE_LIST}", dagger.File(self.CODE_FILE_LIST))
The creation of the file list works fine, but I'm a real pickle with how to add the file to the container which I'm returning. I've tried a variety of solutions for the with_file but I can't figure out what I'm doing wrong. Can someone point me in the right direction please?