def removeby_another_filter(self): """ Remove by another filter if not it is "completed" :param self: self instance :returns: void """ exists = self.check_if_tasks_exists(self.app.args.removeby, self.app.args.value) if exists is False: fatal([ 'Invalid flag "value"', 'The task with "{}" "{}" not found'.format( self.app.args.removeby, self.app.args.value), 'To show the tasks use instead', '$ tasks-app show', ]) (task, ) = self.get_task(self.app.args.removeby, self.app.args.value) # Getting task data, struct = (description, fulldescription, completed (0 False, 1 True),) description = task[0] fulldescription = task[1] completed = task[2] if completed == 0: completed = 'Incompleted' else: completed = 'Completed' print('Selecting the task with description = "{}"'.format(description)) print( 'NOTE: Your value "{}" of filter "{}" like with description "{}"'. format(self.app.args.value, self.app.args.removeby, description)) print('NOTE: The complete task is:') print('NOTE: {} - {} ({})'.format(description, fulldescription, completed)) print('Do you want to continue?') cont = confirm('Remove?') if cont is True: ok = self.remove_task(self.app.args.removeby, self.app.args.value) if ok is True: success([ 'The task with {} description'.format(description), 'was deleted successfully', 'to verify these use instead:', '$ tasks-app show --filter=description --value={}'.format( description), 'if the output is none results all are ok!', ])
def removeby_completed_filter(self): """ Remove all tasks with the completed status :param self: self instance :returns: void """ if self.app.args.value == 'True': value = 1 else: value = 0 # Getting all task with completed status conn = sqlite3.connect(DATABASE['file']) cur = conn.cursor() cur.execute('SELECT * FROM Tasks WHERE completed = {}'.format(value)) tasks = list(cur) conn.close() # Checking the task len if len(tasks) == 0: fatal([ 'No tasks found with completed = {}'.format( self.app.args.value) ]) # Showing selected tasks print('Selected tasks:') for description, fulldescription, completed in tasks: if completed == 0: completed = 'Incompleted' else: completed = 'Completed' print(' > {} - {} ({})'.format(description, fulldescription, completed)) print('NOTE: because the value {} i want selected the before list'. format(self.app.args.value)) print('Do you want to continue?') cont = confirm('Remove?') if cont is True: for task in tasks: description = task[0] # Task description ok = self.remove_task('description', description) if ok is True: success(['Removed {}'.format(description)])
def op_delete_ip(d42): ''' Delete a ip. Required Parameters: ip_id ''' if not check_deps(d42.params, ['ip_id']): d42.err('Required options were not found: ip_id', 115) return False if not d42.opts.misc_yes: if not confirm('Are you sure you want to delete the given ip?'): d42.err('Terminated at user request', 119) return False ret = d42.api('/ips/{}/'.format(d42.params['ip_id']), post=d42.params, delete=True) if not ret['result']: d42.err('API Error', 116, ret['data']) return False d42.out(ret['data']) return True
def op_delete_subnet(d42): ''' Delete a subnet. Required Parameters: subnet_id ''' if not check_deps(d42.params, ['subnet_id']): d42.err('Required options were not found: subnet_id', 130) return False if not d42.opts.misc_yes: if not confirm('Are you sure you want to delete the given subnet?'): d42.err('Terminated at user request', 134) return False ret = d42.api('/subnets/{}/'.format(d42.params['subnet_id']), post=d42.params, delete=True) if not ret['result']: d42.err('API Error', 131, ret['data']) return False d42.out(ret['data']) return True
def remove_without_filter(self): """ Remove a task without filter. default filter is: "description" :param self: self instance :returns: void """ exists = self.check_if_tasks_exists('description', self.app.args.value) if exists is False: fatal([ 'Invalid flag "value"', 'The task with "description" "{}" not found'.format( self.app.args.value), 'To show the tasks use instead:', '$ tasks-app show', ]) (task, ) = self.get_task('description', self.app.args.value) description = task[ 0] # The task description, struct is: (description, fulldescription, completed,) print('Selecting the task with description = "{}"'.format(description)) print('NOTE: Your value "{}" like with "{}"'.format( self.app.args.value, description)) print('Do you want to continue?') cont = confirm('Remove?') if cont is True: ok = self.remove_task('description', self.app.args.value) if ok is True: success([ 'The task with {} description'.format(description), 'was deleted successfully', 'to verify these use instead:', '$ tasks-app show --filter=description --value={}'.format( description), 'if the output is none results all are ok!' ])
def run(self): """ Main method :param self: self instance :returns: void """ ok = self.validate_newcompleted() if ok is False: fatal([ 'Invalid flag "newcompleted"', 'the available values for newcompleted are True|False', 'Use instead:', '$ tasks-app edit --description="{}" --newdescription="{}" --newfulldescription="{}" --newcompleted=True|False' .format(self.app.args.description, self.app.args.newdescription, self.app.args.newfulldescription) ]) self.app.args.newcompleted = self.process_new_completed_arg() exists = self.check_if_exists_task() if exists is True: fatal([ 'The task with description "{}" was exists'.format( self.app.args.newdescription), 'to get all tasks. Use instead:', '$ tasks-app show', ]) selected_task = self.get_selected_task() if selected_task is None: fatal([ 'Invalid task to search with "description" LIKE "{}"'.format( self.app.args.description), 'The task with description like to "{}" doesn\'t exists'. format(self.app.args.description), 'To show all tasks use instead:', '$ tasks-app show', ]) # Getting the selected task data, struct = (description, fulldescription, completed 0|1) description = selected_task[0] fulldescription = selected_task[1] completed = selected_task[2] if completed == 0: completed = 'Incompleted' else: completed = 'Completed' print('NOTE: Selected the task with description = "{}"'.format( description)) print('NOTE: Your description "{}" like with description "{}"'.format( self.app.args.description, description)) print('NOTE: The complete task format is:') print('NOTE: {} - {} ({})'.format(description, fulldescription, completed)) print('Do you want to update to:') description = self.app.args.newdescription fulldescription = self.app.args.newfulldescription completed = self.app.args.newcompleted if completed == 0: completed = 'Incompleted' else: completed = 'Completed' print('{} - {} ({})'.format(description, fulldescription, completed)) cont = confirm('Update?') if cont is True: ok = self.update() if ok is True: success([ 'The task with description = "{}"'.format( selected_task[0]), 'was update successfully to verify these', 'Use instead:', '$ tasks-app show --filter=description --value="{}"'. format(self.app.args.newdescription) ])