diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-24 16:31:31 +0300 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-24 16:31:31 +0300 |
commit | b5867a85362f9cb8c02ecf1668aa2dd2ffee6d0e (patch) | |
tree | 88b07f8123a7d57135682360bc5eef7a659ae421 /scripts | |
parent | 6d42d4949faa2acd0a8e4f55f6472f641ee90199 (diff) | |
download | psutil-b5867a85362f9cb8c02ecf1668aa2dd2ffee6d0e.tar.gz |
script to convert README for PYPI
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/internal/convert_readme.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/internal/convert_readme.py b/scripts/internal/convert_readme.py new file mode 100755 index 00000000..d6cae918 --- /dev/null +++ b/scripts/internal/convert_readme.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Convert README.rst format to make it compatible with PyPI (no raw html). +""" + +import re +import sys + +summary = """\ +Quick links +=========== + +- `Home page <https://github.com/giampaolo/psutil>`_ +- `Install <https://github.com/giampaolo/psutil/blob/master/INSTALL.rst>`_ +- `Documentation <http://psutil.readthedocs.io>`_ +- `Download <https://pypi.org/project/psutil/#files>`_ +- `Forum <http://groups.google.com/group/psutil/topics>`_ +- `StackOverflow <https://stackoverflow.com/questions/tagged/psutil>`_ +- `Blog <https://gmpy.dev/tags/psutil>`_ +- `What's new <https://github.com/giampaolo/psutil/blob/master/HISTORY.rst>`_ +""" + +funding = """\ +Sponsors +======== + +.. image:: https://github.com/giampaolo/psutil/raw/master/docs/_static/tidelift-logo.png + :width: 200 + :alt: Alternative text + +`Add your logo <https://github.com/sponsors/giampaolo>`__. + +Example usages""" + + +def main(): + with open(sys.argv[1]) as f: + data = f.read() + data = re.sub(r".. raw:: html\n+\s+<div align[\s\S]*?/div>", summary, data) + data = re.sub(r"Sponsors\n========[\s\S]*?Example usages", funding, data) + print(data) + + +if __name__ == '__main__': + main() |