File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -347,8 +347,5 @@ submission = Submission(
347347
348348result = judge0.run(submissions = submission)
349349print (result.stdout)
350-
351- matches = [f for f in result.post_execution_filesystem if f.name == " my_dir2/my_file2.txt" ]
352- f = matches[0 ] if matches else None
353- print (f)
350+ print (result.post_execution_filesystem.find(" ./my_dir2/my_file2.txt" ))
354351```
Original file line number Diff line number Diff line change @@ -92,6 +92,27 @@ def encode(self) -> bytes:
9292 zip_file .writestr (file .name , file .content )
9393 return zip_buffer .getvalue ()
9494
95+ def find (self , name : str ) -> Optional [File ]:
96+ """Find file by name in Filesystem object.
97+
98+ Parameters
99+ ----------
100+ name : str
101+ File name to find.
102+
103+ Returns
104+ -------
105+ File or None
106+ Found File object or None if not found.
107+ """
108+ if name .startswith ("./" ):
109+ name = name [2 :]
110+ elif name .startswith ("/" ):
111+ name = name [1 :]
112+
113+ matches = [f for f in self .files if f .name == name ]
114+ return matches [0 ] if matches else None
115+
95116 def __str__ (self ) -> str :
96117 """Create string representation of Filesystem object."""
97118 return b64encode (self .encode ()).decode ()
You can’t perform that action at this time.
0 commit comments