def find_includes(basedirs, source, log=None):
 all_basedirs = [os.path.dirname(source)]
 all_basedirs.extend(basedirs)
 includes = set()
 with open(source, u'r') as thrift:
  for line in thrift.readlines():
   match = INCLUDE_PARSER.match(line)
   if match:
    capture = match.group(1)
    added = False
    for basedir in all_basedirs:
     include = os.path.join(basedir, capture)
     if os.path.exists(include):
      if log:
       log.debug(u'{} has include {}'.format(source, include))
      includes.add(include)
      added = True
    if (not added):
     raise ValueError(u'{} included in {} not found in bases {}'.format(include, source, all_basedirs))
 return includes

def find_includes ( basedirs , source , log = None ) : all_basedirs = [ os . path . dirname ( source ) ] all_basedirs . extend ( basedirs ) includes = set ( ) with open ( source , u'r' ) as thrift : for line in thrift . readlines ( ) : match = INCLUDE_PARSER . match ( line ) if match : capture = match . group ( 1 ) added = False for basedir in all_basedirs : include = os . path . join ( basedir , capture ) if os . path . exists ( include ) : if log : log . debug ( u'{} has include {}' . format ( source , include ) ) includes . add ( include ) added = True if ( not added ) : raise ValueError ( u'{} included in {} not found in bases {}' . format ( include , source , all_basedirs ) ) return includes
finds all thrift files included by the given thrift source .