From 559137b99cd5c4e4880402393120543d6448825e Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 10 Feb 2017 18:03:54 +0000 Subject: [PATCH] The GlueApplication.add_data and load_data methods now return the loaded data objects. --- CHANGES.md | 3 +++ glue/core/application_base.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5829658df..1c50d4da5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/glue/core/application_base.py b/glue/core/application_base.py index fccbe9ee6..05394cbb3 100644 --- a/glue/core/application_base.py +++ b/glue/core/application_base.py @@ -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): @@ -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 = [] @@ -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