MCPcopy Index your code
hub / github.com/dbcli/mycli / suggest_path

Function suggest_path

mycli/packages/filepaths.py:69–97  ·  view source on GitHub ↗

List all files and subdirectories in a directory. If the directory is not specified, suggest root directory, user directory, current and parent directory. :param root_dir: string: directory to list :return: list

(root_dir: str)

Source from the content-addressed store, hash-verified

67
68
69def suggest_path(root_dir: str) -> list[str]:
70 """List all files and subdirectories in a directory.
71
72 If the directory is not specified, suggest root directory,
73 user directory, current and parent directory.
74
75 :param root_dir: string: directory to list
76 :return: list
77
78 """
79 if not root_dir:
80 return [
81 os.path.abspath(os.sep),
82 "~",
83 os.curdir,
84 os.pardir,
85 *list_path(os.curdir),
86 ]
87
88 if root_dir[0] not in ('/', '~') and root_dir[0:1] != './':
89 return list_path(os.curdir)
90
91 if "~" in root_dir:
92 root_dir = os.path.expanduser(root_dir)
93
94 if not os.path.exists(root_dir):
95 root_dir, _ = os.path.split(root_dir)
96
97 return list_path(root_dir)
98
99
100def dir_path_exists(path: str) -> bool:

Callers 1

find_filesMethod · 0.90

Calls 2

list_pathFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected