Example #1
0
    def update_shots(self):
        """docstring for update_project"""
        self.cmbShot.clear()

        self.cmbShot.addItem("[ALL SHOTS]", "*")

        sort = False
        if self.settings.get("preferences",
                             "shotlistsort",
                             "True",
                             create=True).strip().lower() in [
                                 'true', '1', 'yes', 'on'
                             ]:
            sort = True

        cur_project = self.PROJECTNAME
        project_shots = os.path.join(self.PROJECTROOT, cur_project,
                                     "project_shots.xml")

        shot_root_dir = shot_root_path(cur_project)

        if shot_root_dir == "":
            self.valid_shotname = False
            return

        shot_dict = {}
        if os.path.isfile(project_shots):
            with open(project_shots, 'rt') as f:
                tree = etree.parse(f)

                for item in tree.findall(".//shot"):

                    shot_dir = os.path.join(shot_root_dir,
                                            item.text.strip('"'))
                    if os.path.isdir(shot_dir):
                        shot_dict[item.attrib["name"]] = shot_dir

        if sort:
            for key in sorted(shot_dict.keys()):
                self.cmbShot.addItem(key, shot_dict[key])
        else:
            for key in shot_dict.keys():
                self.cmbShot.addItem(key, shot_dict[key])

        if self.cmbShot.count() < 1:
            self.valid_shotname = False
        else:
            self.valid_shotname = True
Example #2
0
def shots(rootdir, project):
    """docstring for shots"""
    project_shots = os.path.join(rootdir, project, "project_shots.xml")
    
    shot_root_dir = shot_root_path(project)

    shot_dict = {}
    if os.path.isfile(project_shots):
        with open(project_shots, 'rt') as f:
            tree = etree.parse(f)
            
            for item in tree.findall(".//shot"):

                shot_dir = os.path.join(shot_root_dir, item.text.strip('"'))
                if os.path.isdir(shot_dir):
                    shot_dict[item.attrib["name"]] = shot_dir
        
    return shot_dict
Example #3
0
def shots(rootdir, project):
    """docstring for shots"""
    project_shots = os.path.join(rootdir, project, "project_shots.xml")

    shot_root_dir = shot_root_path(project)

    shot_dict = {}
    if os.path.isfile(project_shots):
        with open(project_shots, 'rt') as f:
            tree = etree.parse(f)

            for item in tree.findall(".//shot"):

                shot_dir = os.path.join(shot_root_dir, item.text.strip('"'))
                if os.path.isdir(shot_dir):
                    shot_dict[item.attrib["name"]] = shot_dir

    return shot_dict
Example #4
0
    def update_shots(self):
        """docstring for update_project"""
        self.cmbShot.clear()

        sort = False
        if self.settings.get("preferences", "shotlistsort", "True", create=True).strip().lower() in [
            "true",
            "1",
            "yes",
            "on",
        ]:
            sort = True

        cur_project = self.cmbProject.currentText()
        project_shots = os.path.join(self.PROJECTROOT, cur_project, "project_shots.xml")

        shot_root_dir = shot_root_path(cur_project)

        if shot_root_dir == "":
            self.valid_shotname = False
            return

        shot_dict = {}
        if os.path.isfile(project_shots):
            with open(project_shots, "rt") as f:
                tree = etree.parse(f)

                for item in tree.findall(".//shot"):

                    shot_dir = os.path.join(shot_root_dir, item.text.strip('"'))
                    if os.path.isdir(shot_dir):
                        shot_dict[item.attrib["name"]] = shot_dir

        if sort:
            for key in sorted(shot_dict.keys()):
                self.cmbShot.addItem(key, shot_dict[key])
        else:
            for key in shot_dict.keys():
                self.cmbShot.addItem(key, shot_dict[key])

        if self.cmbShot.count() < 1:
            self.valid_shotname = False
        else:
            self.valid_shotname = True
Example #5
0
def project_shot_from_path(filepath):
    """docstring for project_shot_from_file"""

    projectroot = project_root_path()
    all_projects = projects(projectroot)
    
    res = (None, None)
    for projectname, projectdir in all_projects:
        cur_shots = shots(projectroot, projectname)
        shotdir = shot_root_path(projectname)
        if filepath.lower().startswith(shotdir.lower()):

            filepath_end = filepath[len(shotdir):].strip(os.path.sep)
            curshot = None
            for shot in cur_shots:
                if filepath_end.lower().startswith(shot.lower()):
                    curshot = shot

            if curshot is not None:
                res = (projectname, curshot)

    return res
Example #6
0
def project_shot_from_path(filepath):
    """docstring for project_shot_from_file"""

    projectroot = project_root_path()
    all_projects = projects(projectroot)

    res = (None, None)
    for projectname, projectdir in all_projects:
        cur_shots = shots(projectroot, projectname)
        shotdir = shot_root_path(projectname)
        if filepath.lower().startswith(shotdir.lower()):

            filepath_end = filepath[len(shotdir):].strip(os.path.sep)
            curshot = None
            for shot in cur_shots:
                if filepath_end.lower().startswith(shot.lower()):
                    curshot = shot

            if curshot is not None:
                res = (projectname, curshot)

    return res