~lazr-developers/lazr.authentication/trunk

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Colin Watson
  • Date: 2019-11-04 12:53:14 UTC
  • Revision ID: cjwatson@canonical.com-20191104125314-nws01cabv32nghmc
Simplify long description handling using approach from lazr.enum.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# You should have received a copy of the GNU Lesser General Public License
17
17
# along with lazr.authentication.  If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
 
import re
20
 
 
21
19
from setuptools import setup, find_packages
22
20
 
23
21
# generic helpers primarily for the long_description
24
22
def generate(*docname_or_string):
 
23
    marker = '.. pypi description ends here'
25
24
    res = []
26
25
    for value in docname_or_string:
27
26
        if value.endswith('.rst'):
28
27
            with open(value) as f:
29
28
                value = f.read()
30
 
                # toctree is a Sphinx extension.
31
 
                value = re.sub(
32
 
                    r'^\.\. toctree::\n.*?(?=^\S|\Z)', '', value,
33
 
                    flags=re.M | re.S)
 
29
            idx = value.find(marker)
 
30
            if idx >= 0:
 
31
                value = value[:idx]
34
32
        res.append(value)
35
33
        if not value.endswith('\n'):
36
34
            res.append('')