From 1756a09a3b5ed99d7fda27ce32632a0feb7fdc85 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Tue, 27 Jul 2021 13:19:07 +0200 Subject: remove unused/partially implemented skate-dot for now --- skate/Makefile | 2 +- skate/cmd/skate-dot/main.go | 74 --------------------------------------------- 2 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 skate/cmd/skate-dot/main.go (limited to 'skate') diff --git a/skate/Makefile b/skate/Makefile index 8092cbe..4df05f8 100644 --- a/skate/Makefile +++ b/skate/Makefile @@ -1,5 +1,5 @@ SHELL := /bin/bash -TARGETS := skate-conv skate-cleanup skate-from-unstructured skate-wikipedia-doi skate-dot skate-map skate-reduce skate-cdx-lookup skate-resolve-journal-name +TARGETS := skate-conv skate-cleanup skate-from-unstructured skate-wikipedia-doi skate-map skate-reduce skate-cdx-lookup skate-resolve-journal-name PKGNAME := skate .PHONY: test diff --git a/skate/cmd/skate-dot/main.go b/skate/cmd/skate-dot/main.go deleted file mode 100644 index 573209e..0000000 --- a/skate/cmd/skate-dot/main.go +++ /dev/null @@ -1,74 +0,0 @@ -// [wip] skate-dot generates dot files from inbound and outbound citation -// links. Just a demo, replacement for a couple python scripts. We want things -// like: https://git.io/JObzq. -package main - -import ( - "context" - "flag" - "fmt" - "io" - "log" - "os" - - "github.com/elastic/go-elasticsearch/esapi" - elasticsearch "github.com/elastic/go-elasticsearch/v7" -) - -var ( - es = flag.String("es", "http://localhost:9200", "elasticsearch holding fatcat_ref index") - index = flag.String("x", "fatcat_ref_v01", "index name") - fatcat = flag.String("f", "https://api.fatcat.wiki/v0", "fatcat api") - ident = flag.String("i", "2kw3xjf2cbcmdlm3ihkoz2t4lu", "release ident") -) - -func main() { - flag.Parse() - cfg := elasticsearch.Config{Addresses: []string{*es}} - es, err := elasticsearch.NewClient(cfg) - if err != nil { - log.Fatal(err) - } - client := &Client{ - Api: *fatcat, - Es: es, - Index: *index, - } - client.Outbound(*ident) -} - -// A client for fatcat and elasticsearch. -type Client struct { - Api string - Es *elasticsearch.Client - Index string -} - -func (c *Client) String() string { - info, _ := c.Es.Info() - return fmt.Sprintf("%s %s (%s) %s", c.Api, info, elasticsearch.Version, c.Index) -} - -func (c *Client) Inbound(ident string) []string { - resp, err := c.Es.Search( - c.Es.Search.WithContext(context.Background()), - c.Es.Search.WithIndex(c.Index), - ) - if err != nil { - log.Fatal(err) - } - io.Copy(os.Stdout, resp.Body) - return nil -} - -func (c *Client) Outbound(ident string) []string { - req := &esapi.SearchRequest{ - Query: fmt.Sprintf("source_release_ident:%s", ident), - } - resp, err := req.Do(context.Background(), c.Es) - if err != nil { - log.Fatal(err) - } - io.Copy(os.Stdout, resp.Body) - return nil -} -- cgit v1.2.3