def controller_scan(directory=None):
    if directory is None:
        return []

    def find_controllers(dirname, prefix=''):
        """Locate controllers in a directory"""
        controllers = []
        for fname in os.listdir(dirname):
            filename = os.path.join(dirname, fname)
            if os.path.isfile(filename) and \
                    re.match('^[^_]{1,1}.*\.py$', fname):
                controllers.append(prefix + fname[:-3])
            elif os.path.isdir(filename):
                controllers.extend(find_controllers(filename,
                                                    prefix=prefix+fname+'/'))
        return controllers
    controllers = find_controllers(directory)
    # Sort by string length, shortest goes first
    controllers.sort(key=len, reverse=True)
    return controllers
Scan a directory for python files and use them as controllers
dataset/ETHPy150Open bbangert/routes/routes/util.py/controller_scan