def search_require_modules(project_dir):
    grep_cmd = "find {} -name '*.py' | grep -v -E '*_pb2\\.py' | grep -v -E '*_pb2_grpc\\.py' | grep -v -E 'workflow\\.py' | xargs -n1 cat | grep -E '^import|^from'".format(project_dir)
    print(grep_cmd)
    p = subprocess.Popen(grep_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    (stdout, stderr) = p.communicate()
    import_lines = stdout.decode('utf-8').strip().split('\n')
    python_standard_modules = get_python_standard_modules('3.6')
    require_modules = set()
    require_lines = dict()
    all_imports = set()
    for line in import_lines:
        import_module = re.sub('^import |^from ', '', line).split(' ')[0].strip()
        require_module = import_module.split('.')[0]
        if (len(require_module) == 0):
            continue
        if (',' in require_module):
            tmp = require_module.split(',')
        else:
            tmp = [require_module]
        for r_m in tmp:
            if r_m.startswith('.'):
                continue
            if r_m.endswith('_pb2'):
                continue
            if (r_m in USE_SOURCE_MODULES):
                continue
            all_imports.add(line.strip())
            if (r_m in python_standard_modules):
                continue
            if (r_m in CUSTOM_MODULES):
                continue
            require_modules.add(r_m)
            require_lines[r_m] = line.strip()
    return (require_modules, require_lines, all_imports)
def search_require_modules(project_dir):
    grep_cmd = "find {} -name '*.py' | grep -v -E '*_pb2\\.py' | grep -v -E '*_pb2_grpc\\.py' | grep -v -E 'workflow\\.py' | xargs -n1 cat | grep -E '^import|^from'".format(project_dir)
    print(grep_cmd)
    p = subprocess.Popen(grep_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    (stdout, stderr) = p.communicate()
    import_lines = stdout.decode('utf-8').strip().split('\n')
    python_standard_modules = get_python_standard_modules('3.6')
    require_modules = set()
    require_lines = dict()
    all_imports = set()
    for line in import_lines:
        import_module = re.sub('^import |^from ', , line).split(' ')[0].strip()
        require_module = import_module.split('.')[0]
        if (len(require_module) == 0):
            continue
        if (',' in require_module):
            tmp = require_module.split(',')
        else:
            tmp = [require_module]
        for r_m in tmp:
            if r_m.startswith('.'):
                continue
            if r_m.endswith('_pb2'):
                continue
            if (r_m in USE_SOURCE_MODULES):
                continue
            all_imports.add(line.strip())
            if (r_m in python_standard_modules):
                continue
            if (r_m in CUSTOM_MODULES):
                continue
            require_modules.add(r_m)
            require_lines[r_m] = line.strip()
    return (require_modules, require_lines, all_imports)