aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_export.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/fatcat_export.py')
-rwxr-xr-xpython/fatcat_export.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/python/fatcat_export.py b/python/fatcat_export.py
index 60c1caf1..6a5395de 100755
--- a/python/fatcat_export.py
+++ b/python/fatcat_export.py
@@ -12,7 +12,8 @@ import json
import argparse
import fatcat_client
from fatcat_client.rest import ApiException
-from fatcat_tools import uuid2fcid
+from fatcat_client import ReleaseEntity
+from fatcat_tools import uuid2fcid, entity_from_json, release_to_elasticsearch
def run_export_releases(args):
conf = fatcat_client.Configuration()
@@ -24,6 +25,15 @@ def run_export_releases(args):
release = api.get_release(id=ident, expand="all")
args.json_output.write(json.dumps(release.to_dict()) + "\n")
+def run_transform_releases(args):
+ for line in args.json_input:
+ line = line.strip()
+ if not line:
+ continue
+ release = entity_from_json(line, ReleaseEntity)
+ args.json_output.write(
+ json.dumps(release_to_elasticsearch(release)) + '\n')
+
def run_export_changelog(args):
conf = fatcat_client.Configuration()
conf.host = args.host_url
@@ -57,6 +67,15 @@ def main():
help="where to send output",
default=sys.stdout, type=argparse.FileType('w'))
+ sub_transform_releases = subparsers.add_parser('transform-releases')
+ sub_transform_releases.set_defaults(func=run_transform_releases)
+ sub_transform_releases.add_argument('json_input',
+ help="JSON-per-line of release entities",
+ default=sys.stdin, type=argparse.FileType('r'))
+ sub_transform_releases.add_argument('json_output',
+ help="where to send output",
+ default=sys.stdout, type=argparse.FileType('w'))
+
sub_changelog = subparsers.add_parser('changelog')
sub_changelog.set_defaults(func=run_export_changelog)
sub_changelog.add_argument('--start',