Skip to content

Commit

Permalink
fix python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
BjornFJohansson committed Dec 7, 2023
1 parent 75635b4 commit e8eddfa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pydna/seqrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,20 @@ def __repr__(self):

def __format__(self, format):
"""docstring."""

def removeprefix(text, prefix):
"""Until Python 3.8 is dropped, then use str.removeprefix."""
if text.startswith(prefix):
return text[len(prefix) :]
return text

if format == "pydnafasta":
return _pretty_str(
f">{self.id} {len(self)} bp {dict(((True,'circular'),(False,'linear')))[self.seq.circular]}\n{str(self.seq)}\n"
)
if format == "primer":
return _pretty_str(
f">{self.id} {len(self)}-mer {self.description.removeprefix(self.name).strip()}\n{str(self.seq)}\n"
f">{self.id} {len(self)}-mer {removeprefix(self.description, self.name).strip()}\n{str(self.seq)}\n"
)
return _pretty_str(super().__format__(format))

Expand Down

0 comments on commit e8eddfa

Please sign in to comment.