# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           python 1.0
PortGroup           select 1.0

name                py-html2text
version             2019.9.26
revision            0

categories-append   textproc
platforms           darwin
license             GPL-3+
supported_archs     noarch
maintainers         {khindenburg @kurthindenburg} openmaintainer

description         Script to turn HTML into equivalent Markdown-structured text.
long_description \
    html2text is a Python script that converts a page of HTML into clean, \
    easy-to-read plain ASCII text. Better yet, that ASCII also happens to be \
    valid Markdown (a text-to-HTML format).

homepage            https://pypi.python.org/pypi/${python.rootname}
master_sites        pypi:[string index ${python.rootname} 0]/${python.rootname}/
distname            ${python.rootname}-${version}

checksums           rmd160  4acefb71dd07c49b517f0747b8d6db8ea0cbab89 \
                    sha256  6f56057c5c2993b5cc5b347cb099bdf6d095828fef1b53ef4e2a2bf2a1be9b4f \
                    size    48634

python.versions     27 35 36 37 38

if {${name} ne ${subport}} {
    if {${python.version} eq 27} {
        version     2019.8.11
        epoch       1
        revision    0
        distname    ${python.rootname}-${version}
        checksums   rmd160  d7794cb2ca31d02d9359aae569a053be688a1e55 \
                    sha256  f516b9c10284174e2a974d86f91cab02b3cf983a17752075da751af0e895ef5e \
                    size    48721
    }

    depends_lib-append  port:py${python.version}-setuptools

    depends_run-append  port:py-html2text_select

    # Fix permissions
    post-extract {
        system "find ${worksrcpath} -type d -print0 | xargs -0 chmod a+rx"
        system "find ${worksrcpath} -type f -print0 | xargs -0 chmod a+r"
    }

    select.group        py-html2text
    select.file         ${filespath}/py${python.version}-html2text

    depends_test-append port:py${python.version}-pytest

    test.run            yes
    test.env            PYTHONPATH=${worksrcpath}/build/lib
    test.cmd            py.test-${python.branch}

    livecheck.type  none

    notes "
To make the Python ${python.branch} version of py-html2text the one that is run\
when you execute the commands without a version suffix, e.g. 'html2text', run:

port select --set ${select.group} [file tail ${select.file}]
"
}