当前位置: 首页>>代码示例>>Python>>正文


Python filesystem.FileSystem类代码示例

本文整理汇总了Python中elodie.filesystem.FileSystem的典型用法代码示例。如果您正苦于以下问题:Python FileSystem类的具体用法?Python FileSystem怎么用?Python FileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_directory_invalid_permissions

def test_create_directory_invalid_permissions():
    if os.name == 'nt':
       raise SkipTest("It isn't implemented on Windows")
    filesystem = FileSystem()
    status = filesystem.create_directory('/apathwhichdoesnotexist/afolderwhichdoesnotexist')

    assert status == False
开发者ID:scudderfish,项目名称:elodie,代码行数:7,代码来源:filesystem_test.py

示例2: test_set_utime_without_exif_date

def test_set_utime_without_exif_date():
    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder,'photo.jpg')
    shutil.copyfile(helper.get_file('no-exif.jpg'), origin)

    media_initial = Photo(origin)
    metadata_initial = media_initial.get_metadata()

    initial_stat = os.stat(origin)
    initial_time = int(min(initial_stat.st_mtime, initial_stat.st_ctime))
    initial_checksum = helper.checksum(origin)

    assert initial_time == time.mktime(metadata_initial['date_taken'])

    filesystem.set_utime(media_initial)
    final_stat = os.stat(origin)
    final_checksum = helper.checksum(origin)

    media_final = Photo(origin)
    metadata_final = media_final.get_metadata()

    shutil.rmtree(folder)

    assert initial_time == final_stat.st_mtime
    assert final_stat.st_mtime == time.mktime(metadata_final['date_taken']), (final_stat.st_mtime, time.mktime(metadata_final['date_taken']))
    assert initial_checksum == final_checksum
开发者ID:jmathai,项目名称:elodie,代码行数:28,代码来源:filesystem_test.py

示例3: test_process_video_with_album_then_title

def test_process_video_with_album_then_title():
    if not can_edit_exif():
        raise SkipTest('avmetareadwrite executable not found')

    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder,'movie.mov')
    shutil.copyfile(helper.get_file('video.mov'), origin)

    origin_checksum = helper.checksum(origin)

    media = Video(origin)
    media.set_album('test_album')
    media.set_title('test_title')
    destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)

    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum != destination_checksum, destination_checksum
    assert helper.path_tz_fix(os.path.join('2015-01-Jan','test_album','2015-01-19_12-45-11-movie-test_title.mov')) in destination, destination
开发者ID:GonzaloAlvarez,项目名称:elodie,代码行数:25,代码来源:filesystem_test.py

示例4: test_get_all_files_success

def test_get_all_files_success():
    filesystem = FileSystem()
    folder = helper.populate_folder(5)
    files = filesystem.get_all_files(folder)
    shutil.rmtree(folder)

    length = len(files)
    assert length == 5, length
开发者ID:wallrat,项目名称:elodie,代码行数:8,代码来源:filesystem_test.py

示例5: test_process_file_invalid

def test_process_file_invalid():
    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder,'photo.jpg')
    shutil.copyfile(helper.get_file('invalid.jpg'), origin)

    media = Photo(origin)
    destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)

    assert destination is None
开发者ID:scudderfish,项目名称:elodie,代码行数:11,代码来源:filesystem_test.py

示例6: test_get_folder_name_by_date

def test_get_folder_name_by_date():
    filesystem = FileSystem()
    time_tuple = (2010, 4, 15, 1, 2, 3, 0, 0, 0)
    folder_name = filesystem.get_folder_name_by_date(time_tuple)

    assert folder_name == '2010-04-Apr', folder_name

    time_tuple = (2010, 9, 15, 1, 2, 3, 0, 0, 0)
    folder_name = filesystem.get_folder_name_by_date(time_tuple)

    assert folder_name == '2010-09-Sep', folder_name
开发者ID:wallrat,项目名称:elodie,代码行数:11,代码来源:filesystem_test.py

示例7: test_delete_directory_if_empty

def test_delete_directory_if_empty():
    filesystem = FileSystem()
    folder = '%s/%s' % (helper.temp_dir(), helper.random_string(10))
    os.makedirs(folder)

    assert os.path.isdir(folder) == True
    assert os.path.exists(folder) == True

    filesystem.delete_directory_if_empty(folder)

    assert os.path.isdir(folder) == False
    assert os.path.exists(folder) == False
开发者ID:wallrat,项目名称:elodie,代码行数:12,代码来源:filesystem_test.py

示例8: test_create_directory_invalid_permissions

def test_create_directory_invalid_permissions(mock_makedirs):
    if os.name == 'nt':
       raise SkipTest("It isn't implemented on Windows")

    # Mock the case where makedirs raises an OSError because the user does
    # not have permission to create the given directory.
    mock_makedirs.side_effect = OSError()

    filesystem = FileSystem()
    status = filesystem.create_directory('/apathwhichdoesnotexist/afolderwhichdoesnotexist')

    assert status == False
开发者ID:jmathai,项目名称:elodie,代码行数:12,代码来源:filesystem_test.py

示例9: test_create_directory_recursive_success

def test_create_directory_recursive_success():
    filesystem = FileSystem()
    folder = '%s/%s/%s' % (helper.temp_dir(), helper.random_string(10), helper.random_string(10))
    status = filesystem.create_directory(folder)

    # Needs to be a subdirectory
    assert helper.temp_dir() != folder

    assert status == True
    assert os.path.isdir(folder) == True
    assert os.path.exists(folder) == True

    shutil.rmtree(folder)
开发者ID:wallrat,项目名称:elodie,代码行数:13,代码来源:filesystem_test.py

示例10: test_delete_directory_if_empty_when_not_empty

def test_delete_directory_if_empty_when_not_empty():
    filesystem = FileSystem()
    folder = '%s/%s/%s' % (helper.temp_dir(), helper.random_string(10), helper.random_string(10))
    os.makedirs(folder)
    parent_folder = os.path.dirname(folder)

    assert os.path.isdir(folder) == True
    assert os.path.exists(folder) == True
    assert os.path.isdir(parent_folder) == True
    assert os.path.exists(parent_folder) == True

    filesystem.delete_directory_if_empty(parent_folder)

    assert os.path.isdir(folder) == True
    assert os.path.exists(folder) == True
    assert os.path.isdir(parent_folder) == True
    assert os.path.exists(parent_folder) == True

    shutil.rmtree(parent_folder)
开发者ID:wallrat,项目名称:elodie,代码行数:19,代码来源:filesystem_test.py

示例11: test_process_file_with_album_and_title_and_location

def test_process_file_with_album_and_title_and_location():
    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = '%s/photo.jpg' % folder
    shutil.copyfile(helper.get_file('with-album-and-title-and-location.jpg'), origin)

    media = Photo(origin)
    destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)

    origin_checksum = helper.checksum(origin)
    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum == destination_checksum, destination_checksum
    assert '2015-12-Dec/Test Album/2015-12-05_00-59-26-photo-some-title.jpg' in destination, destination
开发者ID:wallrat,项目名称:elodie,代码行数:19,代码来源:filesystem_test.py

示例12: test_process_file_with_album

def test_process_file_with_album():
    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder,'photo.jpg')
    shutil.copyfile(helper.get_file('with-album.jpg'), origin)

    media = Photo(origin)
    destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)

    origin_checksum = helper.checksum(origin)
    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum == destination_checksum, destination_checksum
    assert helper.path_tz_fix(os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo.jpg')) in destination, destination
开发者ID:scudderfish,项目名称:elodie,代码行数:19,代码来源:filesystem_test.py

示例13: test_process_file_plain

def test_process_file_plain():
    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = '%s/photo.jpg' % folder
    shutil.copyfile(helper.get_file('plain.jpg'), origin)

    media = Photo(origin)
    destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)

    origin_checksum = helper.checksum(origin)
    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum == destination_checksum, destination_checksum
    assert '2015-12-Dec/Unknown Location/2015-12-05_00-59-26-photo.jpg' in destination, destination
开发者ID:wallrat,项目名称:elodie,代码行数:19,代码来源:filesystem_test.py

示例14: test_get_all_files_by_extension

def test_get_all_files_by_extension():
    filesystem = FileSystem()
    folder = helper.populate_folder(5)

    files = filesystem.get_all_files(folder)
    length = len(files)
    assert length == 5, length

    files = filesystem.get_all_files(folder, 'jpg')
    length = len(files)
    assert length == 3, length

    files = filesystem.get_all_files(folder, 'txt')
    length = len(files)
    assert length == 2, length

    files = filesystem.get_all_files(folder, 'gif')
    length = len(files)
    assert length == 0, length

    shutil.rmtree(folder)
开发者ID:wallrat,项目名称:elodie,代码行数:21,代码来源:filesystem_test.py

示例15: test_create_directory_invalid_permissions

def test_create_directory_invalid_permissions():
    filesystem = FileSystem()
    status = filesystem.create_directory('/apathwhichdoesnotexist/afolderwhichdoesnotexist')

    assert status == False
开发者ID:wallrat,项目名称:elodie,代码行数:5,代码来源:filesystem_test.py


注:本文中的elodie.filesystem.FileSystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。