Return value description.\r
"""\r
\r
- if (text_file != ''):\r
- fp = open(text_file, 'rb')\r
- # Create a text/plain message\r
- text = (fp.read())\r
- fp.close()\r
+ if text_file != '':\r
+ with open(text_file, 'rb') as fp:\r
+ text = (fp.read())\r
return text\r
\r
\r
Return value description.\r
"""\r
\r
- if (text_file != ''):\r
- fp = open(text_file, 'wb')\r
- # Create a text/plain message\r
- fp.write(text)\r
- fp.close()\r
+ if text_file != '':\r
+ with open(text_file, 'wb') as fp:\r
+ fp.write(text)\r
return text\r
\r
\r
\r
if log_filename:\r
try:\r
- # This also doesn't seem like the best structure...\r
+ # TODO: Review statements.\r
# 3.1\r
try:\r
- log_handle = open(log_filename,\r
- mode='wt',\r
- encoding='utf-8')\r
+ log_handle = (\r
+ open(log_filename, mode='wt', encoding='utf-8'))\r
# 2.6\r
except:\r
- log_handle = open(log_filename,\r
- mode='wt')\r
+ log_handle = open(log_filename, mode='wt')\r
except:\r
print('Couldn\'t open log : %s' % log_filename)\r
log_handle = None\r