From 0069d7fdc595857bfb102cc7866f2411a627478c Mon Sep 17 00:00:00 2001 From: lordwelch Date: Fri, 16 Aug 2019 13:42:04 -0700 Subject: [PATCH] issue string parsing now strips off (# of #) (e.g. 1 of 45) --- comicapi/issuestring.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/comicapi/issuestring.py b/comicapi/issuestring.py index 2f441c1..63b0d5d 100644 --- a/comicapi/issuestring.py +++ b/comicapi/issuestring.py @@ -38,20 +38,19 @@ class IssueString: if text is None: return - if isinstance(text, int): - text = str(text) + text = str(text) if len(text) == 0: return - text = str(text) - # skip the minus sign if it's first if text[0] == '-': start = 1 else: start = 0 + text = text.strip(' \t\r\n()') + # if it's still not numeric at start skip it if text[start].isdigit() or text[start] == ".": # walk through the string, look for split point (the first @@ -81,9 +80,16 @@ class IssueString: part1 = text[0:idx] part2 = text[idx:len(text)] + if "of" in part2: + part2, _, after = part2.partition("of") + after = after.strip() + for char in after: + if char not in "0123456789.": + part2 = part2 + char + if part1 != "": self.num = float(part1) - self.suffix = part2 + self.suffix = part2.strip() else: self.suffix = text