Exemplo n.º 1
0
def test_collect_files_using_filter():
    assert collect_files('tests/fixtures/folder-iteration', '.m4a') == [
        Path('tests/fixtures/folder-iteration/1 first.m4a')
    ]
    assert collect_files('tests/fixtures/folder-iteration', ['.m4a']) == [
        Path('tests/fixtures/folder-iteration/1 first.m4a')
    ]
Exemplo n.º 2
0
def test_collect_files_using_folder():
    # TODO test expanddir()
    assert collect_files(Path('tests/fixtures/folder-iteration')) == [
        Path('tests/fixtures/folder-iteration/1 first.m4a'),
        Path('tests/fixtures/folder-iteration/2 second.mp3'),
        Path('tests/fixtures/folder-iteration/3 third.mp4')
    ]
Exemplo n.º 3
0
Arquivo: main.py Projeto: Hadryan/apit
def main(options) -> int:
    configure_logging(options.verbose_level)

    logging.info('CLI options: %s', options)

    files = collect_files(options.path, FILE_FILTER)
    if len(files) == 0:
        raise ApitError('No matching files found')
    logging.info('Input path: %s', options.path)

    options.cache_path = Path(CACHE_PATH).expanduser()

    ActionType: Type[Action] = find_action_type(options.command, AVAILAIBLE_ACTIONS)

    action_options: Dict[str, Any] = ActionType.to_action_options(options)
    actions: List[Action] = [ActionType(file, action_options) for file in files]

    if any_action_needs_confirmation(actions):
        print_actions_preview(actions)
        ask_user_for_confirmation()

    for action in actions:
        action.apply()

    print_report(actions)
    return 0 if all_actions_successful(actions) else 1
Exemplo n.º 4
0
Arquivo: main.py Projeto: wschott/apit
def main(options) -> int:
    configure_logging(options.verbose_level)

    logging.info('CLI options: %s', options)

    files = collect_files(options.path, FILE_FILTER)
    if len(files) == 0:
        raise ApitError('No matching files found')
    logging.info('Input path: %s', options.path)

    options.cache_path = Path(CACHE_PATH).expanduser()

    CommandType: Type[Command] = determine_command_type(options.command)
    return CommandType().execute(files, options)
Exemplo n.º 5
0
def test_collect_files():
    assert collect_files('tests/fixtures/folder-iteration') == [
        Path('tests/fixtures/folder-iteration/1 first.m4a'),
        Path('tests/fixtures/folder-iteration/2 second.mp3'),
        Path('tests/fixtures/folder-iteration/3 third.mp4')
    ]
Exemplo n.º 6
0
def test_collect_files_using_non_existing_folder():
    with pytest.raises(ApitError, match='Invalid path'):
        collect_files(Path('./non-existing'))
Exemplo n.º 7
0
def test_collect_files_using_single_file():
    assert collect_files(
        Path('tests/fixtures/folder-iteration/1 first.m4a')) == [
            Path('tests/fixtures/folder-iteration/1 first.m4a'),
        ]