Skip to content

Commit

Permalink
figshare_stem: Changes handling of empty string
Browse files Browse the repository at this point in the history
Update figshare_group()
  • Loading branch information
astrochun committed Aug 19, 2020
1 parent 03d1497 commit 92be48e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
15 changes: 11 additions & 4 deletions requiam/commons.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def figshare_stem(stem, production=True):
def figshare_stem(stem='', production=True):
"""
Purpose:
Construct Grouper figshare stems
:param stem: string corresponding to the sub-stem
Options are: 'quota', 'portal'
Some options are: 'quota', 'portal'. Default: root stem
:param production: Bool to use production stem. Otherwise a stage/test is used. Default: True
:return stem_query: str
Expand All @@ -14,11 +14,18 @@ def figshare_stem(stem, production=True):
For portal stem, call as: figshare_stem('portal')
> 'arizona.edu:dept:LBRY:figshare:portal'
For main stem, call as: figshare_stem()
> 'arizona.edu:dept:LBRY:figshare'
"""

if production:
stem_query = f'arizona.edu:dept:LBRY:figshare:{stem}'
stem_query = 'arizona.edu:dept:LBRY:figshare'
else:
stem_query = f'arizona.edu:dept:LBRY:devtest:chun{stem}'
stem_query = 'arizona.edu:dept:LBRY:figtest'

# If [stem] is not an empty string
if stem:
stem_query += f':{stem}'

return stem_query
12 changes: 6 additions & 6 deletions requiam/grouper_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def figshare_group(group, root_stem, production=True):
Purpose:
Construct Grouper figshare groups
:param group: str or int of group name
:param group: str or int of group name. Cannot be empty
:param root_stem: str of associated stem folder for [group]
:param production: Bool to use production stem. Otherwise a stage/test is used. Default: True
Expand All @@ -74,12 +74,12 @@ def figshare_group(group, root_stem, production=True):
> 'arizona.edu:dept:LBRY:figshare:portal:sci_math'
"""

stem_query = figshare_stem(root_stem, production=production)
if not group:
raise ValueError("WARNING: Empty [group]")

if root_stem == '':
grouper_group = stem_query + group
else:
grouper_group = '{}:{}'.format(stem_query, group)
stem_query = figshare_stem(stem=root_stem, production=production)

grouper_group = '{}:{}'.format(stem_query, group)

return grouper_group

Expand Down

0 comments on commit 92be48e

Please sign in to comment.