def parse_list_line_unix(self, b):
        """
        Attempt to parse a LIST line (similar to unix ls utility).

        :param b: response line
        :type b: :py:class:`bytes` or :py:class:`str`

        :return: (path, info)
        :rtype: (:py:class:`pathlib.PurePosixPath`, :py:class:`dict`)
        """
        s = b.decode(encoding=self.encoding).rstrip()
        info = {}
        if s[0] == "-":
            info["type"] = "file"
        elif s[0] == "d":
            info["type"] = "dir"
        elif s[0] == "l":
            info["type"] = "link"
        else:
            info["type"] = "unknown"

        # TODO: handle symlinks(beware the symlink loop)
        info["unix.mode"] = self.parse_unix_mode(s[1:10])
        s = s[10:].lstrip()
        i = s.index(" ")
        info["unix.links"] = s[:i]

        if not info["unix.links"].isdigit():
            raise ValueError

        s = s[i:].lstrip()
        i = s.index(" ")
        info["unix.owner"] = s[:i]
        s = s[i:].lstrip()
        i = s.index(" ")
        info["unix.group"] = s[:i]
        s = s[i:].lstrip()
        i = s.index(" ")
        info["size"] = s[:i]

        if not info["size"].isdigit():
            raise ValueError

        s = s[i:].lstrip()
        info["modify"] = self.parse_ls_date(s[:12])
        s = s[12:].strip()
        if info["type"] == "link":
            i = s.rindex(" -> ")
            link_dst = s[i + 4:]
            link_src = s[:i]
            i = -2 if link_dst[-1] == "\'" or link_dst[-1] == "\"" else -1
            info["type"] = "dir" if link_dst[i] == "/" else "file"
            s = link_src
        return pathlib.PurePosixPath(s), info
def parse_list_line_unix(self, b):
        """
        Attempt to parse a LIST line (similar to unix ls utility).

        :param b: response line
        :type b: :py:class:`bytes` or :py:class:`str`

        :return: (path, info)
        :rtype: (:py:class:`pathlib.PurePosixPath`, :py:class:`dict`)
        """
        s = b.decode(encoding=self.encoding).rstrip()
        info = {}
        if s[0] == "-":
            info["type"] = "file"
        elif s[0] == "d":
            info["type"] = "dir"
        elif s[0] == "l":
            info["type"] = "link"
        else:
            info["type"] = "unknown"

        # TODO: handle symlinks(beware the symlink loop)
        info["unix.mode"] = self.parse_unix_mode(s[1:10])
        s = s[10:].lstrip()
        i = s.index(" ")
        info["unix.links"] = s[:i]

        if not info["unix.links"].isdigit():
            raise ValueError

        s = s[i:].lstrip()
        i = s.index(" ")
        info["unix.owner"] = s[:i]
        s = s[i:].lstrip()
        i = s.index(" ")
        info["unix.group"] = s[:i]
        s = s[i:].lstrip()
        i = s.index(" ")
        info["size"] = s[:i]

        if not info["size"].isdigit():
            raise ValueError

        s = s[i:].lstrip()
        info["modify"] = self.parse_ls_date(s[:12])
        s = s[12:].strip()
        if info["type"] == "link":
            i = s.rindex(" -> ")
            link_dst = s[i + 4:]
            link_src = s[:i]
            i = -2 if link_dst[-1] == "\'" or link_dst[-1] == "\"" else -1
            info["type"] = "dir" if link_dst[i] == "/" else "file"
            s = link_src
        return pathlib.PurePosixPath(s), info
def parse_list_line_unix ( self , b ) : s = b . decode ( encoding = self . encoding ) . rstrip ( ) info = { } if s [ 0 ] == "-" : info [ "type" ] = "file" elif s [ 0 ] == "d" : info [ "type" ] = "dir" elif s [ 0 ] == "l" : info [ "type" ] = "link" else : info [ "type" ] = "unknown" # TODO: handle symlinks(beware the symlink loop) info [ "unix.mode" ] = self . parse_unix_mode ( s [ 1 : 10 ] ) s = s [ 10 : ] . lstrip ( ) i = s . index ( " " ) info [ "unix.links" ] = s [ : i ] if not info [ "unix.links" ] . isdigit ( ) : raise ValueError s = s [ i : ] . lstrip ( ) i = s . index ( " " ) info [ "unix.owner" ] = s [ : i ] s = s [ i : ] . lstrip ( ) i = s . index ( " " ) info [ "unix.group" ] = s [ : i ] s = s [ i : ] . lstrip ( ) i = s . index ( " " ) info [ "size" ] = s [ : i ] if not info [ "size" ] . isdigit ( ) : raise ValueError s = s [ i : ] . lstrip ( ) info [ "modify" ] = self . parse_ls_date ( s [ : 12 ] ) s = s [ 12 : ] . strip ( ) if info [ "type" ] == "link" : i = s . rindex ( " -> " ) link_dst = s [ i + 4 : ] link_src = s [ : i ] i = - 2 if link_dst [ - 1 ] == "\'" or link_dst [ - 1 ] == "\"" else - 1 info [ "type" ] = "dir" if link_dst [ i ] == "/" else "file" s = link_src return pathlib . PurePosixPath ( s ) , info
Attempt to parse a LIST line (similar to unix ls utility).

        :param b: response line
        :type b: :py:class:`bytes` or :py:class:`str`

        :return: (path, info)
        :rtype: (:py:class:`pathlib.PurePosixPath`, :py:class:`dict`)
Attempt to parse a LIST line ( similar to unix ls utility ) .