From 9a9d97f3bbeb742e2c126676cbc61f23c55c80fa Mon Sep 17 00:00:00 2001 From: lordwelch Date: Sat, 14 May 2022 01:57:28 -0700 Subject: [PATCH] Fix #291 ComicTagger now accounts for any single unicode numeric value --- comicapi/issuestring.py | 6 +++--- tests/issuestring_test.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/comicapi/issuestring.py b/comicapi/issuestring.py index 2d0eb86..6775d07 100644 --- a/comicapi/issuestring.py +++ b/comicapi/issuestring.py @@ -21,6 +21,7 @@ comics industry throws at us. import logging +import unicodedata logger = logging.getLogger(__name__) @@ -113,9 +114,8 @@ class IssueString: def as_float(self): # return the float, with no suffix - if self.suffix == "½": - if self.num is not None: - return self.num + 0.5 + if len(self.suffix) == 1 and self.suffix.isnumeric(): + return (self.num or 0) + unicodedata.numeric(self.suffix) return 0.5 return self.num diff --git a/tests/issuestring_test.py b/tests/issuestring_test.py index b423961..5d9d2af 100644 --- a/tests/issuestring_test.py +++ b/tests/issuestring_test.py @@ -3,6 +3,7 @@ import pytest import comicapi.issuestring issues = [ + ("¼", 0.25), ("1½", 1.5), ("0.5", 0.5), ("0", 0.0),