Seperate file read func#334
Conversation
| content = f.read() | ||
| except IOError: | ||
| return | ||
| lines = read_file_content(file_name) |
There was a problem hiding this comment.
Can you still use try and catch the exception? read_file_content is likely to throws an exception
There was a problem hiding this comment.
In that funcion, I check if the file exists, so it will only throws an exception when there are some exceptions in file I/O. In this case, shouldn't the exception be thrown?
There was a problem hiding this comment.
Ok, just saw if file exists is checked in that function.
| lines = read_file_content(file_name) | ||
| content = "" | ||
| for line in lines: | ||
| content = content + line |
There was a problem hiding this comment.
Any difference between lines and content?
There was a problem hiding this comment.
lines is a list, content is a str
There was a problem hiding this comment.
It used to use read() and now you use readlines and concat the lines. The content should be the same, right? I means the '\n' in each line is also included in content.
There was a problem hiding this comment.
In this case, the contents are not the same, but the code still works.
The difference is: when you use the former code(with '\n'(s) in the content), the strip func below will take effect,
while when you use the present code(without '\n's in the content), the strip func below doesn't need to take effect.
| spark_env_file = join(spark_home, "conf/spark-env.sh") | ||
| value = default_value | ||
|
|
||
| if(len(glob.glob(spark_env_file)) == 1): |
There was a problem hiding this comment.
Can we keep this if condition?
There was a problem hiding this comment.
I have moved this statement to read_file_content func
No description provided.