Simplify `make_filename_from_project` (#12540)

This commit is contained in:
Adam Turner 2024-07-11 06:57:47 +01:00 committed by GitHub
parent 81832c2efc
commit 3d118ce81c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,16 +108,15 @@ def copyfile(source: str | os.PathLike[str], dest: str | os.PathLike[str]) -> No
copytimes(source, dest)
no_fn_re = re.compile(r'[^a-zA-Z0-9_-]')
project_suffix_re = re.compile(' Documentation$')
_no_fn_re = re.compile(r'[^a-zA-Z0-9_-]')
def make_filename(string: str) -> str:
return no_fn_re.sub('', string) or 'sphinx'
return _no_fn_re.sub('', string) or 'sphinx'
def make_filename_from_project(project: str) -> str:
return make_filename(project_suffix_re.sub('', project)).lower()
return make_filename(project.removesuffix(' Documentation')).lower()
def relpath(path: str | os.PathLike[str],