# Path: textblob_de/compat.py
# PY2 = int(sys.version[0]) == 2
# PY26 = PY2 and int(sys.version_info[1]) < 7
#     def implements_to_string(cls):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def decode_string(v, encoding="utf-8"):
# def encode_string(v, encoding="utf-8"):
# def get_external_executable(_exec):
# def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None):
#     def _access_check(fn, mode):
#     class metaclass(meta):


import os
import re
import subprocess
import time
from textblob_de.compat import _open, get_external_executable
def get_credits():
    """Extract credits from `AUTHORS.rst`"""
    credits = read(os.path.join(_HERE, "AUTHORS.rst")).split("\n")
    from_index = credits.index("Active Contributors")
    credits = "\n".join(credits[from_index + 2:])
    return credits


def rst2markdown_github(path_to_rst, path_to_md, pandoc="pandoc"):
    """
    Converts ``rst`` to **markdown_github**, using :program:`pandoc`

    **Input**

        * ``FILE.rst``

    **Output**

        * ``FILE.md``

    """
    _proc = subprocess.Popen([pandoc, "-f", "rst",
                              "-t", "markdown_github",
                              #"-o", path_to_md,
                              path_to_rst],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
    print("Converting README.rst to markdown_github, "
          "using 'pandoc' ...")
    _stdout, _stderr = _proc.communicate()

# Path: textblob_de/compat.py
# PY2 = int(sys.version[0]) == 2
# PY26 = PY2 and int(sys.version_info[1]) < 7
#     def implements_to_string(cls):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def decode_string(v, encoding="utf-8"):
# def encode_string(v, encoding="utf-8"):
# def get_external_executable(_exec):
# def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None):
#     def _access_check(fn, mode):
#     class metaclass(meta):


# Path: prepare_docs.py
import os
import re
import subprocess
import time
from textblob_de.compat import _open, get_external_executable

def get_credits():
    """Extract credits from `AUTHORS.rst`"""
    credits = read(os.path.join(_HERE, "AUTHORS.rst")).split("\n")
    from_index = credits.index("Active Contributors")
    credits = "\n".join(credits[from_index + 2:])
    return credits


def rst2markdown_github(path_to_rst, path_to_md, pandoc="pandoc"):
    """
    Converts ``rst`` to **markdown_github**, using :program:`pandoc`

    **Input**

        * ``FILE.rst``

    **Output**

        * ``FILE.md``

    """
    _proc = subprocess.Popen([pandoc, "-f", "rst",
                              "-t", "markdown_github",
                              #"-o", path_to_md,
                              path_to_rst],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
    print("Converting README.rst to markdown_github, "
          "using 'pandoc' ...")
    _stdout, _stderr = _proc.communicate()

    with _open(path_to_md, "w", encoding="utf-8") as _md: