Convert JSON path to individual path components.

    :param path: JSON path, which can be either an iterable of path
        components or a dot-separated string
    :return: A list of path components
173830
def json_path_components(path):
    
    if isinstance(path, str):
        path = path.split('.')

    return list(path)
35401
def iter_prefixes(path):
    
    split_path = path.split('.')
    for i in range(1, len(split_path) + 1):
        yield join_paths(*split_path[:i])
1368425
def splitall(path):
    
    head, tail = os.path.split(os.path.normpath(path))
    components = []
    while tail:
        components.insert(0, tail)
        head, tail = os.path.split(head)
    return components
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
149160
public static String[] getPathComponents(String path) throws InvalidPathException {
    path = cleanPath(path);
    if (isRoot(path)) {
      return new String[]{""};
    }
    return path.split(AlluxioURI.SEPARATOR);
  }
194384
def parse_json(path):
    # type: (str) -> List[FunctionInfo]
    
    with open(path) as f:
        data = json.load(f)  # type: List[RawEntry]
    result = []

    def assert_type(value, typ):
        # type: (object, type) -> None
        assert isinstance(value, typ), '%s: Unexpected type %r' % (path, type(value).__name__)

    def assert_dict_item(dictionary, key, typ):
        # type: (Mapping[Any, Any], str, type) -> None
        assert key in dictionary, '%s: Missing dictionary key %r' % (path, key)
        value = dictionary[key]
        assert isinstance(value, typ), '%s: Unexpected type %r for key %r' % (
            path, type(value).__name__, key)

    assert_type(data, list)
    for item in data:
        assert_type(item, dict)
        assert_dict_item(item, 'path', Text)
        assert_dict_item(item, 'line', int)
        assert_dict_item(item, 'func_name', Text)
        assert_dict_item(item, 'type_comments', list)
        for comment in item['type_comments']:
            assert_type(comment, Text)
        assert_type(item['samples'], int)
        info = FunctionInfo(encode(item['path']),
                            item['line'],
                            encode(item['func_name']),
                            [encode(comment) for comment in item['type_comments']],
                            item['samples'])
        result.append(info)
    return result
180372
def path_types(obj, path):
    
    result = []
    #for elem in path[:-1]:
    cur = obj
    for elem in path[:-1]:
        if ((issubclass(cur.__class__, MutableMapping) and elem in cur)):
            result.append([elem, cur[elem].__class__])
            cur = cur[elem]
        elif (issubclass(cur.__class__, MutableSequence) and int(elem) < len(cur)):
            elem = int(elem)
            result.append([elem, cur[elem].__class__])
            cur = cur[elem]
        else:
            result.append([elem, dict])
    try:
        try:
            result.append([path[-1], cur[path[-1]].__class__])
        except TypeError:
            result.append([path[-1], cur[int(path[-1])].__class__])
    except (KeyError, IndexError):
        result.append([path[-1], path[-1].__class__])
    return result
805451
def make_path(*path_components):
    
    path_components = [quote(component) for component in path_components if component]
    path = '/'.join(path_components)
    if not path.startswith('/'):
        path = '/' + path
    return path
942494
def extract_from_dict(data, path):
    
    value = data
    try:
        for key in path:
            value = value[key]
        return value
    except (KeyError, IndexError, TypeError):
        return ''
141663
def wrap_paths(paths):
    # type: (list[str]) -> str
    
    if isinstance(paths, string_types):
        raise ValueError(
            "paths cannot be a string. "
            "Use array with one element instead."
        )
    return ' '.join('"' + path + '"' for path in paths)
1107972
def get_repo_paths(path):
    
    repo_paths = []
    dirnames = (os.path.abspath(dirname) for dirname in os.listdir(path))
    for dirname in dirnames:
        try:
            get_scm(dirname)
            repo_paths.append(dirname)
        except VCSError:
            pass
    return repo_paths
892708
def path_components(path):
    """"""

    def yield_components(path):
        # Iterate over each character and the next character
        chars = zip_longest(path, path[1:])
        try:
            # Iterate over components
            while True:
                c, n = next(chars)
                if c != '/':
                    raise ValueError("Invalid path, expected \"/\"")
                elif (n is not None and n != "'"):
                    raise ValueError("Invalid path, expected \"'\"")
                else:
                    # Consume "'" or raise StopIteration if at the end
                    next(chars)
                component = []
                # Iterate over characters in component name
                while True:
                    c, n = next(chars)
                    if c == "'" and n == "'":
                        component += "'"
                        # Consume second "'"
                        next(chars)
                    elif c == "'":
                        yield "".join(component)
                        break
                    else:
                        component += c
        except StopIteration:
            return

    return list(yield_components(path))
1306162
def path(self, path: str):
        

        path = path if path else ''
        self.pathName = os.path.join(path, self.name)
1129644
def as_json(self, path="", with_indent=False):
        
        if path not in self.top_level_links:
            raise StateError("Unknown path")

        return json.dumps(self.get_state_repr(path),
                          indent=4 if with_indent else None)
587523
def read_json_file(cls, path):
        
        with open(path, 'r') as f:
            json_string = f.read()
        return cls.from_json(json_string)
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')
832743
def load(path, **kw):
    
    _kw = {}
    if PY3:  # pragma: no cover
        _kw['encoding'] = 'utf-8'
    with open(str(path), **_kw) as fp:
        return json.load(fp, **kw)