Skip to content
Snippets Groups Projects
Commit f66b8587 authored by Mike Lynch's avatar Mike Lynch
Browse files

Added a script to convert a datapub to a CATALOG.json

parent 8c0e16aa
Branches
Tags
No related merge requests found
// Quick tool for making a datacrate from a data pub
const datacrate = require('./lib/catalog.js');
const fs = require('fs-extra');
const path = require('path');
const ArgumentParser = require('argparse').ArgumentParser;
const ORGANISATION = {
'id': 'https://www.uts.edu.au/',
'name': 'University of Technology Sydney'
};
const OWNER = 'Kathryn.T.Braye@student.uts.edu.au';
const APPROVER = 'Sharyn.Wise@uts.edu.au';
async function makedatacrate(dest, datapub) {
await fs.ensureDir(dest);
const catalog = await datacrate.datapub2catalog({
id: id,
datapub: datapub,
organisation: ORGANISATION,
owner: OWNER,
approver: APPROVER
});
const catfile = path.join(dest, id, 'CATALOG.json');
await fs.writeFile(catfile, JSON.stringify(catalog, null, 2));
}
async function convertdatapub(jsonfile, dest) {
const datapub = await fs.readJSON(jsonfile);
await makedatacrate(dest, datapub);
}
var parser = new ArgumentParser({
version: '1.0.0',
addHelp: true,
description: 'Converts a ReDBox data publication to a CATALOG.json'
});
parser.addArgument(
['-i', '--input'],
{
help: "The input data publication"
});
parser.addArgument(
['-d', '--directory'],
{
help: "Directory in which to write the CATALOG.json. Will be created if it doesn't exist",
defaultValue: './datacrate/'
}
);
var args = parser.parseArgs();
convertdatapub(args['input'], args['directory']);
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment