def pathIndex(self, path):
if path == self.root.path:<EOL><INDENT>return QModelIndex()<EOL><DEDENT>if not path.startswith(self.root.path):<EOL><INDENT>return QModelIndex()<EOL><DEDENT>parts = []<EOL>while True:<EOL><INDENT>if path == self.root.path:<EOL><INDENT>break<EOL><DEDENT>head, tail = os.path.split(path)<EOL>if head == path:<EOL><INDENT>if path:<EOL><INDENT>parts.append(path)<EOL><DEDENT>break<EOL><DEDENT>parts.append(tail)<EOL>path = head<EOL><DEDENT>parts.reverse()<EOL>if parts:<EOL><INDENT>item = self.root<EOL>count = <NUM_LIT:0><EOL>for count, part in enumerate(parts):<EOL><INDENT>matched = False<EOL>for child in item.children:<EOL><INDENT>if child.name == part:<EOL><INDENT>item = child<EOL>matched = True<EOL>break<EOL><DEDENT><DEDENT>if not matched:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if count + <NUM_LIT:1> == len(parts):<EOL><INDENT>return self.createIndex(item.row, <NUM_LIT:0>, item)<EOL><DEDENT><DEDENT>return QModelIndex()<EOL>
Return index of item with *path*.