@printing_func
def extract_scala_imports(source_files_content):
 packages = set()
 import_re = re.compile(u'^import ([^;]*);?$')
 for filecontent in source_files_content.dependencies:
  for line in filecontent.content.splitlines():
   match = import_re.search(line)
   if match:
    packages.add(match.group(1).rsplit(u'.', 1)[0])
 return ImportedJVMPackages([JVMPackageName(p) for p in packages])

@ printing_func def extract_scala_imports ( source_files_content ) : packages = set ( ) import_re = re . compile ( u'^import ([^;]*);?$' ) for filecontent in source_files_content . dependencies : for line in filecontent . content . splitlines ( ) : match = import_re . search ( line ) if match : packages . add ( match . group ( 1 ) . rsplit ( u'.' , 1 ) [ 0 ] ) return ImportedJVMPackages ( [ JVMPackageName ( p ) for p in packages ] )
a toy example of dependency inference .