コード例 #1
0
ファイル: test_file_handling.py プロジェクト: Hadryan/apit
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')
    ]
コード例 #2
0
ファイル: test_file_handling.py プロジェクト: wschott/apit
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')
    ]
コード例 #3
0
ファイル: main.py プロジェクト: 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
コード例 #4
0
ファイル: main.py プロジェクト: 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)
コード例 #5
0
ファイル: test_file_handling.py プロジェクト: Hadryan/apit
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')
    ]
コード例 #6
0
ファイル: test_file_handling.py プロジェクト: wschott/apit
def test_collect_files_using_non_existing_folder():
    with pytest.raises(ApitError, match='Invalid path'):
        collect_files(Path('./non-existing'))
コード例 #7
0
ファイル: test_file_handling.py プロジェクト: wschott/apit
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'),
        ]