I am searching a way to check if there is a blank space next to the found keywords if so break the loop till it again finds the keyword.
For example here, I have a keyword:
'/* Function Declarations */'
If this keyword is found the loop will proceed further and check for the next set of keywords:
['(const ', '(unsigned ', '(char ', '(double ', '(int ', '(long ', '(long long ', '(float ', '(string ', '(signed ', ');']
If this is also satisfied the line will be sent to another function for processing. Until there is an empty space. This is what I wanted to achieve in this function. But unfortunately it ignores the empty space constrain and it satisfies only the first two
I have herewith attached the function:
def find_member_functions(opened_file, opened_cpp_file):
previous_keyword = '/* Function Declarations */'
member_func_keyword = ['(const ', '(unsigned ', '(char ',
'(double ', '(int ', '(long ',
'(long long ', '(float ', '(string ',
'(signed ', ');']
for line in opened_cpp_file:
prev_keyword_matched = [True for match in prev_keyword if match in line]
if True in prev_keyword_matched:
member_func_keyword_matched = [True for match in member_func_keyword if match in line]
if True in member_func_keyword_matched:
if line == '\n':
print "End of function declaration"
break
else:
found_funcs = member_functions(opened_file, line)
print str(found_funcs)
return
I then edited my code yet, I am not able to achieve what I wanted to. In this code, it says an empty line "End of member functions" even though it is not the end. The line which I am executing is
/* Function Declarations */
extern void multiplyImage(const unsigned char img[2115216], double parameter,
unsigned char imgout[2115216]);
blabla.....
The functions finds the next line as a space though I have the continuation of the function
unsigned char imgout[2115216]);
My edited code:
def Find_Member_Functions(Opened_File, Opened_Cpp_File):
Previous_Line_Keyword = '/* Function Declarations */'
Member_Function_Keyword = ['(const ', '(unsigned ', '(char ', '(double ', '(int ', '(long ', '(long long ', '(float ', '(string ', '(signed ', ');']
Empty_Line = ['\n', '\r\n']
for item in Member_Function_Keyword:
for line in Opened_Cpp_File:
Previous_Line_Keyword_Matched = [True for match in Previous_Line_Keyword if match in line]
if True in Previous_Line_Keyword_Matched:
Member_Function_Keyword_Matched = [True for match in Member_Function_Keyword if match in line]
if True in Member_Function_Keyword_Matched:
Found_Functions = Member_Functions(Opened_File, line)
print str(Found_Functions)
Next_Line = line[1:]
Empty_Line_Matched = [True for match in Empty_Line if match in Next_Line]
if True in Empty_Line_Matched:
print "End of member functions"
break
else:
pass
return
I couldn't understand where I am going wrong. It would be great to have some guidance...
My command line output
extern void multiplyImage(const unsigned char img[2115216], double parameter,
End of member functions
unsigned char imgout[2115216]);
End of member functions