예제 #1
0
파일: cli.py 프로젝트: wily123/LibreLingo
def cli(input_path, output_path, dry_run):
    """
        Convert a YAML course into a JSON course.
    """
    settings = Settings(dry_run=dry_run, )
    course = load_course(input_path)
    ensure_output_directory(output_path, settings)
    export_course(output_path, course, settings)
예제 #2
0
def test_load_course_output_matches_value(fs):
    fixture_path = os.path.join(os.path.dirname(
        __file__), 'fixtures', "fake_course")
    fs.add_real_directory(fixture_path)
    result = load_course(fixture_path)
    assert result.target_language == Language(
        name="French",
        code="fr"
    )
    assert result.source_language == Language(
        name="English",
        code="en")
    assert result.license == License(name='CC BY 3.0', full_name='CC BY 3.0',
                                     link='https://www.example.com/license')
    assert result.dictionary == [
        DictionaryItem("the man", ["l'homme"], False),
        DictionaryItem("l'homme", ["the man"], True),
        DictionaryItem("the woman", ["la femme"], False),
        DictionaryItem("la femme", ["the woman"], True),
    ]
    assert len(result.modules) == 1
    assert result.modules[0].title == "Basics"
    assert len(result.modules[0].skills) == 1
    assert result.modules[0].skills[0] == Skill(
        name="Hello",
        id=4,
        image_set=["people1", "woman1", "man1"],
        phrases=result.modules[0].skills[0].phrases,
        words=result.modules[0].skills[0].words,
    )
    assert result.modules[0].skills[0].phrases == [
        Phrase(
            in_target_language=['La femme dit bonjour',
                                'la femme dit salut'],
            in_source_language=['The woman says hello',
                                'The woman says hi']),
        Phrase(
            in_target_language=["L'homme dit bonjour",
                                "L'homme dit salut"],
            in_source_language=['The man says hello',
                                'The man says hi'])]

    assert result.modules[0].skills[0].words == [
        Word(
            in_target_language=["l'homme"],
            in_source_language=['the man'],
            pictures=['man1', 'man2', 'man3']
        ),
        Word(
            in_target_language=['la femme', 'la dame'],
            in_source_language=['the woman', 'the female'],
            pictures=None
        )
    ]
    assert result.special_characters == [
        'Ç', 'é', 'â', 'ê', 'î', 'ô', 'û', 'à', 'è', 'ù', 'ë', 'ï', 'ü'
    ]
예제 #3
0
def test_loaded_yaml_is_exported_to_correct_json(fs, snapshot):
    fixture_path = os.path.join(os.path.dirname(
        __file__), 'fixtures', "fake_course")
    fs.add_real_directory(fixture_path)
    fs.create_dir("output")
    course = load_course(fixture_path)
    export_course("./output", course)
    files = glob.glob("./output/**/*")
    data = {
        fname: read_json_file(fname) for fname in files
    }

    fs.pause()  # Write snapshots to the real fs, not the fake
    snapshot.assert_match(data)
예제 #4
0
 def call_function(self):
     self.create_fake_course_meta(self.fake_path, **{
         **self.fake_values,
     })
     self.result = load_course(self.fake_path)