doit/action.py
def expand_action(self):
        """Expand action using task meta informations if action is a string.
        Convert `Path` elements to `str` if action is a list.
        @returns: string -> expanded string if action is a string
                  list - string -> expanded list of command elements
        """
        if not self.task:
            return self.action

        # cant expand keywords if action is a list of strings
        if isinstance(self.action, list):
            action = []
            for element in self.action:
                if isinstance(element, str):
                    action.append(element)
                elif isinstance(element, PurePath):
                    action.append(str(element))
                else:
                    msg = ("%s. CmdAction element must be a str " +
                           "or Path from pathlib. Got '%r' (%s)")
                    raise InvalidTask(
                        msg % (self.task.name, element, type(element)))
            return action

        subs_dict = {
            'targets' : " ".join(self.task.targets),
            'dependencies': " ".join(self.task.file_dep),
        }

        # dep_changed is set on get_status()
        # Some commands (like `clean` also uses expand_args but do not
        # uses get_status, so `changed` is not available.
        if self.task.dep_changed is not None:
            subs_dict['changed'] = " ".join(self.task.dep_changed)

        # task option parameters
        subs_dict.update(self.task.options)
        # convert positional parameters from list space-separated string
        if self.task.pos_arg:
            if self.task.pos_arg_val:
                pos_val = ' '.join(self.task.pos_arg_val)
            else:
                pos_val = ''
            subs_dict[self.task.pos_arg] = pos_val

        if self.STRING_FORMAT == 'old':
            return self.action % subs_dict
        elif self.STRING_FORMAT == 'new':
            return self.action.format(**subs_dict)
        else:
            assert self.STRING_FORMAT == 'both'
            return self.action.format(**subs_dict) % subs_dict
Expand action using task meta informations if action is a string.
        Convert `Path` elements to `str` if action is a list.
        @returns: string -> expanded string if action is a string
                  list - string -> expanded list of command elements
        
Expand action using task meta informations if action is a string.
Convert `Path` elements to `str` if action is a list.
Expand action using task meta informations if action is a string . Convert ` Path ` elements to ` str ` if action is a list .
def expand_action(self):
        if not self.task:
            return self.action
        if isinstance(self.action, list):
            action = []
            for element in self.action:
                if isinstance(element, str):
                    action.append(element)
                elif isinstance(element, PurePath):
                    action.append(str(element))
                else:
                    msg = ("%s. CmdAction element must be a str " +
                           "or Path from pathlib. Got '%r' (%s)")
                    raise InvalidTask(
                        msg % (self.task.name, element, type(element)))
            return action
        subs_dict = {
            'targets' : " ".join(self.task.targets),
            'dependencies': " ".join(self.task.file_dep),
        }
        if self.task.dep_changed is not None:
            subs_dict['changed'] = " ".join(self.task.dep_changed)
        subs_dict.update(self.task.options)
        if self.task.pos_arg:
            if self.task.pos_arg_val:
                pos_val = ' '.join(self.task.pos_arg_val)
            else:
                pos_val = ''
            subs_dict[self.task.pos_arg] = pos_val
        if self.STRING_FORMAT == 'old':
            return self.action % subs_dict
        elif self.STRING_FORMAT == 'new':
            return self.action.format(**subs_dict)
        else:
            assert self.STRING_FORMAT == 'both'
            return self.action.format(**subs_dict) % subs_dict
def expand_action ( self ) : if not self . task : return self . action if isinstance ( self . action , list ) : action = [ ] for element in self . action : if isinstance ( element , str ) : action . append ( element ) elif isinstance ( element , PurePath ) : action . append ( str ( element ) ) else : msg = ( "%s. CmdAction element must be a str " + "or Path from pathlib. Got '%r' (%s)" ) raise InvalidTask ( msg % ( self . task . name , element , type ( element ) ) ) return action subs_dict = { 'targets' : " " . join ( self . task . targets ) , 'dependencies' : " " . join ( self . task . file_dep ) , } if self . task . dep_changed is not None : subs_dict [ 'changed' ] = " " . join ( self . task . dep_changed ) subs_dict . update ( self . task . options ) if self . task . pos_arg : if self . task . pos_arg_val : pos_val = ' ' . join ( self . task . pos_arg_val ) else : pos_val = '' subs_dict [ self . task . pos_arg ] = pos_val if self . STRING_FORMAT == 'old' : return self . action % subs_dict elif self . STRING_FORMAT == 'new' : return self . action . format ( ** subs_dict ) else : assert self . STRING_FORMAT == 'both' return self . action . format ( ** subs_dict ) % subs_dict
Expand action using task meta informations if action is a string.
Expand action using task meta informations if action is a string .
"""Expand action using task meta informations if action is a string.
        Convert `Path` elements to `str` if action is a list.
        @returns: string -> expanded string if action is a string
                  list - string -> expanded list of command elements
        """ # cant expand keywords if action is a list of strings # dep_changed is set on get_status() # Some commands (like `clean` also uses expand_args but do not # uses get_status, so `changed` is not available. # task option parameters # convert positional parameters from list space-separated string
self
returns
> expanded string if action is a string
list - string -> expanded list of command elements
> expanded string if action is a string list - string - > expanded list of command elements