@classmethod
    def validate(cls, value):
        if not value:
            return value
        value = os.path.abspath(value)
        dirname = os.path.dirname(value)

        if os.path.isfile(value):
            if not os.access(value, os.W_OK):
                raise config_option.BadValue('You do not have write permissions')
            if not os.access(dirname, os.W_OK):
                raise config_option.BadValue('You do not have write permissions for "%s"' % dirname)
            return value
        elif os.path.isdir(value):
            raise config_option.BadValue('"%s" is a directory' % value)
        else:
            if os.path.isdir(dirname):
                if not os.access(dirname, os.W_OK):
                    raise config_option.BadValue('You do not have write permissions for "%s"' % dirname)
                # filename is in a valid directory
                return value
            previous_dir = os.path.dirname(dirname)
            if not os.path.isdir(previous_dir):
                raise config_option.BadValue('"%s" not found' % value)
            if not os.access(previous_dir, os.W_OK):
                raise config_option.BadValue('You do not have write permissions for "%s"' % previous_dir)
            # the preceding directory can be created later (in apply())
            return value
dataset/ETHPy150Open NVIDIA/DIGITS/digits/config/log_file.py/LogFileOption.validate/original