Ejemplo n.º 1
0
def main(buildout_dir, package_name, i18n_domain,
         package_namespace, package_dir):
    assert buildout_dir, 'missing compulsory argument buildout_dir'
    assert package_name, 'missing compulsory argument package_name'

    parser = argparse.ArgumentParser(sys.argv[0])
    parser.add_argument('--version', action='version',
                        version='%%(prog)s %s' % version())
    parser.add_argument('new_languages', nargs='*')
    arguments = parser.parse_args()

    new_languages = arguments.new_languages or []

    if not i18n_domain:
        i18n_domain = package_name
    if not package_dir:
        package_dir = find_package_directory(buildout_dir, package_name,
                                             package_namespace)

    package_root = buildout_dir
    build_translations(package_dir, package_root, i18n_domain, new_languages)
Ejemplo n.º 2
0
def main(buildout_dir, package_name, i18n_domain, package_namespace,
         package_dir):
    assert buildout_dir, 'missing compulsory argument buildout_dir'
    assert package_name, 'missing compulsory argument package_name'

    parser = argparse.ArgumentParser(sys.argv[0])
    parser.add_argument('--version',
                        action='version',
                        version='%%(prog)s %s' % version())
    parser.add_argument('new_languages', nargs='*')
    arguments = parser.parse_args()

    new_languages = arguments.new_languages or []

    if not i18n_domain:
        i18n_domain = package_name
    if not package_dir:
        package_dir = find_package_directory(buildout_dir, package_name,
                                             package_namespace)

    package_root = buildout_dir
    build_translations(package_dir, package_root, i18n_domain, new_languages)
Ejemplo n.º 3
0
 def test_package_namespace_has_precedence(self):
     os.makedirs(os.path.join(self.tempdir, 'my/package'))
     directory = find_package_directory(self.tempdir, 'my', 'my.package')
     self.assertEqual(os.path.join(self.tempdir, 'my/package'), directory)
Ejemplo n.º 4
0
 def test_find_package_directory_in_custom_namespace_folder(self):
     os.makedirs(os.path.join(self.tempdir, 'my/package'))
     directory = find_package_directory(self.tempdir, 'foo.bar', 'my.package')
     self.assertEqual(os.path.join(self.tempdir, 'my/package'), directory)
Ejemplo n.º 5
0
    def test_find_package_directory_in_default_namespace_folder(self):
        os.makedirs(os.path.join(self.tempdir, 'src/foo.bar/foo/bar'))

        directory = find_package_directory(self.tempdir, 'foo.bar', None)
        self.assertEqual(os.path.join(self.tempdir, 'src/foo.bar/foo/bar'),
                         directory)
Ejemplo n.º 6
0
    def test_find_package_directory(self):
        os.makedirs(os.path.join(self.tempdir, 'foo/bar'))

        directory = find_package_directory(self.tempdir, 'foo.bar', None)
        self.assertEqual(os.path.join(self.tempdir, 'foo/bar'), directory)