# Path: starterpyth/log.py
# GREEN = '32'
# 
# YELLOW = '33'
# 
# RED = '31'
# 
# Path: starterpyth/log.py
# def display(text, color=None, bold=False, newline=True):
#     if not isinstance(text, text_type):
#         text = text.decode('utf-8')
#     if bold and color:
#         text = u("\033[1;{0}m{1}\033[0m").format(color, text)
#     text = u("\033[{0}m{1}\033[0m").format(color, text)
#     if newline:
#         text += u('\n')
#     end = u('')
#     if __encode_stdout:
#         text = text.encode('utf-8')
#         end = b('')
#     print_(text, end=end)
# 
# Path: starterpyth/translation.py
# def __find(domain, locale_module, localedir='locale', languages=None):
# def translation(domain, locale_module, localedir='locale', languages=None, class_=None, fallback=False):
# __TRANS = translation(parent_package, parent_package, fallback=True)


from starterpyth.log import GREEN, YELLOW, RED
from starterpyth.log import display
from starterpyth.translation import gettext as _
from distutils.core import Command
import os
import shlex
import shutil
import subprocess
    import sphinx
    def initialize_options(self):
        pass

    def finalize_options(self):
        self.build_dir = os.path.abspath(self.build_dir)
        self.doc_dir = os.path.abspath(self.doc_dir)

    def run(self):
        if sphinx is None:
            display(_('package sphinx is required.'), color=RED)
            return 1
        if self.clean and os.path.isdir(self.build_dir):
            msg = _('removing %(dir)s') % {'dir': self.build_dir}
            display(msg, color=GREEN)
            shutil.rmtree(self.build_dir)
        sphinx_opts = shlex.split(self.ALLSPHINXOPTS % (self.build_dir, os.getenv('SPHINXOPTS') or '', self.doc_dir))
        count = 0
        for orig_fmt, txt in self.outputs.items():
            fmt = 'latex' if orig_fmt == 'latexpdf' else orig_fmt
            if orig_fmt not in self.distribution.command_options['gen_doc']:
                continue
            count = 1
            options = ['sphinx-build', '-b', fmt, ] + sphinx_opts + [os.path.join(self.build_dir, fmt), ]
            result = sphinx.main(options)
            if result == 0:
                msg = txt % self.build_dir
                display(msg, color=GREEN)
                if orig_fmt == 'latexpdf':
                    subprocess.check_call('make -C %s/latex all-pdf' % self.build_dir, shell=True)
                    msg = "pdflatex finished; the PDF files are in %s/latex." % self.build_dir

# Path: starterpyth/log.py
# GREEN = '32'
# 
# YELLOW = '33'
# 
# RED = '31'
# 
# Path: starterpyth/log.py
# def display(text, color=None, bold=False, newline=True):
#     if not isinstance(text, text_type):
#         text = text.decode('utf-8')
#     if bold and color:
#         text = u("\033[1;{0}m{1}\033[0m").format(color, text)
#     text = u("\033[{0}m{1}\033[0m").format(color, text)
#     if newline:
#         text += u('\n')
#     end = u('')
#     if __encode_stdout:
#         text = text.encode('utf-8')
#         end = b('')
#     print_(text, end=end)
# 
# Path: starterpyth/translation.py
# def __find(domain, locale_module, localedir='locale', languages=None):
# def translation(domain, locale_module, localedir='locale', languages=None, class_=None, fallback=False):
# __TRANS = translation(parent_package, parent_package, fallback=True)


# Path: starterpyth/commands/gen_doc.py
from starterpyth.log import GREEN, YELLOW, RED
from starterpyth.log import display
from starterpyth.translation import gettext as _
from distutils.core import Command
import os
import shlex
import shutil
import subprocess
    import sphinx

    def initialize_options(self):
        pass

    def finalize_options(self):
        self.build_dir = os.path.abspath(self.build_dir)
        self.doc_dir = os.path.abspath(self.doc_dir)

    def run(self):
        if sphinx is None:
            display(_('package sphinx is required.'), color=RED)
            return 1
        if self.clean and os.path.isdir(self.build_dir):
            msg = _('removing %(dir)s') % {'dir': self.build_dir}
            display(msg, color=GREEN)
            shutil.rmtree(self.build_dir)
        sphinx_opts = shlex.split(self.ALLSPHINXOPTS % (self.build_dir, os.getenv('SPHINXOPTS') or '', self.doc_dir))
        count = 0
        for orig_fmt, txt in self.outputs.items():
            fmt = 'latex' if orig_fmt == 'latexpdf' else orig_fmt
            if orig_fmt not in self.distribution.command_options['gen_doc']:
                continue
            count = 1
            options = ['sphinx-build', '-b', fmt, ] + sphinx_opts + [os.path.join(self.build_dir, fmt), ]
            result = sphinx.main(options)
            if result == 0:
                msg = txt % self.build_dir
                display(msg, color=GREEN)
                if orig_fmt == 'latexpdf':
                    subprocess.check_call('make -C %s/latex all-pdf' % self.build_dir, shell=True)
                    msg = "pdflatex finished; the PDF files are in %s/latex." % self.build_dir

                    display(msg, color=GREEN)