File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -50,16 +50,17 @@ def find_first_instance_of_file(
50
50
if isinstance (file_names , str ):
51
51
file_names = [file_names ]
52
52
53
- for root , _ , files in os . walk ( os . getcwd (), topdown = False ) :
54
- for file_name in file_names :
55
- if file_name in files :
56
- return pathlib . Path ( root ). joinpath ( file_name )
53
+ for file_name in file_names :
54
+ _user_file = pathlib . Path . cwd (). joinpath ( file_name )
55
+ if _user_file . exists () :
56
+ return _user_file
57
57
58
58
# If the user is running on different mounted volume or outside
59
59
# of their user space then the above will not return the file
60
60
if check_user_space :
61
61
for file_name in file_names :
62
- if os .path .exists (_user_file := pathlib .Path .home ().joinpath (file_name )):
62
+ _user_file = pathlib .Path .home ().joinpath (file_name )
63
+ if _user_file .exists ():
63
64
return _user_file
64
65
65
66
return None
You can’t perform that action at this time.
0 commit comments