Ejemplo n.º 1
0
def check_incomplete_vs_complete():
    """ Make sure "incomplete" and "complete" are not identical """
    complete = cfg.complete_dir.get_path()
    if filesystem.same_file(cfg.download_dir.get_path(), complete):
        if filesystem.real_path("X", cfg.download_dir()) == cfg.download_dir():
            # Abs path, so set an abs path too
            cfg.download_dir.set(os.path.join(complete, "incomplete"))
        else:
            cfg.download_dir.set("incomplete")
Ejemplo n.º 2
0
def check_incomplete_vs_complete():
    """Make sure download_dir and complete_dir are not identical
    or that download_dir is not a subfolder of complete_dir"""
    complete = cfg.complete_dir.get_path()
    if filesystem.same_file(cfg.download_dir.get_path(), complete):
        if filesystem.real_path("X", cfg.download_dir()) == filesystem.long_path(cfg.download_dir()):
            # Abs path, so set download_dir as an abs path inside the complete_dir
            cfg.download_dir.set(os.path.join(complete, "incomplete"))
        else:
            cfg.download_dir.set("incomplete")
        return False
    return True
Ejemplo n.º 3
0
 def test_same(self):
     assert 1 == filesystem.same_file("/home/123", "/home/123")
     assert 1 == filesystem.same_file("D:\\", "D:\\")
     assert 1 == filesystem.same_file("/test/../test", "/test")
     assert 1 == filesystem.same_file("test/../test", "test")
     assert 1 == filesystem.same_file("/test/./test", "/test/test")
     assert 1 == filesystem.same_file("./test", "test")
Ejemplo n.º 4
0
 def test_posix_fun(self):
     assert 1 == filesystem.same_file("/test", "/test")
     # IEEE 1003.1-2017 par. 4.13 for details
     assert 0 == filesystem.same_file("/test", "//test")
     assert 1 == filesystem.same_file("/test", "///test")
     assert 1 == filesystem.same_file("/test", "/test/")
     assert 1 == filesystem.same_file("/test", "/test//")
     assert 1 == filesystem.same_file("/test", "/test///")
Ejemplo n.º 5
0
 def test_capitalization_linux(self):
     assert 2 == filesystem.same_file("/home/test123", "/home/test123/sub")
     assert 0 == filesystem.same_file("/test", "/Test")
     assert 0 == filesystem.same_file("tesT", "Test")
     assert 0 == filesystem.same_file("/test/../Home", "/home")
Ejemplo n.º 6
0
 def test_capitalization(self):
     # Only matters on Windows/macOS
     assert 1 == filesystem.same_file("/HOME/123", "/home/123")
     assert 1 == filesystem.same_file("D:\\", "d:\\")
     assert 2 == filesystem.same_file("\\\\?\\c:\\", "\\\\?\\C:\\Users\\")
Ejemplo n.º 7
0
 def test_subfolder(self):
     assert 2 == filesystem.same_file("\\\\?\\C:\\", "\\\\?\\C:\\Users\\")
     assert 2 == filesystem.same_file("/home/test123", "/home/test123/sub")
     assert 2 == filesystem.same_file("/test", "/test/./test")
     assert 2 == filesystem.same_file("/home/../test", "/test/./test")
Ejemplo n.º 8
0
 def test_nothing_in_common_unix_paths(self):
     assert 0 == filesystem.same_file("/home/", "/data/test")
     assert 0 == filesystem.same_file("/test/home/test", "/home/")
     assert 0 == filesystem.same_file("/test/../home", "/test")
     assert 0 == filesystem.same_file("/test/./test", "/test")
Ejemplo n.º 9
0
 def test_nothing_in_common_win_paths(self):
     assert 0 == filesystem.same_file("C:\\", "D:\\")
     assert 0 == filesystem.same_file("C:\\", "/home/test")