def scan_readme_files(dirname):
 samples = []
 keyword_set = set()
 for (root, dirs, files) in os.walk(dirname):
  if ('README' in files):
   filename = os.path.join(root, 'README')
   with open(filename, 'r') as f:
    content = f.read()
    lines = content.splitlines()
    desc = ' '.join(itertools.takewhile((lambda x: x), lines))
    api = get_lines('api', lines)
    keywords = get_lines('keywords', lines)
    uri = get_lines('uri', lines)
    if (not uri):
     uri = None
    for k in keywords:
     if (k not in KEYWORDS):
      raise ValueError(('%s is not a valid keyword in file %s' % (k, filename)))
    keyword_set.update(keywords)
    if (not api):
     api = [None]
    samples.append((api[0], keywords, root[1:], desc, uri))
 samples.sort()
 return (samples, keyword_set)

def scan_readme_files ( dirname ) : samples = [ ] keyword_set = set ( ) for ( root , dirs , files ) in os . walk ( dirname ) : if ( 'README' in files ) : filename = os . path . join ( root , 'README' ) with open ( filename , 'r' ) as f : content = f . read ( ) lines = content . splitlines ( ) desc = ' ' . join ( itertools . takewhile ( ( lambda x : x ) , lines ) ) api = get_lines ( 'api' , lines ) keywords = get_lines ( 'keywords' , lines ) uri = get_lines ( 'uri' , lines ) if ( not uri ) : uri = None for k in keywords : if ( k not in KEYWORDS ) : raise ValueError ( ( '%s is not a valid keyword in file %s' % ( k , filename ) ) ) keyword_set . update ( keywords ) if ( not api ) : api = [ None ] samples . append ( ( api [ 0 ] , keywords , root [ 1 : ] , desc , uri ) ) samples . sort ( ) return ( samples , keyword_set )
scans all subdirs of dirname for readme files .