Skip to content

Commit

Permalink
prepares release with URN check
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Dec 28, 2023
1 parent 5e9282c commit 3ed4095
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ceurws/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.3"
__version__ = "0.3.2"
5 changes: 3 additions & 2 deletions ceurws/urn.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ class URN:

@classmethod
def check_urn_checksum(cls, urn: str, debug: bool = False) -> bool:
expected_check_digit = int(urn[-1])
urn_check_digit_str=urn[-1]
urn_prefix = urn[:-1]
check_digit = cls.calc_urn_checksum(urn_prefix, debug)
return check_digit == expected_check_digit
urn_ok = str(check_digit) == urn_check_digit_str
return urn_ok

@classmethod
def calc_urn_checksum(cls, test_urn: str, debug: bool = False) -> int:
Expand Down
11 changes: 6 additions & 5 deletions ceurws/volumeparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ def check_parsed_dict(self,parsed_dict:dict):
"""
if "urn" in parsed_dict:
urn=parsed_dict["urn"]
urn_prefix = urn[:-1]
check_digit=URN.calc_urn_checksum(urn_prefix)
parsed_dict["urn_check_digit"]=check_digit
urn_ok=URN.check_urn_checksum(urn)
parsed_dict["urn_ok"]=urn_ok
if urn:
urn_prefix = urn[:-1]
check_digit=URN.calc_urn_checksum(urn_prefix)
parsed_dict["urn_check_digit"]=check_digit
urn_ok=URN.check_urn_checksum(urn)
parsed_dict["urn_ok"]=urn_ok

def parse(self, url: str) -> dict:
"""
Expand Down

0 comments on commit 3ed4095

Please sign in to comment.