Scaffolding for "mooncrawl ethcrawler trending"

pull/92/head
Neeraj Kashyap 2021-08-09 04:58:47 -07:00
rodzic b0dc2c9e9c
commit ea1a714e9b
2 zmienionych plików z 49 dodań i 0 usunięć

Wyświetl plik

@ -8,6 +8,8 @@ import sys
import time
from typing import Iterator, List
import dateutil.parser
from .ethereum import (
crawl_blocks_executor,
crawl_blocks,
@ -164,6 +166,11 @@ def ethcrawler_contracts_update_handler(args: argparse.Namespace) -> None:
json.dump(results, args.outfile)
def ethcrawler_trending_handler(args: argparse.Namespace) -> None:
with args.outfile:
print(args)
def main() -> None:
parser = argparse.ArgumentParser(description="Moonstream crawlers CLI")
parser.set_defaults(func=lambda _: parser.print_help())
@ -314,6 +321,47 @@ def main() -> None:
func=ethcrawler_contracts_update_handler
)
parser_ethcrawler_trending = subcommands_ethcrawler.add_parser(
"trending", description="Trending addresses on the Ethereum blockchain"
)
parser_ethcrawler_trending.add_argument(
"-s",
"--start",
type=dateutil.parser.parse,
required=True,
help="Start time for window to calculate trending addresses in",
)
parser_ethcrawler_trending.add_argument(
"--include-start",
action="store_true",
help="Set this flag if range should include start time",
)
parser_ethcrawler_trending.add_argument(
"-e",
"--end",
type=dateutil.parser.parse,
required=True,
help="End time for window to calculate trending addresses in",
)
parser_ethcrawler_trending.add_argument(
"--include-end",
action="store_true",
help="Set this flag if range should include end time",
)
parser_ethcrawler_trending.add_argument(
"--humbug",
default=None,
help="If you would like to write this data to a Moonstream journal, please provide a Humbug token for that here.",
)
parser_ethcrawler_trending.add_argument(
"-o",
"--outfile",
type=argparse.FileType("w"),
default=sys.stdout,
help="Optional file to write output to. By default, prints to stdout.",
)
parser_ethcrawler_trending.set_defaults(func=ethcrawler_trending_handler)
args = parser.parse_args()
args.func(args)

Wyświetl plik

@ -34,6 +34,7 @@ setup(
zip_safe=False,
install_requires=[
"moonstreamdb @ git+https://git@github.com/bugout-dev/moonstream.git@ec3278e192119d1e8a273cfaab6cb53890d2e8e9#egg=moonstreamdb&subdirectory=db",
"python-dateutil",
"requests",
"tqdm",
"web3",