Skip to content

Commit

Permalink
Merge pull request #549 from Proteobench/peaks_parameters
Browse files Browse the repository at this point in the history
Peaks parameters
  • Loading branch information
RobbinBouwmeester authored Jan 24, 2025
2 parents 951bf09 + bd457e5 commit b52149e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions proteobench/io/params/peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,17 @@ def read_peaks_settings(file_path: str) -> ProteoBenchParameters:
"""
# Try to read the file contents

try:
# Attempt to open and read the file
with open(file_path, encoding="utf-8") as f:
lines = f.readlines()
except Exception as e:
raise IOError(f"Failed to open or read the file at {file_path}. Error: {e}")
# Check if file_path is an UploadedFile instance
if hasattr(file_path, "read"):
# Assume it behaves like a file object
lines = file_path.read().decode("utf-8").splitlines()
else:
try:
# Attempt to open and read the file
with open(file_path, encoding="utf-8") as f:
lines = f.readlines()
except Exception as e:
raise IOError(f"Failed to open or read the file at {file_path}. Error: {e}")

# Remove any trailing newline characters from each line
lines = [line.strip() for line in lines]
Expand Down

0 comments on commit b52149e

Please sign in to comment.