Esempio n. 1
0
    def fileFromPath(self, file_path = ''):
        """Get File by path, also sets App, Asset and Project.
        @param file_path: String
        @return Bool
        """

        assert isinstance(file_path, basestring), 'file_path is not an instance of basestring.'

        file_path = unixPath(file_path)

        if self.projectFromPath(file_path):
            if self.assetFromPath(file_path):
                if self.appFromPath(file_path):
                    matching_files = filter(lambda x: file_path == x.path, self.app.files)

                    if matching_files:
                        self.file = matching_files.pop()

                        #print self.file.name

                        return True
                    else:
                        raise exceptions.MissingFile('No File recognized in {path}'.format(path = file_path))

        return False
Esempio n. 2
0
    def projectFromPath(self, project_path = ''):
        """Get Project by path.
        @param project_path: String
        @return Bool
        """

        assert isinstance(project_path, basestring), 'project_path is not an instance of basestring'

        project_path = unixPath(project_path)

        matching_projects = filter(lambda x: project_path.startswith(x.path), self.projects.children)

        if matching_projects:
            self.project = matching_projects.pop()

            #print self.project.name

            return True
        else:
            raise exceptions.MissingProject('No Project recognized in {path}'.format(path = project_path))

        return False
Esempio n. 3
0
    def assetFromPath(self, asset_path = ''):
        """Get Asset by path, also sets Project.
        @param asset_path: String
        @return Bool
        """

        assert isinstance(asset_path, basestring), 'asset_path is not an instance of basestring'

        asset_path = unixPath(asset_path)

        if self.projectFromPath(asset_path):
            matching_assets = filter(lambda x: asset_path.startswith(x.path), self.project.assets.children)

            if matching_assets:
                self.asset = matching_assets.pop()

                #print self.asset.name

                return True
            else:
                raise exceptions.MissingAsset('No Asset recognized in {path}'.format(path = asset_path))

        return False
Esempio n. 4
0
    def appFromPath(self, app_path = ''):
        """Get App by path, also sets Asset and Project.
        @param app_path: String
        @return Bool
        """

        assert isinstance(app_path, basestring), 'app_path is not an instance of basestring'

        app_path = unixPath(app_path)

        if self.projectFromPath(app_path):
            if self.assetFromPath(app_path):
                matching_apps = filter(lambda x: app_path.startswith(x.save.path), self.asset.applications)

                if matching_apps:
                    self.app = matching_apps.pop()

                    #print self.app.name

                    return True
                else:
                    raise exceptions.MissingApp('No App recognized in {path}'.format(path = app_path))

        return False