<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def do_stacks(self,args):
 """List available stacks. stacks -h for detailed help."""

        parser = CommandArgumentParser()
        parser.add_argument('-s','--silent',dest='silent',action='store_true',help='Run silently')
        parser.add_argument('-i','--include',nargs='*',dest='includes',default=[],help='Add statuses')
        parser.add_argument('-e','--exclude',nargs='*',dest='excludes',default=[],help='Remove statuses')
        parser.add_argument('--summary',dest='summary',action='store_true',default=False,help='Show just a summary')
        parser.add_argument(dest='filters',nargs='*',default=["*"],help='Filter stacks')
        args = vars(parser.parse_args(args))

        nextToken = None

        includes = args['includes']
        excludes = args['excludes']
        filters = args['filters']

        global stackStatusFilter
        for i in includes:            
            if not i in stackStatusFilter:
                stackStatusFilter.append(i)
        for e in excludes:
            stackStatusFilter.remove(e)

        complete = False;
        stackSummaries = []
        while not complete:
            if None == nextToken:
                stacks = AwsConnectionFactory.getCfClient().list_stacks(StackStatusFilter=stackStatusFilter)
            else:
                stacks = AwsConnectionFactory.getCfClient().list_stacks(NextToken=nextToken,StackStatusFilter=stackStatusFilter)
                #pprint(stacks)
            if not 'NextToken' in stacks:
                complete = True;
            else:
                nextToken = stacks['NextToken']

            if 'StackSummaries' in stacks:
                stackSummaries.extend(stacks['StackSummaries'])

        stackSummaries = filter( lambda x: fnmatches(x['StackName'],filters),stackSummaries)
        stackSummaries = sorted(stackSummaries, key= lambda entry: entry['StackName'])
        index = 0;
        stackSummariesByIndex = {}
        for summary in stackSummaries:
            summary['Index'] = index
            stackSummariesByIndex[index] = summary
            index += 1

        self.stackList = stackSummariesByIndex
        if not (args['silent'] or args['summary']):
            for index,summary in stackSummariesByIndex.items():
                print '{0:3d}: {2:20} {1:40} {3}'.format(summary['Index'],summary['StackName'],summary['StackStatus'],defaultifyDict(summary,'StackStatusReason',''))

        if args['summary'] and not args['silent']:
            print '{} stacks'.format(len(stackSummariesByIndex))