-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.py
61 lines (42 loc) · 1.24 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# !/usr/bin/env python
# -*- coding: utf-8 -*-
""""""
import typer
from pathlib import Path
from app.database import init_db, drop_db, import_basedata_states
from app.models import Base
app = typer.Typer()
@app.command("initdb")
def initdb_command():
init_db()
typer.echo("Initialized the database")
@app.command("dropdb")
def dropdb_command():
drop_db()
typer.echo("Dropped the database")
@app.command("deploy")
def deploy_command():
typer.echo("Deployed")
@app.command("resetdb")
def resetdb_command():
drop_db()
init_db()
typer.echo("Dataset dropped and initialized (reset)")
@app.command("import-basedata")
def import_basedata_command():
import_basedata_states()
# import_basedata_parties()
# import_basedata_nonparties()
# import_basedata_reds()
# import_basedata_districts()
# import_basedata_municipalities()
typer.echo("Basedata imported")
@app.command("import-results")
def import_results_command(csv_filename: Path, json_filename: Path):
import_result()
typer.echo("Election results data imported")
@app.command("create-json")
def create_json_command(election: str):
typer.echo("JSON of election {0} created".format(election))
if __name__ == "__main__":
app()