Converts a path into its absolute path and verifies that it exists or throws an exception.
420950
def to_existing_absolute_path(string):
    """"""
    value = os.path.abspath(string)
    if not os.path.exists( value ) or not os.path.isdir( value ):
        msg = '"%r" is not a valid path to a directory.' % string
        raise argparse.ArgumentTypeError(msg)
    return value
877838
def return_abs_path(directory, path):
    
    if directory is None or path is None:
        return
    directory = os.path.expanduser(directory)
    return os.path.abspath(os.path.join(directory, path))
1333199
protected boolean isValidPath(String path) {
        if (path == null) {
            return false;
        }
        
        if (!PATH_PATTERN.matcher(path).matches()) {
            return false;
        }
        
        try {
            URI uri = new URI(null,null,path,null);
            String norm = uri.normalize().getPath();
            if (norm.startsWith("/../") // Trying to go via the parent dir 
                    || norm.equals("/..")) {   // Trying to go to the parent dir
                return false;
            }
        } catch (URISyntaxException e) {
            return false;
        }
        
        int slash2Count = countToken("//", path);
        if (isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) {
            return false;
        }
        
        return true;
    }
827172
static String toUnixStylePath(String absolutePath) {
        if (StringUtils.isEmpty(absolutePath)) {
            throw new IllegalStateException("empty path given");
        }
        if (absolutePath.startsWith("/")) {
            return absolutePath;
        } else if (absolutePath.length()>=2 && Character.isLetter(absolutePath.charAt(0)) && ':' == absolutePath.charAt(1) && '\\' == absolutePath.charAt(2)) {
            char driveLetter = Character.toLowerCase(absolutePath.charAt(0));
            String drivePath = StringUtils.substringAfter(absolutePath, ":");
            String drivePathUnixStyle = drivePath.replace('\\', '/');
            return "/"+driveLetter+drivePathUnixStyle;
        } else {
            throw new IllegalStateException(String.format("unable to convert path %s", absolutePath));
        }
    }
78272
Path absolutePathFor( String absPath ) throws RepositoryException {
        Path path = null;
        try {
            path = pathFactory().create(absPath);
        } catch (org.modeshape.jcr.value.ValueFormatException e) {
            throw new RepositoryException(e.getMessage());
        }
        if (!path.isAbsolute()) {
            throw new RepositoryException(JcrI18n.invalidAbsolutePath.text(absPath));
        }
        return path;
    }
1169606
function isValidAbsolutePath(p) {
    var parsedPath;
    try {
        parsedPath = path.parse(p);
    } catch (error) {
        // Not a valid path if it can't be parsed.
        return false;
    }

    return (parsedPath.root === '/');
}
1275327
def get_absolute_path(self, path):
        '''
        
        '''
        if os.path.isabs(path):
            return path
        else:
            return os.path.abspath(os.path.join(self.config.BASEDIR, path))
131362
public function setPath($path)
        {
            if ($this->validatePath($path) === false) {
                throw new Exception("Path \"$path\" is not a valid HTTP path");
            }

            $oldPath     = $this->_path;
            $this->_path = $path;

            return $oldPath;
        }
302957
public boolean accept(String path) {
        if (allow.isEmpty() && deny.isEmpty()) {
            return true;
        }
        // Check if the path is denied
        for (Pattern p : deny) {
            if (p.matcher(path).matches()) {
                return false;
            }
        }

        // Check if the path is accepted
        for (Pattern p : allow) {
            if (p.matcher(path).matches()) {
                return true;
            }
        }

        // Denied by default.
        return !deny.isEmpty();
    }
1119099
def PathToComponents(path):
  
  precondition.AssertType(path, Text)
  if path and not path.startswith("/"):
    raise ValueError("Path '{}' is not absolute".format(path))

  if path:
    return tuple(path.split("/")[1:])
  else:
    return ()
302485
def normalize_path(path, filetype=FILE):
    
    if not path:
        raise ValueError('"{0}" is not a valid path.'.format(path))
    if not os.path.exists(path):
        raise ValueError('"{0}" does not exist.'.format(path))
    if filetype == FILE and not os.path.isfile(path):
        raise ValueError('"{0}" is not a file.'.format(path))
    elif filetype == DIR and not os.path.isdir(path):
        raise ValueError('"{0}" is not a dir.'.format(path))

    return os.path.abspath(path)
1227499
@Trivial
    public static boolean pathIsAbsolute(String normalizedPath) {
        // Absolute path with leading /
        if (normalizedPath.length() > 0 && normalizedPath.charAt(0) == '/')
            return true;

        // Absolute path with symbolic
        if (isSymbol(normalizedPath))
            return true;

        if (normalizedPath.contains(":")) {
            // Absolute windows path with leading c:/
            if (normalizedPath.length() > 3 && normalizedPath.charAt(1) == ':' && normalizedPath.charAt(2) == '/')
                return true;

            // Absolute path with scheme, e.g. file://whatever
            Matcher m = ABSOLUTE_URI.matcher(normalizedPath);
            if (m.matches())
                return true;
        }

        return false;
    }
758976
@Override
    public Path toAbsolutePath() {

        // Already absolute?
        if (this.isAbsolute()) {
            return this;
        }

        // Else construct a new absolute path and normalize it
        final Path absolutePath = new ShrinkWrapPath(ArchivePath.SEPARATOR + this.path, this.fileSystem);
        final Path normalized = absolutePath.normalize();
        return normalized;
    }
1348218
protected static function validatePath($path)
    {
        if (realpath($path) === false) {
            throw new Exception(
                'Path "' . $path . '" does not exist.'
            );
        }

        if (is_dir($path) === false || is_writable($path) === false) {
            throw new Exception(
                'Make sure path "' . $path . '" exists and that it\'s writable.'
            );
        }

        // Make full usable with trailing slash
        $path = realpath($path) . DIRECTORY_SEPARATOR;

        return $path;
    }
1178090
def assert_valid_path(self, path):
        
        if not isinstance(path, str):
            raise NotFoundResourceException(
                "Resource passed to load() method must be a file path")

        if not os.path.isfile(path):
            raise NotFoundResourceException(
                'File "{0}" does not exist'.format(path))
216439
def absolute(path = nil)
      return path if path && path[0] != '/'
      abs = if path
        [env['scorched.root_path'], path].join('/').gsub(%r{/+}, '/')
      else
        env['scorched.root_path']
      end
      abs.insert(0, '/') unless abs[0] == '/'
      abs
    end
29836
def from_path(cls, path: pathlib.Path) -> 'File':
        
        if not path.is_file():
            raise ValueError('Path does not point to a file')
        return File(path.name, path.stat().st_size, cls._md5(path))