Example #1
0
    def run(self):
        if polib is None:
            print(red(_('package polib is required.')))
            return 1
        module_names = find_packages()
        dst_rel_path = 'locale' if self.dest is None else self.dest
        # group by top-level packages and compute their directories:
        top_levels_modules = {}
        for module_name in module_names:
            top_level = module_name.partition('.')[0]
            if top_level not in top_levels_modules:
                locale_dir = os.path.join(
                    os.path.dirname(load_module(top_level).__file__),
                    dst_rel_path)
                top_levels_modules[top_level] = locale_dir

        for module_name, locale_dir in top_levels_modules.items():
            po_filename = os.path.join(locale_dir, self.language,
                                       'LC_MESSAGES', '%s.po' % module_name)
            if not os.path.isfile(po_filename):
                print(
                    yellow(
                        _('Missing file: %(filename)s. Please run the makemessages -l xx_XX command first.'
                          ) % {'filename': po_filename}))
                continue
            po_content = polib.pofile(po_filename)
            for entry in po_content:
                entry.msgstr = translate_string(entry.msgid)
            print(
                green(
                    _('Processed file: %(filename)s.') %
                    {'filename': po_filename}))
            po_content.save(po_filename)
Example #2
0
    def run(self):
        if polib is None:
            print(red(_('package polib is required.')))
            return 1
        module_names = find_packages()
        dst_rel_path = 'locale' if self.dest is None else self.dest
        # group by top-level packages and compute their directories:
        top_levels_modules = {}
        for module_name in module_names:
            top_level = module_name.partition('.')[0]
            if top_level not in top_levels_modules:
                locale_dir = os.path.join(os.path.dirname(load_module(top_level).__file__), dst_rel_path)
                top_levels_modules[top_level] = locale_dir

        for module_name, locale_dir in top_levels_modules.items():
            po_filename = os.path.join(locale_dir, self.language, 'LC_MESSAGES', '%s.po' % module_name)
            if not os.path.isfile(po_filename):
                print(yellow(_('Missing file: %(filename)s. Please run the makemessages -l xx_XX command first.')
                             % {'filename': po_filename}))
                continue
            po_content = polib.pofile(po_filename)
            for entry in po_content:
                entry.msgstr = translate_string(entry.msgid)
            print(green(_('Processed file: %(filename)s.') % {'filename': po_filename}))
            po_content.save(po_filename)
Example #3
0
    #     '''yes
    # no
    # yes
    # yes''',
    '''no
yes
no''',
]

AVAILABLE_PYTHONS = []
for min_version in ('2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4'):
    popen = subprocess.Popen('which python' + min_version, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = popen.communicate()
    if stdout:
        AVAILABLE_PYTHONS.append(min_version)
print(green('Tests will be done with Python {0}'.format(', '.join(AVAILABLE_PYTHONS))))

if __name__ == '__main__':
    for prefix in STDIN_PREFIXES:
        for min_version in PY_VERSIONS:
            for plugins in PLUGIN_VERSIONS:
                for trans in ('yes', 'no'):
                    data = prefix + "\n" + min_version + "\n" + trans + "\n0.1\n" + plugins + "\n"
                    print(magenta(data))
                    for run_version in AVAILABLE_PYTHONS:
                        print(cyan('Running StarterPyth with ' + run_version))
                        if os.path.isdir(TEST_DIRECTORY):
                            shutil.rmtree(TEST_DIRECTORY)
                        cmd = "python{0} -c 'from starterpyth.core import main; main()'".format(run_version)
                        popen = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                                                 stdin=subprocess.PIPE)