Example #1
0
    def setPath(self, path):
        """
        Set the path location on disc for the item.

        :type path: str
        :rtype: None
        """
        if not path:
            raise ItemError('Cannot set an empty item path.')

        path = studiolibrary.normPath(path)

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setName(name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        self.setText("Type", extension)
Example #2
0
    def updatePathData(self):
        """
        Update the data when the item is created or when a new path is set.
        
        :rtype: None 
        """
        path = self.path()

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname)
        # modified = ""
        # timeAgo = ""

        # if os.path.exists(path):
        #     modified = os.path.getmtime(path)
        #     timeAgo = studiolibrary.timeAgo(modified)

        itemData = {
            "name": name,
            "path": path,
            "type": extension,
            "folder": dirname,
            "category": category,
            # "modified": modified
        }

        self.setItemData(itemData)
Example #3
0
    def createItemData(self):

        path = self.path()

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname)
        # modified = ""
        # timeAgo = ""

        # if os.path.exists(path):
        #     modified = os.path.getmtime(path)
        #     timeAgo = studiolibrary.timeAgo(modified)

        itemData = {
            "name": name,
            "path": path,
            "type": extension,
            "folder": dirname,
            "category": category,
            # "modified": modified
        }

        return itemData
Example #4
0
    def createItemData(self):
        """
        Called when syncing the given path with the library cache.

        :rtype: dict
        """
        path = self.path()

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname) or dirname
        modified = ""

        if os.path.exists(path):
            modified = os.path.getmtime(path)

        itemData = {
            "name": name,
            "path": path,
            "type": extension,
            "folder": dirname,
            "category": category,
            "modified": modified,
            "__class__":
            self.__class__.__module__ + "." + self.__class__.__name__
        }

        return itemData
Example #5
0
    def setPath(self, path):
        """
        :type path: str
        :rtype: None
        """
        if not path:
            raise RecordError('Cannot set empty record path.')

        text = os.path.basename(path)
        iconPath = path + "/thumbnail.jpg"

        self.setText(text)
        self.setIconPath(iconPath)

        dirname, basename, extension = studiolibrary.splitPath(path)

        if extension:
            if self.plugin():
                if extension != self.plugin().extension():
                    path += self.plugin().extension()
        else:
            if self.plugin():
                path += self.plugin().extension()
            else:
                raise RecordSaveError('No extension found!')

        studiolibrary.MasterPath.setPath(self, path)
Example #6
0
    def createItemData(self):

        path = self.path()

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname)
        # modified = ""
        # timeAgo = ""

        # if os.path.exists(path):
        #     modified = os.path.getmtime(path)
        #     timeAgo = studiolibrary.timeAgo(modified)

        itemData = {
            "name": name,
            "path": path,
            "type": extension,
            "folder": dirname,
            "category": category,
            # "modified": modified
        }

        return itemData
Example #7
0
    def updateData(self):
        """
        Update the data when the item is created or when a new path is set.
        
        :rtype: None 
        """
        path = self.path()

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setName(name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        self.setText("Type", extension)
Example #8
0
 def rename(self, path, save = True, force = False):
     """
     @type path: str
     @type save: bool
     @type force: bool
     """
     path = path.replace('\\', '/')
     dirname, basename, extension = studiolibrary.splitPath(path)
     if extension != self.plugin().extension():
         path += self.plugin().extension()
     studiolibrary.Folder.rename(self, path, save, force)
Example #9
0
 def rename(self, path, save=True, force=False):
     """
     @type path: str
     @type save: bool
     @type force: bool
     """
     path = path.replace('\\', '/')
     dirname, basename, extension = studiolibrary.splitPath(path)
     if extension != self.plugin().extension():
         path += self.plugin().extension()
     studiolibrary.Folder.rename(self, path, save, force)
Example #10
0
    def setPath(self, path):
        """
        :type path: str
        :rtype: None
        """
        if not path:
            raise RecordError('Cannot set empty record path.')

        plugin = self.plugin()

        dirname, basename, extension = studiolibrary.splitPath(path)

        iconPath = path + "/thumbnail.jpg"

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setIconPath(iconPath)
        self.setText("Icon", name)
        self.setText("Name", name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        if extension:
            if plugin:
                if extension != plugin.extension():
                    path += plugin.extension()
        else:
            if plugin:
                path += plugin.extension()
            else:
                raise RecordSaveError('No extension found!')

        if plugin:
            self.setText("Type", plugin.extension())

        studiolibrary.BasePath.setPath(self, path)
Example #11
0
    def setPath(self, path):
        """
        :type path: str
        :rtype: None
        """
        if not path:
            raise RecordError('Cannot set empty record path.')

        plugin = self.plugin()

        dirname, basename, extension = studiolibrary.splitPath(path)

        iconPath = path + "/thumbnail.jpg"

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setIconPath(iconPath)
        self.setText("Icon", name)
        self.setText("Name", name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        if extension:
            if plugin:
                if extension != plugin.extension():
                    path += plugin.extension()
        else:
            if plugin:
                path += plugin.extension()
            else:
                raise RecordSaveError('No extension found!')

        if plugin:
            self.setText("Type", plugin.extension())

        studiolibrary.BasePath.setPath(self, path)
Example #12
0
def loadPlugin(path, parent = None):
    """
    @type path: str
    @type parent: QWidget
    """
    path = path.replace('\\', '/')
    if os.path.exists(path):
        dirname, basename, extension = studiolibrary.splitPath(path)
        module = imp.load_source(basename, path)
    else:
        exec 'import ' + path
        module = eval(path)
    p = module.Plugin(parent)
    if not parent:
        Plugin._plugins.setdefault(p.name(), p)
    p.setPath(path)
    p.load()
    Plugin._plugins.setdefault(p.name(), p)
    return p
Example #13
0
def loadPlugin(path, parent=None):
    """
    @type path: str
    @type parent: QWidget
    """
    path = path.replace('\\', '/')
    if os.path.exists(path):
        dirname, basename, extension = studiolibrary.splitPath(path)
        module = imp.load_source(basename, path)
    else:
        exec 'import ' + path
        module = eval(path)
    p = module.Plugin(parent)
    if not parent:
        Plugin._plugins.setdefault(p.name(), p)
    p.setPath(path)
    p.load()
    Plugin._plugins.setdefault(p.name(), p)
    return p
Example #14
0
    def setPath(self, path):
        """
        :type path: str
        :rtype: None
        """
        if not path:
            raise RecordError('Cannot set empty record path.')

        text = os.path.basename(path)
        iconPath = path + "/thumbnail.jpg"

        self.setText(text)
        self.setIconPath(iconPath)

        dirname, basename, extension = studiolibrary.splitPath(path)
        if not extension:
            if self.plugin():
                path += self.plugin().extension()
            else:
                raise RecordSaveError('No extension found!')

        studiolibrary.MasterPath.setPath(self, path)
Example #15
0
 def versionPath(self, version):
     dirname, basename, extension = studiolibrary.splitPath(
         self.versionDirname())
     return dirname + '/' + basename + '.' + str(version) + extension
Example #16
0
 def versionPath(self, version):
     dirname, basename, extension = studiolibrary.splitPath(self.versionDirname())
     return dirname + '/' + basename + '.' + str(version) + extension