Skip to content

Commit

Permalink
Implement a simple version of listify
Browse files Browse the repository at this point in the history
  • Loading branch information
dgunning committed Aug 27, 2024
1 parent 4d7aad5 commit 3c98705
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions edgar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
get_identity,
set_identity,
use_local_storage,
download_edgar_data)
download_edgar_data,
listify)
from edgar.fundreports import FundReport, NPORT_FORMS
from edgar.funds import Fund, FundSeries, get_fund, FundClass
from edgar.thirteenf import ThirteenF, THIRTEENF_FORMS
Expand Down Expand Up @@ -94,7 +95,6 @@ def find(search_id: Union[str, int]) -> (
def matches_form(sec_filing: Filing,
form: Union[str, List[str]]) -> bool:
"""Check if the filing matches the forms"""
from fastcore.basics import listify
form_list = listify(form)
if sec_filing.form in form_list + [f"{f}/A" for f in form_list]:
return True
Expand Down
2 changes: 1 addition & 1 deletion edgar/_filings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import pyarrow.parquet as pq
import pytz
from bs4 import BeautifulSoup
from fastcore.basics import listify
from fastcore.parallel import parallel
from rich import box
from rich.columns import Columns
Expand All @@ -41,6 +40,7 @@
filter_by_form,
filter_by_cik,
filter_by_ticker,
listify,
InvalidDateException, IntString, DataPager)
from edgar.documents import HtmlDocument, get_clean_html
from edgar.filingheader import FilingHeader
Expand Down
18 changes: 17 additions & 1 deletion edgar/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import pandas as pd
import pyarrow as pa
import pyarrow.compute as pc
from fastcore.basics import listify
from rich.logging import RichHandler
from rich.prompt import Prompt

Expand Down Expand Up @@ -67,6 +66,7 @@
'pandas_version',
'python_version',
'set_identity',
'listify',
'decode_content',
'filter_by_date',
'filter_by_form',
Expand Down Expand Up @@ -707,3 +707,19 @@ def run_async_or_sync(coroutine):
except (KeyError, AttributeError):
# We're not in an IPython environment, use asyncio.run()
return asyncio.run(coroutine)


def listify(value):
"""
Convert the input to a list if it's not already a list.
Args:
value: Any type of input
Returns:
list: The input as a list
"""
if isinstance(value, list):
return value
else:
return [value]
3 changes: 1 addition & 2 deletions edgar/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import pandas as pd
import pyarrow as pa
import pyarrow.compute as pc
from fastcore.basics import listify
from rich import box
from rich.columns import Columns
from rich.console import Group
Expand All @@ -23,7 +22,7 @@

from edgar._filings import Filing, Filings, FilingsState
from edgar.richtools import df_to_rich_table, repr_rich
from edgar.core import (log, Result, display_size,
from edgar.core import (log, Result, display_size, listify,
filter_by_date, IntString, InvalidDateException, reverse_name, get_edgar_data_directory)
from edgar.httprequests import download_json, download_text, download_bulk_data
from edgar.reference import states
Expand Down

0 comments on commit 3c98705

Please sign in to comment.