Permalink
Browse files

Allowed for ISBN checkdigit x/X in Record.isbn

  • Loading branch information...
godmar committed Mar 12, 2012
1 parent 68b27a2 commit 5a4b77ab0a2a3758320671260f9e7e860f8371cb
Showing with 7 additions and 2 deletions.
  1. +3 −2 pymarc/record.py
  2. +4 −0 test/record.py
View
@@ -67,7 +67,7 @@ def sentinel():
finally:
del chain
-isbn_regex = re.compile(r'([0-9\-]+)')
+isbn_regex = re.compile(r'([0-9\-xX]+)')
class Record(object):
"""
@@ -351,7 +351,8 @@ def title(self):
def isbn(self):
"""
Returns the first ISBN in the record or None if one is not
- present. The returned ISBN will be all numberic; so dashes and
+ present. The returned ISBN will be all numeric, except for an
+ x/X which may occur in the checksum position. Dashes and
extraneous information will be automatically removed. If you need
this information you'll want to look directly at the 020 field,
e.g. record['020']['a']
View
@@ -120,6 +120,10 @@ def test_isbn(self):
record = Record()
record.add_field(Field('020', [' ', ' '], subfields=['a', '0456789012 (reel 1)']))
self.assertEquals(record.isbn(), '0456789012')
+
+ record = Record()
+ record.add_field(Field('020', [' ', ' '], subfields=['a', '006073132X']))
+ self.assertEquals(record.isbn(), '006073132X')
def test_multiple_isbn(self):
reader = MARCReader(file('test/multi_isbn.dat'))

0 comments on commit 5a4b77a

Please sign in to comment.