def getPackages(dname, pkgname=None, results=None, ignore=None, parent=None):
 parent = (parent or '')
 prefix = []
 if parent:
  prefix = [parent]
 bname = os.path.basename(dname)
 ignore = (ignore or [])
 if (bname in ignore):
  return []
 if (results is None):
  results = []
 if (pkgname is None):
  pkgname = []
 subfiles = os.listdir(dname)
 abssubfiles = [os.path.join(dname, x) for x in subfiles]
 if ('__init__.py' in subfiles):
  results.append(((prefix + pkgname) + [bname]))
  for subdir in filter(os.path.isdir, abssubfiles):
   getPackages(subdir, pkgname=(pkgname + [bname]), results=results, ignore=ignore, parent=parent)
 res = ['.'.join(result) for result in results]
 return res

def getPackages ( dname , pkgname = None , results = None , ignore = None , parent = None ) : parent = ( parent or '' ) prefix = [ ] if parent : prefix = [ parent ] bname = os . path . basename ( dname ) ignore = ( ignore or [ ] ) if ( bname in ignore ) : return [ ] if ( results is None ) : results = [ ] if ( pkgname is None ) : pkgname = [ ] subfiles = os . listdir ( dname ) abssubfiles = [ os . path . join ( dname , x ) for x in subfiles ] if ( '__init__.py' in subfiles ) : results . append ( ( ( prefix + pkgname ) + [ bname ] ) ) for subdir in filter ( os . path . isdir , abssubfiles ) : getPackages ( subdir , pkgname = ( pkgname + [ bname ] ) , results = results , ignore = ignore , parent = parent ) res = [ '.' . join ( result ) for result in results ] return res
get all packages which are under dname .