-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bulkk upload bugfixes and enhancements.
Add option to launch web browser when using `deriva-globus-auth-utils logout` to complete Globus logout flow at https://app.globus.org/logout.
- Loading branch information
Showing
4 changed files
with
74 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
deriva/transfer/upload/processors/metadata_update_processor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import json | ||
import logging | ||
from deriva.transfer.upload.processors import BaseProcessor | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class MetadataUpdateProcessor(BaseProcessor): | ||
""" | ||
Upload processor used to load external JSON into a dict for use as upload metadata. | ||
""" | ||
def __init__(self, **kwargs): | ||
super(MetadataUpdateProcessor, self).__init__(**kwargs) | ||
self.metadata = kwargs.get("metadata", dict()) or dict | ||
|
||
def process(self): | ||
input_file = self.parameters.get("input_file") | ||
if not input_file: | ||
return | ||
|
||
with open(input_file, "r") as input_data: | ||
data = json.load(input_data) | ||
if not isinstance(data, dict): | ||
logger.warning("Type mismatch: expected dict object from loaded JSON file: %s" % input_file) | ||
for key in data.keys(): | ||
if key in self.metadata: | ||
logger.warning( | ||
"Duplicate key '%s' encountered in metadata input file [%s] existing key will be " | ||
"overwritten." % (key, input_file)) | ||
self.metadata.update(data) |