# Path: starterpyth/log.py
# RED = '31'
# 
# 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)
# 
# YELLOW = '33'
# 
# GREEN = '32'
# 
# Path: starterpyth/core.py
# def load_module(modulename):
#     parents = modulename.split('.')
#     path = sys.path
#     module = None
#     abs_module_name = ''
#     cwd = os.getcwd()
#     for module_name in parents:
#         (file_, pathname, description) = imp.find_module(module_name, path)
#         name_to_import = abs_module_name + module_name
#         if name_to_import in sys.modules:
#             module = sys.modules[name_to_import]
#         else:
#             module = imp.load_module(name_to_import, file_, pathname, description)
#         path = [os.path.dirname(module.__file__)]
#         abs_module_name += module_name + '.'
#     os.chdir(cwd)
#     return module
# 
# 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)


import codecs
import datetime
import os
import subprocess
from distutils.core import Command
from starterpyth.log import RED, display, YELLOW, GREEN
    from jinja2 import Environment, PackageLoader
from setuptools import find_packages
from starterpyth.core import load_module
from starterpyth.translation import gettext as _
            for module_name in module_names:
                init_filename = load_module(module_name).__file__
                local_root = os.path.dirname(init_filename)
                for filename in os.listdir(local_root):
                    filename = os.path.join(local_root, filename)
                    basename, sepa, ext = filename.rpartition('.')
                    if ext not in ('py', 'pyx', 'c'):
                        continue
                    try:
                        po_fd = codecs.open(filename, 'r', encoding='utf-8')
                        po_fd.read()
                        po_fd.close()
                        filenames.append(os.path.relpath(filename, root_path))
                        msg = _('%(filename)s added.') % {'filename': filename}
                        display(msg, color=GREEN)
                    except UnicodeDecodeError:
                        msg = _('Encoding of %(filename)s is not UTF-8.') % {'filename': filename}
                        display(msg, color=GREEN)
            cmd = ['xgettext', '--language=Python', '--keyword=_', '--output=%s' % pot_filename,
                   '--from-code=UTF-8', '--add-comments=Translators', ] + filenames
            subprocess.check_call(cmd, stdout=subprocess.PIPE)
            if os.path.isfile(po_filename):
                cmd = ['msgmerge', '--update', '--backup=off', po_filename, pot_filename, ]
            else:
                cmd = ['msginit', '--no-translator', '-l', self.language, '--input=%s' % pot_filename,
                       '--output=%s' % po_filename, ]
            subprocess.check_call(cmd, stderr=subprocess.PIPE)
            msg = _('Please translate strings in %(filename)s') % {'filename': po_filename}
            display(msg, color=YELLOW)
            msg = _('Then run setup.py compilemessages -l %(lang)s') % {'lang': self.language}

# Path: starterpyth/log.py
# RED = '31'
# 
# 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)
# 
# YELLOW = '33'
# 
# GREEN = '32'
# 
# Path: starterpyth/core.py
# def load_module(modulename):
#     parents = modulename.split('.')
#     path = sys.path
#     module = None
#     abs_module_name = ''
#     cwd = os.getcwd()
#     for module_name in parents:
#         (file_, pathname, description) = imp.find_module(module_name, path)
#         name_to_import = abs_module_name + module_name
#         if name_to_import in sys.modules:
#             module = sys.modules[name_to_import]
#         else:
#             module = imp.load_module(name_to_import, file_, pathname, description)
#         path = [os.path.dirname(module.__file__)]
#         abs_module_name += module_name + '.'
#     os.chdir(cwd)
#     return module
# 
# 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/makemessages.py
import codecs
import datetime
import os
import subprocess
from distutils.core import Command
from starterpyth.log import RED, display, YELLOW, GREEN
    from jinja2 import Environment, PackageLoader
from setuptools import find_packages
from starterpyth.core import load_module
from starterpyth.translation import gettext as _

            for module_name in module_names:
                init_filename = load_module(module_name).__file__
                local_root = os.path.dirname(init_filename)
                for filename in os.listdir(local_root):
                    filename = os.path.join(local_root, filename)
                    basename, sepa, ext = filename.rpartition('.')
                    if ext not in ('py', 'pyx', 'c'):
                        continue
                    try:
                        po_fd = codecs.open(filename, 'r', encoding='utf-8')
                        po_fd.read()
                        po_fd.close()
                        filenames.append(os.path.relpath(filename, root_path))
                        msg = _('%(filename)s added.') % {'filename': filename}
                        display(msg, color=GREEN)
                    except UnicodeDecodeError:
                        msg = _('Encoding of %(filename)s is not UTF-8.') % {'filename': filename}
                        display(msg, color=GREEN)
            cmd = ['xgettext', '--language=Python', '--keyword=_', '--output=%s' % pot_filename,
                   '--from-code=UTF-8', '--add-comments=Translators', ] + filenames
            subprocess.check_call(cmd, stdout=subprocess.PIPE)
            if os.path.isfile(po_filename):
                cmd = ['msgmerge', '--update', '--backup=off', po_filename, pot_filename, ]
            else:
                cmd = ['msginit', '--no-translator', '-l', self.language, '--input=%s' % pot_filename,
                       '--output=%s' % po_filename, ]
            subprocess.check_call(cmd, stderr=subprocess.PIPE)
            msg = _('Please translate strings in %(filename)s') % {'filename': po_filename}
            display(msg, color=YELLOW)
            msg = _('Then run setup.py compilemessages -l %(lang)s') % {'lang': self.language}

            display(msg, color=YELLOW)