this repo has no description
1#!/usr/bin/env python3
2# Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
3"""The _path module provides path facilities very early in the bootstrapping
4process. It is used primarily by the sys module before it is possible to bring
5up the usual CPython {posix|nt}path module."""
6
7from _builtins import _builtin, _str_guard
8
9
10def dirname(path):
11 _str_guard(path)
12 sep = "/"
13 i = path.rfind(sep) + 1
14 head = path[:i]
15 if head and head != sep * len(head):
16 head = head.rstrip(sep)
17 return head
18
19
20def isdir(path):
21 _builtin()
22
23
24def isfile(path):
25 _builtin()
26
27
28def join(a, *p):
29 _str_guard(a)
30 sep = "/"
31 path = a
32 for b in p:
33 _str_guard(b)
34 if b.startswith(sep):
35 path = b
36 elif not path or path.endswith(sep):
37 path += b
38 else:
39 path += sep + b
40 return path