コード例 #1
0
ファイル: gui.py プロジェクト: Nooby/episode_renamer
    def rename(self):
        files = []

        for itemIndex in xrange(self.model.rowCount()):
            item = self.model.item(itemIndex)
            if item.checkState() == QtCore.Qt.Checked:
                files.append(item.rename_info)

        old_order, errors = utils.rename(files, 'yes')
        self.model.clear()
        self.buttonBox.accepted.disconnect()

        utils.save_renamed_file_info(old_order, Settings.title)

        self.print_renamed_files(errors)
コード例 #2
0
    def rename(self):
        files = []

        for itemIndex in xrange(self.model.rowCount()):
            item = self.model.item(itemIndex)
            if item.checkState() == QtCore.Qt.Checked:
                files.append(item.rename_info)

        old_order, errors = utils.rename(files, 'yes')
        self.model.clear()
        self.buttonBox.accepted.disconnect()

        utils.save_renamed_file_info(old_order, Settings.title)

        self.print_renamed_files(errors)
コード例 #3
0
ファイル: main.py プロジェクト: Nooby/episode_renamer
def do_rename(files):
    files = [(old, new) if old != new else None for old, new in files]
    print_renamed_files(files)
    files = [t for t in files if t]

    if not files:
        print("No changes to files were needed")
        sys.exit(1)

    old_order, errors = utils.rename(files)

    utils.save_renamed_file_info(old_order, Settings.title)

    if not old_order:
        print ("Changes were not committed to the files")
    elif not errors:
        print ("All files were successfully renamed")

    for name in errors:
        print("File {} could not be successfully renamed".format(os.path.split(name)[1]))
        sys.exit(1)
コード例 #4
0
ファイル: test_utils.py プロジェクト: Nooby/episode_renamer
def test_rename():
    create_temp_files(filenames)

    utils.load_renamed_file()

    files = []
    for index, f in enumerate(os.listdir(temp_dir)):
        old = os.path.join(temp_dir, f)
        new = os.path.join(temp_dir, "{:02}.avi".format(index))
        files.append((old, new))

    old, errors = utils.rename(files, 'y')
    assert_equal(errors, [])
    assert_not_equal(old, [])
    utils.save_renamed_file_info(old, 'test-show', temp_dir)

    for index, f in enumerate(os.listdir(temp_dir)):
        assert_equal(f, "{:02}.avi".format(index))

    files = utils.find_old_filenames(temp_dir, 'test-show')
    old, error = utils.rename(files, 'y')
    assert_equal(errors, [])
    assert_not_equal(old, [])
    utils.save_renamed_file_info(old, 'test-show', temp_dir)

    for new in os.listdir(temp_dir):
        assert new in filenames

    files = utils.find_old_filenames(temp_dir, 'test-show')
    old, errors = utils.rename(files, 'n')
    assert_equal(errors, [])
    assert_equal(old, [])

    teardown()

    files = utils.find_old_filenames(temp_dir, 'test-show')
    old, errors = utils.rename(files, 'y')
    assert errors
    assert not old
コード例 #5
0
ファイル: main.py プロジェクト: djt5019/episode_renamer
def do_rename(files):
    files = [(old, new) if old != new else None for old, new in files]
    print_renamed_files(files)
    files = [t for t in files if t]

    if not files:
        print("No changes to files were needed")
        sys.exit(1)

    old_order, errors = utils.rename(files)

    utils.save_renamed_file_info(old_order, Settings.title)

    if not old_order:
        print("Changes were not committed to the files")
    elif not errors:
        print("All files were successfully renamed")

    for name in errors:
        print("File {} could not be successfully renamed".format(
            os.path.split(name)[1]))
        sys.exit(1)
コード例 #6
0
def test_rename():
    create_temp_files(filenames)

    utils.load_renamed_file()

    files = []
    for index, f in enumerate(os.listdir(temp_dir)):
        old = os.path.join(temp_dir, f)
        new = os.path.join(temp_dir, "{:02}.avi".format(index))
        files.append((old, new))

    old, errors = utils.rename(files, 'y')
    assert_equal(errors, [])
    assert_not_equal(old, [])
    utils.save_renamed_file_info(old, 'test-show', temp_dir)

    for index, f in enumerate(os.listdir(temp_dir)):
        assert_equal(f, "{:02}.avi".format(index))

    files = utils.find_old_filenames(temp_dir, 'test-show')
    old, error = utils.rename(files, 'y')
    assert_equal(errors, [])
    assert_not_equal(old, [])
    utils.save_renamed_file_info(old, 'test-show', temp_dir)

    for new in os.listdir(temp_dir):
        assert new in filenames

    files = utils.find_old_filenames(temp_dir, 'test-show')
    old, errors = utils.rename(files, 'n')
    assert_equal(errors, [])
    assert_equal(old, [])

    teardown()

    files = utils.find_old_filenames(temp_dir, 'test-show')
    old, errors = utils.rename(files, 'y')
    assert errors
    assert not old