Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
catalogue
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labs-team
catalogue
Commits
8d1e8019
Commit
8d1e8019
authored
6 years ago
by
gabriele-h
Browse files
Options
Downloads
Patches
Plain Diff
Rename single to unique for clarity
parent
aa7c5b4a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sru/almasru.py
+13
-6
13 additions, 6 deletions
sru/almasru.py
with
13 additions
and
6 deletions
sru/almasru.py
+
13
−
6
View file @
8d1e8019
...
...
@@ -71,7 +71,7 @@ class RecordRetriever:
'
marc
'
:
'
http://www.loc.gov/MARC21/slim
'
}
def
get_
singl
e
(
self
,
alma_query
:
str
)
->
Element
:
def
get_
uniqu
e
(
self
,
alma_query
:
str
)
->
Element
:
"""
Return one MARC XML record for a specific query.
:param alma_query: URI-parameter query for SRU request
...
...
@@ -87,7 +87,7 @@ class RecordRetriever:
sru_url
=
self
.
_create_url
(
alma_query
,
startrecord
)
sru_xml
=
self
.
_response_to_xml
(
sru_url
)
self
.
_raise_errors_
singl
e_record
s
(
sru_xml
)
self
.
_raise_errors_
uniqu
e_record
(
sru_xml
)
xml_list
=
self
.
_extract_marc_xml
(
sru_xml
)
return
xml_list
[
0
]
...
...
@@ -102,7 +102,14 @@ class RecordRetriever:
return
sru_url
def
_raise_errors_single_records
(
self
,
sru_xml
:
Element
):
def
_response_to_xml
(
self
,
sru_url
):
response
=
request
.
urlopen
(
sru_url
).
read
()
sru_xml
=
fromstring
(
response
)
return
sru_xml
def
_raise_errors_unique_record
(
self
,
sru_xml
:
Element
):
num_recs
=
sru_xml
.
find
(
"
srw:numberOfRecords
"
,
self
.
namespaces
)
...
...
@@ -138,7 +145,7 @@ class RecordRetriever:
"""
alma_query
=
f
'
alma.local_control_field_009=
{
marc_009
}
'
return
self
.
get_
singl
e
(
alma_query
)
return
self
.
get_
uniqu
e
(
alma_query
)
def
by_barcode
(
self
,
barcode
:
str
)
->
Element
:
"""
Return record by barcode.
...
...
@@ -146,7 +153,7 @@ class RecordRetriever:
param barcode: Barcode of a specific item.
"""
alma_query
=
f
'
alma.barcode=
{
barcode
}
'
return
self
.
get_
singl
e
(
alma_query
)
return
self
.
get_
uniqu
e
(
alma_query
)
def
by_mms_id
(
self
,
mms_id
:
str
)
->
Element
:
"""
Return record by MMS-ID.
...
...
@@ -154,4 +161,4 @@ class RecordRetriever:
param mmsid: MMS-ID of a specific item.
"""
alma_query
=
f
'
alma.mms_id=
{
mms_id
}
'
return
self
.
get_
singl
e
(
alma_query
)
return
self
.
get_
uniqu
e
(
alma_query
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment