Пример #1
0
def makerc(qrc_files, recursive, verbose):
    """Generate python module for corresponding given qrc files.

    Args:
        qrc_files (tuple): Paths to qrc files that need to generate its
            corresponding rc files.
        recursive (bool): If True, search recursively qrc filed from launching
            directory.
        verbose (bool): Boolean determining if messages will be displayed.

    """
    # Check all qrc files recursively
    if recursive:
        recursive_qrc_files = recursive_file_search("qrc")

        # Check if recursive option find qrc files
        if not recursive_qrc_files:
            v.error("Could not find any qrc files")
        else:
            generate_rc(recursive_qrc_files, verbose)

    # Process given files or warns user if none
    if qrc_files:
        generate_rc(qrc_files, verbose)
    elif not recursive:
        v.warning("No qrc files was given to process.")
Пример #2
0
def makealias(qrc_files, recursive, verbose):
    """Command to generate aliases for each resources contained in qrc files.

    Args:
        qrc_files (tuple): Paths to qrc files that need to generate alias.
        recursive (bool): If True, search recursively qrc filed from launching
            directory.
        verbose (bool): Boolean determining if messages will be displayed.

    """
    # Check all qrc files recursively
    if recursive:
        recursive_qrc_files = recursive_file_search("qrc")

        # Check if recursive option find qrc files
        if not recursive_qrc_files:
            v.error("Could not find any qrc files.")
            raise click.Abort()
        else:
            write_alias(recursive_qrc_files, verbose)

    # Process given files or warns user if none
    if qrc_files:
        write_alias(qrc_files, verbose)
    elif not recursive:
        v.warning("No qrc files was given to process.")
Пример #3
0
def test_search_mp3_in_different_directories(test_resources):
    mp3_files = recursive_file_search("mp3", "resources")
    assert sorted(mp3_files) == [
        "resources/musics/solos/best/best_solo1.mp3",
        "resources/musics/solos/best/best_solo2.mp3",
        "resources/musics/solos/solo1.mp3",
        "resources/musics/solos/solo2.mp3",
    ]
Пример #4
0
def update(config, qrc_files, project, verbose):
    """Update project's qrc files through information stored in config file.

    Args:
        config (:class:`PyqtcliConfig`): PyqtcliConfig object representing
            project config file.
        qrc_files (tuple): Paths to qrc files that need to get updated.
        project (bool): If True, all registered qrc files will be updated.
        verbose (bool): Boolean determining if messages will be displayed.

    """
    if project:
        recursive_qrc_files = recursive_file_search("qrc")
        update_project(recursive_qrc_files, config, verbose)
        generate_rc(recursive_qrc_files, verbose)

    elif qrc_files:
        update_project(qrc_files, config, verbose)
        generate_rc(qrc_files, verbose)

    else:
        v.warning("No qrc files to update")
Пример #5
0
def test_search_files_in_nonexistent_directory():
    with pytest.raises(FileNotFoundError) as e:
        recursive_file_search("txt", "nonexistent")
    assert str(e.value) == "No such directory: 'nonexistent'"