Skip to content

Commit 2553832

Browse files
authored
Merge pull request #248 from pbashyal-nmdp/fix_error_when_maccodes
Validate MAC codes is alpha before looking up in db
2 parents 6b26931 + ff7d43f commit 2553832

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pyard/ard.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#
2424
import functools
2525
import re
26+
import sqlite3
2627
import sys
2728
from typing import Iterable, List
2829

@@ -473,7 +474,11 @@ def is_mac(self, allele: str) -> bool:
473474
"""
474475
if ":" in allele:
475476
code = allele.split(":")[1]
476-
return db.is_valid_mac_code(self.db_connection, code)
477+
try:
478+
if code.isalpha():
479+
return db.is_valid_mac_code(self.db_connection, code)
480+
except sqlite3.OperationalError as e:
481+
print("Error: ", e)
477482
return False
478483

479484
def is_v2(self, allele: str) -> bool:

0 commit comments

Comments
 (0)