Skip to content

Commit 828b688

Browse files
committed
Changed from list to dict for adding subfields to a field at creation
1 parent 3039b8b commit 828b688

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

almamarc/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,18 @@ def add_field(self, tag, field_type='datafield', ind1='', ind2='', subfields=Non
6767
new_field = ElementTree.Element(field_type, tag=tag, ind1=ind1, ind2=ind2)
6868

6969
if subfields is None:
70-
subfields = []
71-
for subfield in subfields:
72-
new_subfield = ElementTree.Element('subfield', code=subfield['code'])
73-
new_subfield.text = subfield['value']
70+
subfields = {}
71+
for code, value in subfields.items():
72+
new_subfield = ElementTree.Element('subfield', code=code)
73+
new_subfield.text = value
7474
new_field.append(new_subfield)
7575

7676
record_root.append(new_field)
7777
fields = self.get_fields(tag=tag, field_type=field_type)
7878
return fields
7979

8080
def to_string(self):
81+
# Write to fake file so that we can write our own XML declaration string.
8182
fake_file = bytes()
8283
self.xml.write(fake_file, encoding='utf-8', xml_declaration=False)
8384
return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + fake_file.getvalue().decode('utf-8')

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22

33
setup(name='almaapi',
4-
version='0.1',
4+
version='1.0',
55
description='Python module for making requests to the Alma API',
66
url='https://github.com/JonkopingUniversityLibrary/almaapi',
77
author='Gustav Lindqvist',

0 commit comments

Comments
 (0)