Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Add support for pattern substitutions #9

Closed
ofek opened this issue Sep 4, 2022 · 4 comments · Fixed by #11
Closed

FR: Add support for pattern substitutions #9

ofek opened this issue Sep 4, 2022 · 4 comments · Fixed by #11

Comments

@ofek
Copy link
Contributor

ofek commented Sep 4, 2022

I'm seeing things like this frequently:

# Replace relative paths to images with absolute paths
long_description = re.sub("website/homepage/", "https://raw.githubusercontent.com/gradio-app/gradio/main/website/homepage/", long_description)
long_description = re.sub(r"demo/([\S]*.gif)", r"https://raw.githubusercontent.com/gradio-app/gradio/main/demo/\g<1>", long_description)

maybe:

[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
find = "website/homepage/"
replace = "https://raw.githubusercontent.com/gradio-app/gradio/main/website/homepage/"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
find = 'demo/([\S]*.gif)'
replace = 'https://raw.githubusercontent.com/gradio-app/gradio/main/demo/\g<1>'
@hynek
Copy link
Owner

hynek commented Sep 5, 2022

Yeah this has been on my todo list since someone asked about https://github.com/twisted/twisted/blob/eda9d29dc7fe34e7b207781e5674dc92f798bffe/setup.py#L19-L24

@ofek
Copy link
Contributor Author

ofek commented Sep 6, 2022

pydantic just switched and would use this pydantic/pydantic#4473 (comment)

history = (THIS_DIR / 'HISTORY.md').read_text(encoding='utf-8')
history = re.sub(r'#(\d+)', r'[#\1](https://github.com/pydantic/pydantic/issues/\1)', history)
history = re.sub(r'( +)@([\w\-]+)', r'\1[@\2](https://github.com/\2)', history, flags=re.I)
history = re.sub('@@', '@', history)

long_description = (THIS_DIR / 'README.md').read_text(encoding='utf-8') + '\n\n' + history

@hynek hynek mentioned this issue Sep 8, 2022
@hynek hynek closed this as completed in #11 Sep 9, 2022
@hynek
Copy link
Owner

hynek commented Sep 10, 2022

BTW any idea what that @@, @ is about? I can't find any @@ in their history.md?

@ofek
Copy link
Contributor Author

ofek commented Sep 10, 2022

People do weird things 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants