todo: Docstring for _clen_path

    :param p: arg description
    :type p: type description
    :return:
    :rtype:
346596
def _clean_path(p):
    

    np = os.path.expanduser(p)
    np = os.path.abspath(np)

    return np
798612
def ensure_mkdir_p(mode=0o777):
    

    def decorator(f):
        @functools.wraps(f)
        def decorated(*args, **kwargs):
            path = f(*args, **kwargs)
            mkdir_p(path, mode=mode)
            return path

        return decorated

    return decorator
139824
def upath(path):
    
    if six.PY2 and not isinstance(path, six.text_type):
        return path.decode(fs_encoding)
    return path
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))
805279
def _get_path(path):
    

    if isinstance(path, (six.string_types, bytes)):
        return path
    path_type = type(path)
    try:
        path_repr = path_type.__fspath__(path)
    except AttributeError:
        return
    if isinstance(path_repr, (six.string_types, bytes)):
        return path_repr
    return
882542
def displayable_path(path, separator=u'; '):
    
    if isinstance(path, (list, tuple)):
        return separator.join(displayable_path(p) for p in path)
    elif isinstance(path, six.text_type):
        return path
    elif not isinstance(path, bytes):
        # A non-string object: just get its unicode representation.
        return six.text_type(path)

    try:
        return path.decode(_fsencoding(), 'ignore')
    except (UnicodeError, LookupError):
        return path.decode('utf8', 'ignore')
278889
def instance_path_for(name, identifier_type, identifier_key=None):
    
    return "/{}/<{}:{}>".format(
        name_for(name),
        identifier_type,
        identifier_key or "{}_id".format(name_for(name)),
    )
653972
def path(string):
        
        if not os.path.exists(string):
            msg = "Path %s not found!" % string
            raise ArgumentTypeError(msg)
        return string
1353966
def mimetype_from_path(path):
    
    extension = file_extension(path)
    if extension is not None:
        extension = extension.lower()
        if extension in gc.MIMETYPE_MAP:
            return gc.MIMETYPE_MAP[extension]
    return None
658804
def rmtree_p(self):
        
        try:
            self.rmtree()
        except OSError:
            _, e, _ = sys.exc_info()
            if e.errno != errno.ENOENT:
                raise
        return self
679934
function (p, cb) {
				var pth = p.replace(/\\\?/g, '\/'); // Glob must use / as path seperator even on windows
				glob(pth + '/**/*.*', function (er, files) {
					if (er) {
						return cb(er);
					}
					return cb(null, files.map(function (f) {
						return path.relative(p, f);
					}));
				});
			}
567028
def path(cls, name, type_=Type.String, description=None, default=None,
             minimum=None, maximum=None, enum=None, **options):
        
        if minimum is not None and maximum is not None and minimum > maximum:
            raise ValueError("Minimum must be less than or equal to the maximum.")
        return cls(name, In.Path, type_, None, description,
                   default=default, minimum=minimum, maximum=maximum,
                   enum=enum, required=True, **options)
62600
def add_to_path(p):
    '''
        
    '''
    old_path = sys.path
    if p not in sys.path:
        sys.path = sys.path[:]
        sys.path.insert(0, p)
    try:
        yield
    finally:
        sys.path = old_path
763031
def from_file(cls, path):

        

        with open(path, 'r', errors='replace') as f:
            return cls(f.read())
864240
def path2url(p):
    
    # Python 3 is a bit different and does a better job.
    if sys.version_info.major >= 3 and sys.version_info.minor >= 4:
        import pathlib
        return pathlib.Path(p).as_uri()
    else:
        return six.moves.urllib.parse.urljoin(
            'file:', six.moves.urllib.request.pathname2url(p)
        )
856943
def _mkdir_p(abspath):
    
    try:
        os.makedirs(abspath)
    except OSError as e:
        if (e.errno == errno.EEXIST) and (os.path.isdir(abspath)):
            pass
        else: raise
1299353
def mkdir_p(self, path):
        
        try:
            if not os.path.isdir(path):
                os.makedirs(path)
                self.log.info('Created Directory [ %s ]', path)
        except OSError as exc:
            if exc.errno == errno.EEXIST and os.path.isdir(path):
                pass
            else:
                raise OSError(
                    'The provided path can not be created into a directory.'
                )