Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlueApplication.add_data and load_data now return the loaded data objects #1239

Merged
merged 1 commit into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Full changelog
v0.10.0 (unreleased)
--------------------

- The GlueApplication.add_data and load_data methods now return the
loaded data objects. [#1239]

- Change default name of subsets to include the word 'Subset'. [#1234]

- Removed ginga plugin from core package and moved it to a separate repository
Expand Down
11 changes: 11 additions & 0 deletions glue/core/application_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,15 @@ def settings(self):

@catch_error("Could not load data")
def load_data(self, path):
"""
Given a path to a file, load the file as a Data object and add it to
the current session.

This returns the added `Data` object.
"""
d = load_data(path)
self.add_datasets(self.data_collection, d)
return d

@catch_error("Could not add data")
def add_data(self, *args, **kwargs):
Expand All @@ -171,6 +178,8 @@ def add_data(self, *args, **kwargs):
Positional arguments are interpreted using the data factories, while
keyword arguments are interpreted using the same infrastructure as the
`qglue` command.

This returns a list of added `Data` objects.
"""

datasets = []
Expand All @@ -190,6 +199,8 @@ def add_data(self, *args, **kwargs):
if links is not None:
self.data_collection.add_link(parse_links(self.data_collection, links))

return datasets

def report_error(self, message, detail):
""" Report an error message to the user.
Must be implemented in a subclass
Expand Down