Skip to content

Commit

Permalink
Update CLI parser to support updated logic for restructured asyncio c…
Browse files Browse the repository at this point in the history
…oroutines in parser
  • Loading branch information
dherincx92 committed Aug 22, 2024
1 parent e6e7c69 commit 99973a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ $ fpds parse "LAST_MOD_DATE=[2022/01/01, 2022/05/01]" "AGENCY_CODE=7504" -o my-
Same request via python interpreter:
```
import asyncio
from itertools import chain
from fpds import fpdsRequest
request = fpdsRequest(
LAST_MOD_DATE="[2022/01/01, 2022/05/01]",
AGENCY_CODE="7504"
)
data = list(asyncio.run(request.data()))
# results are nested lists so de-nest
data = asyncio.run(request.data())
records = list(chain.from_iterable(data))
```

For linting and formatting, we use `flake8` and `black`.
Expand Down
6 changes: 5 additions & 1 deletion src/fpds/cli/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
last_updated: 12/30/2022
"""

import asyncio
import json
from itertools import chain
from pathlib import Path
from uuid import uuid4

Expand Down Expand Up @@ -65,7 +67,9 @@ def parse(params, output):

request = fpdsRequest(**params_kwargs, cli_run=True)
click.echo("Retrieving FPDS records from ATOM feed...")
records = request()

data = asyncio.run(request.data())
records = list(chain.from_iterable(data))

DATA_DIR = OUTPUT_PATH if output else FPDS_DATA_DATE_DIR
DATA_FILE = DATA_DIR / f"{uuid4()}.json"
Expand Down

0 comments on commit 99973a8

Please sign in to comment.