Exemple #1
0
    def Edited(self):
        # Get the current working directory of where the script is executed
        cwd = os.getcwd()

        # Check whether the current working directory exists
        grd.Filesystem.PathExist(cwd)

        # Obtain the name of the base directory of the current working directory
        shoot = os.path.basename(cwd)

        # Obtain the path to the base flow project
        pathToBaseflowProject = helper.FullFilePath(self.ctx.Config.Workspace,
                                                    self.ctx.Config.Selection,
                                                    shoot)

        # Check whether the the path to the base flow project exists
        grd.Filesystem.PathExist(pathToBaseflowProject)

        # Check whether you're within the baseflow directory
        grd.Filesystem.PathCwdExists(pathToBaseflowProject, cwd, True)

        # Obtain the absolute path to the edit flow of a shoot
        pathToShootInEditedFlow = helper.FullFilePath(
            self.ctx.Config.Workspace, self.ctx.Config.Edited, shoot)

        # Check whether you're within the edit flow shoot directory
        grd.Filesystem.PathExist(pathToShootInEditedFlow)

        # Open the correct edited directory
        os.system(f"explorer {pathToShootInEditedFlow}")
Exemple #2
0
def main(context):
    '''Main method where config data and workspace object are initialized
    
    Args:
        context (object): Global context object
    '''

    pathToConfig = helper.FullFilePath("config.json")

    # Check whether the path to the confile exists
    grd.Filesystem.PathExist(pathToConfig)

    with open(pathToConfig) as f:
        # if conext isn't initialized created a new dictionary
        if context.obj is None:
            context.obj = dict()

        # Load data from file
        data = json.load(f)
        lstConfig = []
        for d in data:
            lstConfig.append(
                poco.Config(d['workspace'], d['workflow'], d['baseflow'],
                            d['backup'], d['selection'], d['edited'],
                            d['preview'], d['editing'], d['instagram']))
        c = 1

        # Load the config data in the context variable
        #x = poco.Config(data['workspace'], data['workflow'], data['baseflow'], data['backup'], data['selection'], data['edited'], data['preview'], data['editing'], data['instagram'])
        #context.obj['config'] = poco.Config(data[c]['workspace'], data[c]['workflow'], data[c]['baseflow'], data[c]['backup'], data[c]['selection'], data[c]['edited'], data[c]['preview'], data[c]['editing'], data[c]['instagram'])
        context.obj['config'] = lstConfig
        # Load the workspace object into the context variable
        context.obj['workspaceObj'] = ws.Workspace(pathToConfig, context)
Exemple #3
0
def base(context, backup, massbackup, hash, rename, massrename, convert):
    '''Method to backup files from the baseflow project

    Args:
        context (object): Global context object
        backup (object): Make a copy of a picture in the backup flow
        massbackup (object): Make a copy of all pictures within the base flow and copy them to the backup flow
        rename (object): Rename a picture within the baseflow accordingly to it's shootname
        massrename (object): Rename all pictures within the baseflow accordingly to it's shootname
        convert (object): Convert a raw picture within the base flow to a jpg format and store it within the preview flow
    '''

    ctx = helper.Context(context)

    if backup:
        bs = baseflow.Base(ctx, backup[0])
        bs.Backup(backup[1])
    elif massbackup:
        bs = baseflow.Base(ctx, massbackup[0])
        bs.MassBackup()
    elif hash:
        bs = baseflow.Base(ctx, hash[0])
        bs.HashRename()
    elif rename:
        bs = baseflow.Base(ctx, rename[0])
        bs.Rename(rename[1], rename[2])
    elif massrename:
        bs = baseflow.Base(ctx, massrename[0])
        bs.MassRename()
    elif convert:
        bs = baseflow.Base(ctx, convert[0])
        bs.Convert(convert[1], convert[2])
Exemple #4
0
    def ShowConfig(self):
        '''Open the config location within an editor'''

        ctx = helper.Context(self.context)

        grd.Filesystem.PathExist(ctx.WorkspaceObj.location)
        os.system(f"start {ctx.WorkspaceObj.location}")
Exemple #5
0
def flow(context, completed, edited):
    ctx = helper.Context(context)

    fw = otherflow.Flow(ctx)
    if completed:
        fw.Completed()
    elif edited:
        fw.Edited()
Exemple #6
0
    def Create(self, index):
        '''Create a new workspace an initialize it with flows'''
        
        index = int(index)

        ctx = helper.Context(self.context)

        if not grd.Filesystem.IsPath(ctx.Config[index].Workspace):
            directory.CreateFolder(ctx.Config[index].Workspace)
        
        else:
            click.echo(f"Workspace {ctx.Config.Workspace} already exists")
Exemple #7
0
    def Completed(self):
        # Get the current working directory of where the script is executed
        cwd = os.getcwd()

        # Check whether the current working directory exists
        grd.Filesystem.PathExist(cwd)

        # Check whether the script is executed from the workspace directory
        grd.Filesystem.PathCwdExists(self.ctx.Config.Workspace, cwd)

        # Obtain the path to the the edit root directory
        pathToEditedRoot = helper.FullFilePath(self.ctx.Config.Workspace,
                                               self.ctx.Config.Edited)

        # Check whether the path to the edit root directory exists
        grd.Filesystem.PathExist(pathToEditedRoot)

        # Loopover every shoot within the edit directory
        for shoot in os.listdir(pathToEditedRoot):
            # Obtain the path to the shoot within the edit root directory
            pathToEditedShoots = helper.FullFilePath(pathToEditedRoot, shoot)

            # Check whether the shoot exists within the edit root directory
            grd.Filesystem.PathExist(pathToEditedShoots)

            # Amount of pictures within the edit shoot directory
            shootAmountPicturesEdited = len(os.listdir(pathToEditedShoots))

            pathToSelectedShoot = helper.FullFilePath(
                self.ctx.Config.Workspace, self.ctx.Config.Selection, shoot)
            grd.Filesystem.PathExist(pathToSelectedShoot)

            # Amount of pictures within the selection shoot directory
            shootAmountPicturesSelection = len(os.listdir(pathToSelectedShoot))

            # Check whether the amount of pictures are equal
            if shootAmountPicturesEdited != shootAmountPicturesSelection:
                print(f'Shoot: {shoot} is not fully edited')
Exemple #8
0
def shoot(context, new):
    '''Shoot option allows modification of a shoot within the workspace

    Args:
        context (object): Global context object
        new (object): Option to create a new shoot (<name> <date>) 
    '''

    ctx = helper.Context(context)

    if new:
        newShoot = f'{new[1]} {new[2]}'
        # Create a shoot object
        s = sht.Shoot(ctx, new[0], newShoot)
        # Creates the shoot
        s.Create()
Exemple #9
0
def workspace(context, create):
    '''Create a new workspace
    
    Args:
        context (object): Global context object
        create (object): Create a new workspace
    '''

    ctx = helper.Context(context)
    # Get the current working directory of where the script is executed
    cwd = os.getcwd()

    #Check whether the current working directory exists
    grd.Filesystem.PathExist(cwd)

    if create:
        ctx.WorkspaceObj.Create(create[0])
Exemple #10
0
def config(context, show, location, version):
    '''CLI command that handles the configuration file operations
    
    Args:
        context (object): Global context object
        view (object): Option that opens the configuration file
        location (object): Option that prints the configuration file location within the filesystem
    '''

    ctx = helper.Context(context)

    if show:
        ctx.WorkspaceObj.ShowConfig()
    elif location:
        ctx.WorkspaceObj.PrintConfig()
    elif version:
        ctx.WorkspaceObj.Version()
Exemple #11
0
    def Create(self):
        '''Creates a shoot within the workspace directory'''

        # Obtain the root directory of the new shoot
        shootRootPath = helper.FullFilePath(
            self.ctx.Config[self.index].Workspace, self.name)

        # Check whether the root directory of the new shoot exists
        if not grd.Filesystem.IsPath(shootRootPath):
            # Create a new shoot
            directory.CreateFolder(shootRootPath)
            # Check whether the shoot is successfully created
            grd.Filesystem.PathExist(shootRootPath)
        else:
            print('Path already exists')

        self.__CreateFlow(shootRootPath)
Exemple #12
0
    def __CreateFlow(self, root):
        ''' Create all flows configured in the config file

        Args:
            root (string): Root directory of the newly created shoot
        '''

        counter = 0

        #Loop-over the workflows
        for flow in self.ctx.Config[self.index].Workflow:
            pathToFlow = helper.FullFilePath(root, flow)

            # Only create non existing flows
            if not grd.Filesystem.IsPath(pathToFlow):
                directory.CreateFolder(pathToFlow)
                click.echo(f'Flow created: {pathToFlow}')
                counter += 1

        click.echo(f"Flows created: {counter}")
Exemple #13
0
    def PrintConfig(self):
        '''Print the configuration path location'''
        
        ctx = helper.Context(self.context)

        click.echo(ctx.WorkspaceObj.location)