Exemplo n.º 1
0
def replace_links(link, max_depth=10):
    link_depth = 0
    target = link

    for attempt in range(0, max_depth):
        if not islink(target):
            break
        target = readlink(target)
        link_depth = attempt

    if not link_depth:
        logger.debug('{0} is not a link'.format(link))
    elif link_depth > max_depth or (link_depth == max_depth and islink(target)):
        logger.warning('Exceeded maximum depth {0} while following link {1}'.format(max_depth, link))
    else:
        logger.info('Changing sym-link: {0} to point directly to file: {1}'.format(link, target), 'COPYLINK')
        os.unlink(link)
        linktastic.symlink(target, link)
Exemplo n.º 2
0
def test_islink_on_nonexistent_target():
    assert filesystem.islink('/doesnotexist') is False
Exemplo n.º 3
0
def test_islink_on_nonexistent_target():
	assert filesystem.islink('/doesnotexist') == False
Exemplo n.º 4
0
 def islink(self, path):
     """Return True if path refers to an existing directory entry that is a symbolic link.
     """
     return fs.islink(path)