This if and the two nested ifs (if old_virtual_build_dir and old_virtual_sconsign_file) seem redundant since old_virtual_build_dir will not evaluate to True unless it is a non-empty string and it's only a non-empty string if sconsign_branch is non-empty. Both could probably be removed becuase os.path.isdir('') and isfile('') will return false.