Get a path from the shader member, name or path.
Source code
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167 | def __call__(self, file_name: str | Path | MissingT = MISSING) -> Path:
"""Get a path from the shader member, name or path."""
if self is not ShaderFile.CUSTOM:
file_name = self.value
if file_name is MISSING: # type: ignore
raise TypeError("ShaderFile.__call__() missing 1 required positional argument: 'file_name'")
file_name, cwd = Path(file_name), Path.cwd()
assets_dirs = [
file_name,
cwd / file_name,
cwd / '.shaders' / file_name,
cwd / '_shaders' / file_name,
cwd / '.assets' / file_name,
cwd / '_assets' / file_name
]
for asset_dir in assets_dirs:
if asset_dir.is_file():
return asset_dir
mpv_dir = get_user_data_dir().parent / 'Roaming' / 'mpv' / 'shaders' / file_name
if mpv_dir.is_file():
return mpv_dir
raise FileWasNotFoundError(f'"{file_name}" could not be found!', str(ShaderFile.CUSTOM))
|