search_file and test work
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
# prompt user if multiple are found
|
||||
|
||||
import os
|
||||
import errno
|
||||
from fnmatch import fnmatch
|
||||
|
||||
def search_all_match(filename, path):
|
||||
@@ -12,7 +13,9 @@ def search_all_match(filename, path):
|
||||
for root, dirs, files in os.walk(path):
|
||||
for name in files:
|
||||
if fnmatch(filename, name):
|
||||
results.append(os.path.join(root, name))
|
||||
match_path = os.path.join(root, name)
|
||||
if not os.path.islink(match_path):
|
||||
results.append(match_path)
|
||||
return results
|
||||
|
||||
def print_num_list(paths):
|
||||
@@ -40,6 +43,6 @@ def search_file(filename, path):
|
||||
paths = search_all_match(filename, path)
|
||||
if len(paths) == 0 :
|
||||
print(f"No match for \"{filename}\". Link not modified.")
|
||||
raise Exception(FileNotFoundError)
|
||||
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename)
|
||||
p = select_path(paths)
|
||||
return p
|
||||
|
||||
Reference in New Issue
Block a user