Skip to content

Commit

Permalink
Merge pull request #287 from mugdhapolimera/publisheredit
Browse files Browse the repository at this point in the history
updated publisher field to ignore default value
  • Loading branch information
mugdhapolimera committed Feb 1, 2024
2 parents 702c8bd + c319f7a commit e13f0f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
8 changes: 6 additions & 2 deletions aip/classic/solr_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import traceback
import datetime


from adsputils import get_date, date2solrstamp
from aip.classic import enforce_schema

Expand Down Expand Up @@ -475,7 +474,12 @@ def _pubdate(ADS_record):

@staticmethod
def _publisher(ADS_record):
return {'publisher': ADS_record['metadata']['general'].get('publication', {}).get('publisher')}
result = ADS_record['metadata']['general'].get('publication', {}).get('publisher')

if result:
if result.lower() == 'publisher':
result = None
return {'publisher': result}

@staticmethod
def _pubnote(ADS_record):
Expand Down
36 changes: 18 additions & 18 deletions tests/classic/test_solr_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_SolrAdapter(self):
'page': [u'2056-2078'],
'page_count': 0,
'pubdate': u'2013-08-05',
'publisher': u'Publisher',
'publisher': u'test-Publisher',
'title': [u'This is of the title', u'This is of the alternate'],
'volume': u'l24'})

Expand Down Expand Up @@ -110,7 +110,7 @@ def test_SolrAdapter(self):
"bibstem_facet": u"A&AS",
"pub": u"Astronomy and Astrophysics Supplement Series",
"volume": u"143",
"publisher": u"Publisher",

"doi": [u"10.1051/aas:2000170"],
"eid": u"here is the eid",
"author_norm": [u"Kurtz, M", u"Eichhorn, G", u"Accomazzi, A", u"Grant, C",
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_SolrAdapter(self):
"general" : {
"publication" : {
"origin" : u"ARXIV",
"publisher": u"Publisher",

'dates' : [
{
'type' : u'date-preprint',
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_SolrAdapter(self):
'author_count': 2,
'doctype_facet_hier': [u'0/Article', u'1/Article/Journal Article'],
'identifier': [u'2014arXiv1406.4542H'],
"publisher": u"Publisher",

})

# test addition of type = collaboration, which should act similar to type = regular
Expand All @@ -228,7 +228,7 @@ def test_SolrAdapter(self):
"general": {
"publication": {
"origin": u"ARXIV",
"publisher": u"Publisher",

'dates': [
{
'type': u'date-preprint',
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_SolrAdapter(self):
'author_count': 2,
'doctype_facet_hier': [u'0/Article', u'1/Article/Journal Article'],
'identifier': [u'2014arXiv1406.4542H'],
"publisher": u"Publisher",

})

# test identifer arXiv with bibcode
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_SolrAdapter(self):
"general": {
"publication": {
"origin": u"ARXIV",
"publisher": u"Publisher",

'dates': [
{
'type': u'date-preprint',
Expand Down Expand Up @@ -349,7 +349,7 @@ def test_SolrAdapter(self):
'doctype_facet_hier': [u'0/Article', u'1/Article/Journal Article'],

'identifier': [u'2018arXiv180710779B', u'arXiv:1807.10779'],
"publisher": u"Publisher",

})

# test identifer arXiv with bibcode, different kind of arXiv id, plus made sure links are captured properly
Expand Down Expand Up @@ -393,7 +393,7 @@ def test_SolrAdapter(self):
"general": {
"publication": {
"origin": u"ARXIV",
"publisher": u"Publisher",

'dates': [
{
'type': u'date-preprint',
Expand Down Expand Up @@ -432,7 +432,7 @@ def test_SolrAdapter(self):
'page_count': 0,
'author_count': 1,
'doctype_facet_hier': [u'0/Article', u'1/Article/Journal Article'],
"publisher": u"Publisher",

'identifier': [u'1968NuPhB...7...79F', u'arXiv:quant-ph/0206057'],
'links_data': [
u'{"access": "open", "instances": "", "title": "", "type": "preprint", "url": "http://arxiv.org/abs/quant-ph/0206057"}',
Expand Down Expand Up @@ -466,7 +466,7 @@ def test_SolrAdapter(self):
"general": {
"publication": {
"origin": u"ASCL",
"publisher": u"Publisher",

'dates': [
{
'type': u'date-published',
Expand Down Expand Up @@ -505,7 +505,7 @@ def test_SolrAdapter(self):
'page_count': 0,
'author_count': 1,
'doctype_facet_hier': ["0/Non-Article", "1/Non-Article/Software"],
"publisher": u"Publisher",

'identifier': [u'ascl:1802.007', u'2018ascl.soft02007G'],
})

Expand All @@ -527,7 +527,7 @@ def test_SolrAdapter(self):
"general": {
"publication": {
"origin": u"JSTOR",
"publisher": u"Publisher",

'dates': [
{
'type': u'date-published',
Expand Down Expand Up @@ -572,7 +572,7 @@ def test_SolrAdapter(self):
'author_count': 1,
'doctype_facet_hier': [u'0/Article', u'1/Article/Journal Article'],
'identifier': [u'1988Sci...240..668D'],
"publisher": u"Publisher",

})

# check the entry_date updates - don't update if the timestamp is setup
Expand All @@ -593,7 +593,7 @@ def test_SolrAdapter(self):
"general": {
"publication": {
"origin": u"ARXIV",
"publisher": u"Publisher",

'dates': [
{
'type': u'date-preprint',
Expand Down Expand Up @@ -645,7 +645,7 @@ def test_SolrAdapter(self):
'author_count': 2,
'doctype_facet_hier': [u'0/Article', u'1/Article/Journal Article'],
'identifier': [u'2014arXiv1406.4542H'],
"publisher": u"Publisher",

})

# check the entry_date updates - don't update if the date is today
Expand All @@ -668,7 +668,7 @@ def test_SolrAdapter(self):
"general": {
"publication": {
"origin": u"ARXIV",
"publisher": u"Publisher",

'dates': [
{
'type': u'date-preprint',
Expand Down Expand Up @@ -720,7 +720,7 @@ def test_SolrAdapter(self):
'author_count': 2,
'doctype_facet_hier': [u'0/Article', u'1/Article/Journal Article'],
'identifier': [u'2014arXiv1406.4542H'],
"publisher": u"Publisher",

})

class TestBibstemMapper(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/stubdata/ADSRecords/testbibcode
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'origin': '',
'page': u'2056-2078',
'page_count': 0,
'publisher': u'Publisher',
'publisher': u'test-Publisher',
'volume': u'l24'},
'titles': [{'lang': u'en', 'text': u'This is of the title'},
{'lang': '', 'text': u'This is of the alternate'}]},
Expand Down

0 comments on commit e13f0f5

Please sign in to comment.