Def deal_import (origin_code) :
Import_list=[]
Origin_code=origin_code. The lower ()
Code_lines=removeComments (origin_code)
One_split_list=code_lines. Split (" import ")
For twosplit one_split_list in:
Two_spilt_list=twosplit. Split (" from ")
Remove_list=remmove_empty (two_spilt_list)
If len (remove_list)!=0:
Rmas_list=rm_as (remove_list)
Import_list=import_list + rmas_list
Code_def=import_list [1]
Code_import=import_list
Code_import. Pop ()
Code_import=list (set (code_import))
Code_import. Sort ()
Return code_import, code_def
As code, I want to extract the data stream,
In this code, enter the function's parameters for origin_code
Origin_code=origin_code. The lower ()
In this line, origin_code into origin_code (is actually no change)
Code_lines=removeComments (origin_code)
In this line of code that is converted into origin_code code_lines
The same method, find out the data flow:
Origin_code - & gt; Code_lines - & gt; One_split_list - & gt; Twosplit - & gt; Two_spilt_list - & gt; Remove_list - & gt; Rmas_list - & gt; Import_list - & gt; Code_def
Origin_code - & gt; Code_lines - & gt; One_split_list - & gt; Twosplit - & gt; Two_spilt_list - & gt; Remove_list - & gt; Rmas_list - & gt; Import_list - & gt; Import_list
Data flow is one of the two, but choose the longest data flow,
If is very complex, it if it can not judge,
Remmove_empty (two_spilt_list)
Its internal for the custom function we don't, that is, whatever it is that if the data flow
Don't know how to implement the code, I hope will be the bosses can give can implement code, thank you