Skip to content

Commit

Permalink
Merge branch 'master' of github.com:scieloorg/delorean
Browse files Browse the repository at this point in the history
  • Loading branch information
jamilatta committed Apr 20, 2016
2 parents 9210071 + 4c5b973 commit 3d6fe22
Show file tree
Hide file tree
Showing 17 changed files with 881 additions and 43 deletions.
82 changes: 70 additions & 12 deletions delorean/domain.py
Expand Up @@ -273,6 +273,7 @@ def get_data(self, obj):
journalid = obj['journal'].strip('/').split('/')[-1]
obj['journal'] = self._lookup_fields('journals', journalid, ['title',
'short_title',
'medline_title',
'publisher_name',
'publication_city',
'sponsors',
Expand All @@ -286,9 +287,12 @@ def get_data(self, obj):
])

# Formating publication date, must have 00 for the days digits.
pub_month = "%02d" % obj['publication_end_month']
pub_month = "%02d" % obj['publication_end_month'] if obj['publication_end_month'] else u'00'
obj['publication_date'] = unicode(obj['publication_year']) + pub_month + u'00'

if not obj.get('use_license', None) and obj['journal'].get('use_license', None):
obj['use_license'] = obj['journal']['use_license']

sections = {}
# lookup sections
for section in obj['sections']:
Expand All @@ -309,6 +313,10 @@ def get_data(self, obj):

obj['sections'] = sections


if obj['type'] == 'special':
obj['number'] = 'spe.%s' % obj.get('spe_text', '')

# Issue Label ShortTitle

obj['display'] = {}
Expand All @@ -323,7 +331,7 @@ def get_data(self, obj):
obj['display']['es'] += u'^t' + unicode(obj['journal']['short_title'])

# Volume
if 'volume' in obj and obj['volume']:
if 'volume' in obj and obj['volume']:
obj['display']['pt'] += u'^vvol.' + unicode(obj['volume'])
obj['display']['en'] += u'^vvol.' + unicode(obj['volume'])
obj['display']['es'] += u'^vvol.' + unicode(obj['volume'])
Expand All @@ -336,9 +344,14 @@ def get_data(self, obj):

# Number
if 'number' in obj and obj['number']:
obj['display']['pt'] += u'^nno.' + unicode(obj['number'])
obj['display']['en'] += u'^nn.' + unicode(obj['number'])
obj['display']['es'] += u'^nno.' + unicode(obj['number'])
if obj['type'] == 'special':
obj['display']['pt'] += u'^n' + unicode(obj['number'])
obj['display']['en'] += u'^n' + unicode(obj['number'])
obj['display']['es'] += u'^n' + unicode(obj['number'])
else:
obj['display']['pt'] += u'^nno.' + unicode(obj['number'])
obj['display']['en'] += u'^nn.' + unicode(obj['number'])
obj['display']['es'] += u'^nno.' + unicode(obj['number'])

# Number Supplement
if 'suppl_number' in obj and obj['suppl_number']:
Expand All @@ -353,8 +366,8 @@ def get_data(self, obj):
obj['display']['es'] += u'^c' + unicode(obj['journal']['publication_city'])

for lang in ['pt_BR', 'en_US', 'es_ES']:
numeric_start_month = obj['publication_start_month']
numeric_end_month = obj['publication_end_month']
numeric_start_month = obj['publication_start_month'] or 0
numeric_end_month = obj['publication_end_month'] or 0

if numeric_start_month in range(1, 13):
start_month = MONTH_ABBREVS[lang][numeric_start_month]
Expand All @@ -366,14 +379,22 @@ def get_data(self, obj):
else:
end_month = ''

sub_m = './'.join([month for month in [start_month, end_month] if month])
#Verify if the start_month is equal to end_month
if start_month == end_month:
sub_m = start_month
else:
sub_m = './'.join([month for month in [start_month, end_month] if month])

if sub_m:
obj['display'][lang[:2]] += u'^m' + sub_m + u'.'
else:
obj['display'][lang[:2]] += u'^m'

obj['display'][lang[:2]] += u'^m' + sub_m + u'.'

# Year
obj['display']['pt'] += u'^y' + unicode(obj['publication_year'])
obj['display']['en'] += u'^y' + unicode(obj['publication_year'])
obj['display']['es'] += u'^y' + unicode(obj['publication_year'])
obj['display']['pt'] += u'^a' + unicode(obj['publication_year'])
obj['display']['en'] += u'^a' + unicode(obj['publication_year'])
obj['display']['es'] += u'^a' + unicode(obj['publication_year'])

obj['order'] = str(obj['publication_year']) + str(obj['order'])

Expand All @@ -388,6 +409,42 @@ def get_data(self, obj):
del(obj['issues'])
del(obj['resource_uri'])

# lookup previous journal
if obj['previous_title']:
journalid = obj['previous_title'].strip('/').split('/')[-1]
obj['previous_title'] = self._lookup_fields('journals', journalid, ['title'])

if 'title' in obj['previous_title']:
obj['previous_title'] = obj['previous_title']['title']


joined_editor_address = []

if 'editor_address' in obj and obj['editor_address']:
joined_editor_address.append(obj['editor_address'])

if 'editor_address_city' in obj and obj['editor_address_city']:
joined_editor_address.append(obj['editor_address_city'])

if 'editor_address_state' in obj and obj['editor_address_state']:
joined_editor_address.append(obj['editor_address_state'])

if 'editor_address_country' in obj and obj['editor_address_country']:
joined_editor_address.append(obj['editor_address_country'])

if 'editor_address_zip' in obj and obj['editor_address_zip']:
joined_editor_address.append(obj['editor_address_zip'])

if 'editor_phone1' in obj and obj['editor_phone1']:
joined_editor_address.append(obj['editor_phone1'])

if 'editor_phone2' in obj and obj['editor_phone2']:
joined_editor_address.append(obj['editor_phone2'])


# Editor Address joined
obj['editor_address_joined'] = ', '.join(joined_editor_address)

# dateiso format
obj['created'] = obj['created'][:10].replace('-', '')
obj['updated'] = obj['updated'][:10].replace('-', '')
Expand Down Expand Up @@ -416,6 +473,7 @@ def get_data(self, obj):
elif event['status'] == 'suspended':
status = 'S'
else:
continue
status = '?'

if len(pub_status_history[-1]) < 2:
Expand Down
44 changes: 39 additions & 5 deletions delorean/templates/issue_db_entry.txt
Expand Up @@ -13,6 +13,12 @@
!v032!${number}
% endif
##
% if thematic_titles is not UNDEFINED:
% for value in thematic_titles:
!v033!${thematic_titles[value]}^l${value}
% endfor
% endif
##
% if journal['scielo_issn'] is not UNDEFINED and journal['scielo_issn']:
% if journal['scielo_issn'] == 'print':
!v035!${journal['print_issn']}
Expand Down Expand Up @@ -66,13 +72,19 @@
!v130!${journal['title']}
% endif
##
% if number is UNDEFINED or (number is not UNDEFINED and not number):
% if volume is not UNDEFINED and volume:
% if suppl_volume is not UNDEFINED and suppl_volume:
!v131!${suppl_volume}
% endif
% endif
% endif
##
% if number is not UNDEFINED and number:
% if suppl_number is not UNDEFINED and suppl_number:
!v132!${suppl_number}
% endif
% endif
##
% if journal['title_iso'] is not UNDEFINED and journal['title_iso']:
!v151!${journal['title_iso']}
Expand All @@ -90,14 +102,36 @@
% endfor
% endif
##
% if journal['medline_title'] is not UNDEFINED and journal['medline_title']:
!v421!${journal['medline_title']}
% endif
##
% if journal['eletronic_issn'] is not UNDEFINED and journal['eletronic_issn']:
!v435!${journal['eletronic_issn']}^tONLIN
% endif
##
% if journal['print_issn'] is not UNDEFINED and journal['print_issn']:
!v435!${journal['print_issn']}^tPRINT
% endif
##
% if journal['publisher_name'] is not UNDEFINED and journal['publisher_name']:
!v480!${journal['publisher_name']}
% endif
!v540!^t${journal['use_license']['disclaimer']}^les
!v540!^t${journal['use_license']['disclaimer']}^lpt
!v540!^t${journal['use_license']['disclaimer']}^len
% if journal['use_license']['license_code'] is not UNDEFINED and journal['use_license']['license_code']:
!v541!${journal['use_license']['license_code']}
##
% if use_license['disclaimer'] is not UNDEFINED and use_license['disclaimer']:
!v540!^t${use_license['disclaimer']}^les
% endif
##
% if use_license['disclaimer'] is not UNDEFINED and use_license['disclaimer']:
!v540!^t${use_license['disclaimer']}^lpt
% endif
##
% if use_license['disclaimer'] is not UNDEFINED and use_license['disclaimer']:
!v540!^t${use_license['disclaimer']}^len
% endif
##
% if use_license['license_code'] is not UNDEFINED and use_license['license_code']:
!v541!${use_license['license_code']}
% endif
!v706!i
##
Expand Down
46 changes: 33 additions & 13 deletions delorean/templates/title_db_entry.txt
Expand Up @@ -8,27 +8,21 @@
!v020!${national_code}
% endif
##
% if scielo_issn is not UNDEFINED and scielo_issn:
% if scielo_issn == 'print':
!v035!PRINT
% else:
% if eletronic_issn is not UNDEFINED and eletronic_issn:
!v035!ONLIN
% else:
!v035!PRINT
% endif
%endif
##
% if secs_code is not UNDEFINED and secs_code:
!v037!${secs_code}
% endif
##
% if pub_status is not UNDEFINED and pub_status:
% if pub_status == 'current':
!v050!C
% elif pub_status == 'deceased':
!v050!D
% elif pub_status == 'suspended':
!v050!S
% else:
% if pub_status == 'inprogress':
!v050!?
% else:
!v050!C
% endif
% endif
##
Expand All @@ -47,7 +41,7 @@
% endif
##
% if editor_address is not UNDEFINED and editor_address:
!v063!${editor_address}
!v063!${editor_address_joined}
% endif
##
% if editor_email is not UNDEFINED and editor_email:
Expand Down Expand Up @@ -162,6 +156,18 @@
% endif
% endif
##
% if medline_title is not UNDEFINED and medline_title:
!v421!${medline_title}
% endif
##
% if eletronic_issn is not UNDEFINED and eletronic_issn:
!v435!${eletronic_issn}^tONLIN
% endif
##
% if print_issn is not UNDEFINED and print_issn:
!v435!${print_issn}^tPRINT
% endif
##
% if subject_descriptors is not UNDEFINED and subject_descriptors:
% for value in subject_descriptors.split('\n'):
!v440!${value.upper()}
Expand Down Expand Up @@ -205,6 +211,20 @@
!v692!${url_online_submission}
% endif
##
% if is_indexed_scie is not UNDEFINED and is_indexed_scie:
!v851!SCIE
% endif %
% if is_indexed_ssci is not UNDEFINED and is_indexed_ssci:
!v852!SSCI
% endif %
% if is_indexed_aehci is not UNDEFINED and is_indexed_aehci:
!v853!A&HCI
% endif %
% if subject_categories is not UNDEFINED and subject_categories:
% for value in subject_categories:
!v854!${value}
% endfor
% endif
% if notes is not UNDEFINED and notes:
!v900!${notes}
% endif
Expand Down

0 comments on commit 3d6fe22

Please sign in to comment.