def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)"
        )
        sys.exit(1)

    filename = tempfile.mktemp(".html")
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py("--long-description"))
    warnings = io.StringIO()
    html = render(longdesc, warnings)
    if html is None:
        logging.error("Error generating html. Invalid ReST.")
        rst_filename = tempfile.mktemp(".rst")
        with open(rst_filename, "wb") as rst_file:
            rst_file.write(longdesc.encode("utf-8"))
        warning_text = warnings.getvalue()
        warning_text = warning_text.replace("<string>", rst_filename)
        print(warning_text)
        sys.exit(1)

    if "<html" not in html[:20]:
        # Add a html declaration including utf-8 indicator
        html = HTML_PREFIX + html + HTML_POSTFIX

    with open(filename, "wb") as fh:
        fh.write(html.encode("utf-8"))

    url = "file://" + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#2
0
def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)")
        sys.exit(1)

    filename = tempfile.mktemp('.html')
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py('--long-description'))
    warnings = io.StringIO()
    html, rendered = render(longdesc, warnings)
    if not rendered:
        logging.error(
            'Error generating html. Invalid ReST.')
        print(warnings.getvalue())
        sys.exit(1)

    with open(filename, 'wb') as fh:
        fh.write(html.encode('utf-8'))

    url = 'file://' + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#3
0
def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)")
        sys.exit(1)

    filename = tempfile.mktemp('.html')
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py('--long-description'))
    warnings = io.StringIO()
    html = render(longdesc, warnings)
    if html is None:
        logging.error('Error generating html. Invalid ReST.')
        rst_filename = tempfile.mktemp('.rst')
        with open(rst_filename, 'wb') as rst_file:
            rst_file.write(longdesc.encode('utf-8'))
        warning_text = warnings.getvalue()
        warning_text = warning_text.replace('<string>', rst_filename)
        print(warning_text)
        sys.exit(1)

    if not '<html' in html[:20]:
        # Add a html declaration including utf-8 indicator
        html = HTML_PREFIX + html + HTML_POSTFIX

    with open(filename, 'wb') as fh:
        fh.write(html.encode('utf-8'))

    url = 'file://' + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#4
0
def test_rst_fixtures(rst_filename, html_filename):
    # Get our Markup
    with codecs.open(rst_filename, encoding='utf-8') as f:
        rst_markup = f.read()

    # Get our expected
    with codecs.open(html_filename, encoding="utf-8") as f:
        expected = f.read()

    out, rendered = render(rst_markup)

    assert out == expected
    assert rendered == ("<" in expected)
示例#5
0
def test_rst_fixtures(rst_filename, html_filename):
    # Get our Markup
    with io.open(rst_filename, encoding='utf-8') as f:
        rst_markup = f.read()

    # Get our expected
    with io.open(html_filename, encoding="utf-8") as f:
        expected = f.read()

    out, rendered = render(rst_markup)

    assert out == expected
    assert rendered == ("<" in expected)
示例#6
0
    def check_restructuredtext(self):
        """
        Checks if the long string fields are reST-compliant.
        """
        data = self.distribution.get_long_description()
        stream = io.StringIO()
        markup, rendered = render(data, stream=stream)

        for line in stream.getvalue().splitlines():
            if line.startswith("<string>"):
                line = line[8:]
            self.warn(line)

        if not rendered:
            self.warn("Invalid markup which will not be rendered on PyPI.")
示例#7
0
    def check_restructuredtext(self):
        """
        Checks if the long string fields are reST-compliant.
        """
        data = self.distribution.get_long_description()
        stream = io.StringIO()
        markup = render(data, stream=stream)

        for line in stream.getvalue().splitlines():
            if line.startswith("<string>"):
                line = line[8:]
            self.warn(line)

        if markup is None:
            self.warn("Invalid markup which will not be rendered on PyPI.")
示例#8
0
def test_rst_fixtures(rst_filename, html_filename):
    # Get our Markup
    with io.open(rst_filename, encoding='utf-8') as f:
        rst_markup = f.read()

    # Get our expected
    with io.open(html_filename, encoding="utf-8") as f:
        expected = f.read()

    out = render(rst_markup)

    if "<" in expected:
        assert out == expected
    else:
        assert out is None
示例#9
0
def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)")
        sys.exit(1)

    filename = tempfile.mktemp('.html')
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py('--long-description'))
    warnings = io.StringIO()
    html, rendered = render(longdesc, warnings)
    if not rendered:
        logging.error('Error generating html. Invalid ReST.')
        print(warnings.getvalue())
        sys.exit(1)

    with open(filename, 'wb') as fh:
        fh.write(html.encode('utf-8'))

    url = 'file://' + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#10
0
def test_rst_002():
    assert render('http://mymalicioussite.com/') == (
        ('<p><a href="http://mymalicioussite.com/" rel="nofollow">' +
         'http://mymalicioussite.com/</a></p>\n'), True)
示例#11
0
def test_rst_001():
    assert render('Hello') == ('<p>Hello</p>\n', True)
示例#12
0
def test_rst_002():
    assert render('http://mymalicioussite.com/') == (
        ('<p><a href="http://mymalicioussite.com/" rel="nofollow">' +
         'http://mymalicioussite.com/</a></p>\n'),
        True)
示例#13
0
def test_rst_001():
    assert render('Hello') == ('<p>Hello</p>\n', True)