From b5867a85362f9cb8c02ecf1668aa2dd2ffee6d0e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 24 Oct 2020 16:31:31 +0300 Subject: script to convert README for PYPI --- scripts/internal/convert_readme.py | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 scripts/internal/convert_readme.py (limited to 'scripts') 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 `_ +- `Install `_ +- `Documentation `_ +- `Download `_ +- `Forum `_ +- `StackOverflow `_ +- `Blog `_ +- `What's new `_ +""" + +funding = """\ +Sponsors +======== + +.. image:: https://github.com/giampaolo/psutil/raw/master/docs/_static/tidelift-logo.png + :width: 200 + :alt: Alternative text + +`Add your logo `__. + +Example usages""" + + +def main(): + with open(sys.argv[1]) as f: + data = f.read() + data = re.sub(r".. raw:: html\n+\s+
", summary, data) + data = re.sub(r"Sponsors\n========[\s\S]*?Example usages", funding, data) + print(data) + + +if __name__ == '__main__': + main() -- cgit v1.2.1