Ejemplo n.º 1
0
def aggregate(inputdir, outputdir, ext=False, all=False):
    ap = AggregatesParser()

    # make sure platform-lang is the first one on the sorted list of results
    main_res = ap.load(os.path.join(inputdir, MAIN_LANG_MODULE_PATH), 'nuxeo')
    ext_res = ap.load(inputdir, 'nuxeo', excluded_dirs=[MAIN_LANG_MODULE_PATH])

    langs = DEFAULT_LANGS
    if all is True:
        langs = ALL_LANGS
    elif ext is True:
        langs = EXT_LANGS

    aggs = []
    for lang in langs:
        lang_paths = []
        if lang in main_res:
            lang_paths.extend(main_res[lang])
        if lang in ext_res:
            ext_paths = ext_res[lang]
            ext_paths.sort()
            lang_paths.extend(ext_paths)
        if len(lang_paths) > 0:
            lang_vals = langs[lang]
            aggs.append(
                Aggregate(os.path.join(lang_vals[1], lang_vals[0]),
                          lang_paths))

    MessagesManager(aggs).aggregate(outputdir)
def aggregate(inputdir, outputdir, ext=False, all=False):
    ap = AggregatesParser()

    # make sure platform-lang is the first one on the sorted list of results
    main_res = ap.load(os.path.join(inputdir, MAIN_LANG_MODULE_PATH), "nuxeo")
    ext_res = ap.load(inputdir, "nuxeo", excluded_dirs=[MAIN_LANG_MODULE_PATH])

    langs = DEFAULT_LANGS
    if all is True:
        langs = ALL_LANGS
    elif ext is True:
        langs = EXT_LANGS

    aggs = []
    for lang in langs:
        lang_paths = []
        if lang in main_res:
            lang_paths.extend(main_res[lang])
        if lang in ext_res:
            ext_paths = ext_res[lang]
            ext_paths.sort()
            lang_paths.extend(ext_paths)
        if len(lang_paths) > 0:
            lang_vals = langs[lang]
            aggs.append(Aggregate(os.path.join(lang_vals[1], lang_vals[0]), lang_paths))

    MessagesManager(aggs).aggregate(outputdir)
Ejemplo n.º 3
0
 def test_parser_multiple(self):
     ap = AggregatesParser(crowdin='crowdin_multiple.ini')
     res = ap.load('test/data', 'nuxeo')
     assert_equal(1, len(res))
     assert_true('en_US' in res)
     assert_equal(2, len(res['en_US']))
     assert_equal('test/data/addon/messages_en_US.properties', res['en_US'][0])
     assert_equal('test/data/addon/messages_en_US_from_addon.properties', res['en_US'][1])
Ejemplo n.º 4
0
 def test_parser_nuxeo_project_no_addon(self):
     ap = AggregatesParser()
     res = ap.load('test/data/nuxeo', 'nuxeo')
     assert_equal(3, len(res))
     assert_true('en_US' in res)
     assert_equal(2, len(res['en_US']))
     assert_equal('test/data/nuxeo/nuxeo-features/nuxeo-platform-lang/messages_en_US.properties', res['en_US'][0])
     assert_equal('test/data/nuxeo/nuxeo-other/messages_en_US.properties', res['en_US'][1])
Ejemplo n.º 5
0
 def test_parser_nuxeo_project(self):
     ap = AggregatesParser()
     res = ap.load('test/data', 'nuxeo')
     assert_equal(3, len(res))
     assert_true('en_US' in res)
     assert_equal(3, len(res['en_US']))
     assert_equal('test/data/addon/messages_en_US.properties', res['en_US'][0])
     assert_equal('test/data/nuxeo/nuxeo-features/nuxeo-platform-lang/messages_en_US.properties', res['en_US'][1])
     assert_equal('test/data/nuxeo/nuxeo-other/messages_en_US.properties', res['en_US'][2])
     assert_true('fr_FR' in res)
     assert_equal(1, len(res['fr_FR']))
     assert_equal('test/data/nuxeo/nuxeo-features/nuxeo-platform-lang/messages_fr_FR.properties', res['fr_FR'][0])
     assert_true('pt_BR' in res)
     assert_equal(1, len(res['pt_BR']))
     assert_equal('test/data/nuxeo/addons/nuxeo-platform-lang-ext/messages_pt_BR.properties', res['pt_BR'][0])
Ejemplo n.º 6
0
 def test_parser_none_project(self):
     ap = AggregatesParser()
     res = ap.load('test/data', None)
     assert_equal(0, len(res))