<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_ls(argdict):
    '''List pages.'''
    site = make_site_obj(argdict)
    if not site.tree_ready:
        print "Cannot list pages. You are not within a simplystatic \
tree and you didn't specify a directory."
        sys.exit()
    drafts = argdict['drafts']
    recent = argdict['recent']
    dir = site.dirs['source']

    r = site.get_page_names()
    if drafts:
        fr = [os.path.join(dir,pn , pn+".md") for pn in r]
        cpat = re.compile('status:\s+draft') #compiled pattern
        i=0
        print ''
        for f in fr:
            fcontent = open(f,'r').read().lower()
            res = cpat.search(fcontent)
            if res:
                print r[i]
            i += 1
        print ''
    else:
        if recent:
            fr = [os.path.join(dir,pn , pn+".md") for pn in r]
            bmt = 0
            i = 0
            for f in fr:
                mt = os.path.getmtime(f)
                if mt > bmt:
                    bmt = mt
                    fname = r[i]
                i += 1
            print '\n' + fname + '\n'
        else:
            print  '\n' + '\n'.join(r) + '\n'