(cls, path: Union[str, PathItem])
return item
Create a `ImportItem` from a local file system path.
Create a `ImportItem` from a local file system path.
Create a ImportItem from a local file system path .
def fromPath(cls, path: Union[str, PathItem]) -> 'ImportItem':
        """
        Create a `ImportItem` from a local file system path.
        """
        if isinstance(path, str):
            path = PathItem.AbsPath(path)
        if isinstance(path, PathItem.VarPath):
            basename = os.path.basename(path.relpath)
            text = f"${{{path.name}}}/{path.relpath}"
        elif isinstance(path, PathItem.AbsPath):
            basename = os.path.basename(path.path)
            text = path.path
        else:
            raise TypeError

        item = cls()
        item.setText(basename)
        item.setToolTip(text)
        item.setData(path, ImportItem.VarPathRole)
        return item
def fromPath ( cls , path : Union [ str , PathItem ] ) -> 'ImportItem' : if isinstance ( path , str ) : path = PathItem . AbsPath ( path ) if isinstance ( path , PathItem . VarPath ) : basename = os . path . basename ( path . relpath ) text = f"${{{path.name}}}/{path.relpath}" elif isinstance ( path , PathItem . AbsPath ) : basename = os . path . basename ( path . path ) text = path . path else : raise TypeError item = cls ( ) item . setText ( basename ) item . setToolTip ( text ) item . setData ( path , ImportItem . VarPathRole ) return item