+def remove_newlines(x):
+ return x.replace('\n', '')
+
+
+def strip_whitespace(x):
+ return x.strip()
+
+
+def remove_hash_comments(x):
+ return re.sub(r'#.*$', '', x)
+
+
+def read_file_to_list(
+ filename: str, *, skip_blank_lines=False, line_transformations=[]
+):
+ ret = []
+ if not file_is_readable(filename):
+ raise Exception(f'{filename} can\'t be read.')
+ with open(filename) as rf:
+ for line in rf:
+ for transformation in line_transformations:
+ line = transformation(line)
+ if skip_blank_lines and line == '':
+ continue
+ ret.append(line)
+ return ret
+
+