Skip to content

Commit

Permalink
Fix diffing on Py3 by comparing unicode strings
Browse files Browse the repository at this point in the history
  • Loading branch information
danmichaelo committed Mar 31, 2017
1 parent 76fb802 commit 4a38d0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lokar/bib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Bib(object):

def __init__(self, alma, xml):
self.alma = alma
self.orig_xml = xml.encode('utf-8')
self.orig_xml = xml
self.init(xml)

def init(self, xml):
Expand All @@ -25,15 +25,15 @@ def init(self, xml):
def save(self, diff=False, dry_run=False):
# Save record back to Alma

post_data = ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.encode('utf-8') +
etree.tostring(self.doc, encoding='UTF-8'))
post_data = ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
etree.tounicode(self.doc))

if diff:
show_diff(self.orig_xml, post_data)

if not dry_run:
response = self.alma.put('/bibs/{}'.format(self.mms_id),
data=BytesIO(post_data),
data=BytesIO(post_data.encode('utf-8')),
headers={'Content-Type': 'application/xml'})
self.init(response)

Expand Down

0 comments on commit 4a38d0d

Please sign in to comment.