From bec1a53202a8fd5cc5ea98f7565bb2a0bd93677e Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:38:25 +0200 Subject: [PATCH 1/2] Convert all return fields to snake_case --- .../openbb_core/app/static/package/crypto.py | 8 ++-- .../openbb_core/app/static/package/economy.py | 8 ++-- .../openbb_core/app/static/package/forex.py | 10 ++--- .../openbb_core/app/static/package/news.py | 12 ++--- .../openbb_core/app/static/package/stocks.py | 18 ++++---- .../app/static/package/stocks_fa.py | 44 +++++++++---------- .../openbb_core/app/static/package_builder.py | 7 ++- .../provider/openbb_provider/abstract/data.py | 11 +++++ 8 files changed, 67 insertions(+), 51 deletions(-) diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py index 78b79d715db..8a8f7206fec 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py @@ -118,17 +118,17 @@ class CLASS_crypto(Container): CryptoEOD --------- - adjClose : float + adj_close : float Adjusted Close Price of the symbol. - unadjustedVolume : float + unadjusted_volume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - changePercent : float + change_percent : float Change \% in the price of the symbol. label : str Human readable format of the date. - changeOverTime : float + change_over_time : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py index f948bd96570..5f9467a7dff 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py @@ -429,19 +429,19 @@ class CLASS_economy(Container): --------------- date : datetime The date of the data. - adjClose : float + adj_close : float Adjusted Close Price of the symbol. - unadjustedVolume : float + unadjusted_volume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - changePercent : float + change_percent : float Change \% in the price of the symbol. vwap : float Volume Weighted Average Price of the symbol. label : str Human readable format of the date. - changeOverTime : float + change_over_time : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py index 21d30707bfb..c41e1ecc261 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py @@ -107,7 +107,7 @@ class CLASS_forex(Container): The symbol of the currency pair. currency : str The base currency of the currency pair. - stockExchange : Optional[str] + stock_exchange : Optional[str] The stock exchange of the currency pair. exchange_short_name : Optional[str] The short name of the stock exchange of the currency pair.""" @@ -231,17 +231,17 @@ class CLASS_forex(Container): ForexEOD -------- - adjClose : float + adj_close : float Adjusted Close Price of the symbol. - unadjustedVolume : float + unadjusted_volume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - changePercent : float + change_percent : float Change \% in the price of the symbol. label : str Human readable format of the date. - changeOverTime : float + change_over_time : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py index 703fd2fd0ac..924ac8db425 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py @@ -73,19 +73,19 @@ class CLASS_news(Container): Parameters ---------- - pageSize : int + page_size : int The number of results to return per page. - displayOutput : Literal['headline', 'summary', 'full', 'all'] + display_output : Literal['headline', 'summary', 'full', 'all'] The type of data to return. date : Optional[datetime] The date of the news to retrieve. - dateFrom : Optional[datetime] + date_from : Optional[datetime] The start date of the news to retrieve. - dateTo : Optional[datetime] + date_to : Optional[datetime] The end date of the news to retrieve. - updatedSince : Optional[int] + updated_since : Optional[int] The number of seconds since the news was updated. - publishedSince : Optional[int] + published_since : Optional[int] The number of seconds since the news was published. sort : Optional[Literal['published_at', 'updated_at', 'title', 'author', 'channel', 'ticker', 'topic', 'content_type']] The order in which to sort the news. Options are: published_at, updated_at, title, author, channel, ticker, topic, content_type. diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py index 8fd80da14ba..3cb451a182b 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py @@ -185,17 +185,17 @@ class CLASS_stocks(Container): StockEOD -------- - adjClose : float + adj_close : float Adjusted Close Price of the symbol. - unadjustedVolume : float + unadjusted_volume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - changePercent : float + change_percent : float Change \% in the price of the symbol. label : str Human readable format of the date. - changeOverTime : float + change_over_time : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ @@ -288,17 +288,17 @@ class CLASS_stocks(Container): Parameters ---------- - displayOutput : Literal['headline', 'summary', 'full', 'all'] + display_output : Literal['headline', 'summary', 'full', 'all'] The type of data to return. date : Optional[datetime] The date of the news to retrieve. - dateFrom : Optional[datetime] + date_from : Optional[datetime] The start date of the news to retrieve. - dateTo : Optional[datetime] + date_to : Optional[datetime] The end date of the news to retrieve. - updatedSince : Optional[int] + updated_since : Optional[int] The number of seconds since the news was updated. - publishedSince : Optional[int] + published_since : Optional[int] The number of seconds since the news was published. sort : Optional[Literal['published_at', 'updated_at', 'title', 'author', 'channel', 'ticker', 'topic', 'content_type']] The order in which to sort the news. Options are: published_at, updated_at, title, author, channel, ticker, topic, content_type. diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py index aa9abebcde3..48b2e8d46d7 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py @@ -229,29 +229,29 @@ class CLASS_stocks_fa(Container): BalanceSheet ------------ - calendarYear : Optional[int] + calendar_year : Optional[int] None link : Optional[str] None - finalLink : Optional[str] + final_link : Optional[str] None - cashAndShortTermInvestments : Optional[int] + cash_and_short_term_investments : Optional[int] None - goodwillAndIntangibleAssets : Optional[int] + goodwill_and_intangible_assets : Optional[int] None - deferredRevenueNonCurrent : Optional[int] + deferred_revenue_non_current : Optional[int] None - totalInvestments : Optional[int] + total_investments : Optional[int] None - capitalLeaseObligations : Optional[int] + capital_lease_obligations : Optional[int] None - deferredTaxLiabilitiesNonCurrent : Optional[int] + deferred_tax_liabilities_non_current : Optional[int] None - totalNonCurrentLiabilities : Optional[int] + total_non_current_liabilities : Optional[int] None - totalDebt : Optional[int] + total_debt : Optional[int] None - netDebt : Optional[int] + net_debt : Optional[int] None""" inputs = filter_inputs( provider_choices={ @@ -710,11 +710,11 @@ class CLASS_stocks_fa(Container): CashFlowStatement ----------------- - calendarYear : Optional[int] + calendar_year : Optional[int] None link : Optional[str] None - finalLink : Optional[str] + final_link : Optional[str] None""" inputs = filter_inputs( provider_choices={ @@ -1821,21 +1821,21 @@ class CLASS_stocks_fa(Container): IncomeStatement --------------- - calendarYear : Optional[int] + calendar_year : Optional[int] None - grossProfitRatio : Optional[float] + gross_profit_ratio : Optional[float] None ebitdaratio : Optional[float] None - operatingIncomeRatio : Optional[float] + operating_income_ratio : Optional[float] None - incomeBeforeTaxRatio : Optional[float] + income_before_tax_ratio : Optional[float] None - netIncomeRatio : Optional[float] + net_income_ratio : Optional[float] None link : Optional[str] None - finalLink : Optional[str] + final_link : Optional[str] None""" inputs = filter_inputs( provider_choices={ @@ -2064,11 +2064,11 @@ class CLASS_stocks_fa(Container): The provider to use for the query. symbol : ConstrainedStrValue Symbol to get data for. - transactionType : Optional[List[Literal['A-Award', 'C-Conversion', 'D-Return', 'E-ExpireShort', 'F-InKind', 'G-Gift', 'H-ExpireLong', 'I-Discretionary', 'J-Other', 'L-Small', 'M-Exempt', 'O-OutOfTheMoney', 'P-Purchase', 'S-Sale', 'U-Tender', 'W-Will', 'X-InTheMoney', 'Z-Trust']]] + transaction_type : Optional[List[Literal['A-Award', 'C-Conversion', 'D-Return', 'E-ExpireShort', 'F-InKind', 'G-Gift', 'H-ExpireLong', 'I-Discretionary', 'J-Other', 'L-Small', 'M-Exempt', 'O-OutOfTheMoney', 'P-Purchase', 'S-Sale', 'U-Tender', 'W-Will', 'X-InTheMoney', 'Z-Trust']]] The type of the transaction. - reportingCik : Optional[int] + reporting_cik : Optional[int] The CIK of the reporting owner. - companyCik : Optional[int] + company_cik : Optional[int] The CIK of the company owner. page : Optional[int] The page number of the data to fetch. diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py index bd32af3258a..b5b31d4f376 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py @@ -1,4 +1,5 @@ import builtins +import re import shutil import subprocess from collections import OrderedDict @@ -308,6 +309,10 @@ class DocstringGenerator: field_mapping = mapping[model_name][provider.lower()][section_name]["fields"] fields = field_mapping.keys() + def _to_snake_case(string: str) -> str: + s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string) + return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() + if len(fields) == 0: section_docstring += "All fields are standardized.\n" else: @@ -322,7 +327,7 @@ class DocstringGenerator: field_description = field_mapping[field].field_info.description - section_docstring += f"{field} : {field_type}\n" + section_docstring += f"{_to_snake_case(field)} : {field_type}\n" section_docstring += f"{padding}{field_description}\n" if provider == "openbb" and section_name == "QueryParams": diff --git a/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py b/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py index 17f67b05c60..8e2f6601bac 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py +++ b/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py @@ -1,9 +1,20 @@ +import re + from pydantic import BaseModel, Extra +def to_snake_case(string: str) -> str: + s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string) + return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() + + class Data(BaseModel): """The OpenBB Standardized Data Model.""" + def dict(self, *args, **kwargs): + original_dict = super().dict(*args, **kwargs) + return {to_snake_case(k): v for k, v in original_dict.items()} + def __repr__(self): return f"{self.__class__.__name__}({', '.join([f'{k}={v}' for k, v in self.dict().items()])})" From bd1bca653e43a4627b8c6210a808609a06af96a7 Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Fri, 11 Aug 2023 16:59:07 +0200 Subject: [PATCH 2/2] Revert "Convert all return fields to snake_case" This reverts commit bec1a53202a8fd5cc5ea98f7565bb2a0bd93677e. --- .../openbb_core/app/static/package/crypto.py | 8 ++-- .../openbb_core/app/static/package/economy.py | 8 ++-- .../openbb_core/app/static/package/forex.py | 10 ++--- .../openbb_core/app/static/package/news.py | 12 ++--- .../openbb_core/app/static/package/stocks.py | 18 ++++---- .../app/static/package/stocks_fa.py | 44 +++++++++---------- .../openbb_core/app/static/package_builder.py | 7 +-- .../provider/openbb_provider/abstract/data.py | 11 ----- 8 files changed, 51 insertions(+), 67 deletions(-) diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py index 8a8f7206fec..78b79d715db 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py @@ -118,17 +118,17 @@ class CLASS_crypto(Container): CryptoEOD --------- - adj_close : float + adjClose : float Adjusted Close Price of the symbol. - unadjusted_volume : float + unadjustedVolume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - change_percent : float + changePercent : float Change \% in the price of the symbol. label : str Human readable format of the date. - change_over_time : float + changeOverTime : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py index 5f9467a7dff..f948bd96570 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/economy.py @@ -429,19 +429,19 @@ class CLASS_economy(Container): --------------- date : datetime The date of the data. - adj_close : float + adjClose : float Adjusted Close Price of the symbol. - unadjusted_volume : float + unadjustedVolume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - change_percent : float + changePercent : float Change \% in the price of the symbol. vwap : float Volume Weighted Average Price of the symbol. label : str Human readable format of the date. - change_over_time : float + changeOverTime : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py index c41e1ecc261..21d30707bfb 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/forex.py @@ -107,7 +107,7 @@ class CLASS_forex(Container): The symbol of the currency pair. currency : str The base currency of the currency pair. - stock_exchange : Optional[str] + stockExchange : Optional[str] The stock exchange of the currency pair. exchange_short_name : Optional[str] The short name of the stock exchange of the currency pair.""" @@ -231,17 +231,17 @@ class CLASS_forex(Container): ForexEOD -------- - adj_close : float + adjClose : float Adjusted Close Price of the symbol. - unadjusted_volume : float + unadjustedVolume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - change_percent : float + changePercent : float Change \% in the price of the symbol. label : str Human readable format of the date. - change_over_time : float + changeOverTime : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py index 924ac8db425..703fd2fd0ac 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/news.py @@ -73,19 +73,19 @@ class CLASS_news(Container): Parameters ---------- - page_size : int + pageSize : int The number of results to return per page. - display_output : Literal['headline', 'summary', 'full', 'all'] + displayOutput : Literal['headline', 'summary', 'full', 'all'] The type of data to return. date : Optional[datetime] The date of the news to retrieve. - date_from : Optional[datetime] + dateFrom : Optional[datetime] The start date of the news to retrieve. - date_to : Optional[datetime] + dateTo : Optional[datetime] The end date of the news to retrieve. - updated_since : Optional[int] + updatedSince : Optional[int] The number of seconds since the news was updated. - published_since : Optional[int] + publishedSince : Optional[int] The number of seconds since the news was published. sort : Optional[Literal['published_at', 'updated_at', 'title', 'author', 'channel', 'ticker', 'topic', 'content_type']] The order in which to sort the news. Options are: published_at, updated_at, title, author, channel, ticker, topic, content_type. diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py index 3cb451a182b..8fd80da14ba 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks.py @@ -185,17 +185,17 @@ class CLASS_stocks(Container): StockEOD -------- - adj_close : float + adjClose : float Adjusted Close Price of the symbol. - unadjusted_volume : float + unadjustedVolume : float Unadjusted volume of the symbol. change : float Change in the price of the symbol from the previous day. - change_percent : float + changePercent : float Change \% in the price of the symbol. label : str Human readable format of the date. - change_over_time : float + changeOverTime : float Change \% in the price of the symbol over a period of time.""" inputs = filter_inputs( provider_choices={ @@ -288,17 +288,17 @@ class CLASS_stocks(Container): Parameters ---------- - display_output : Literal['headline', 'summary', 'full', 'all'] + displayOutput : Literal['headline', 'summary', 'full', 'all'] The type of data to return. date : Optional[datetime] The date of the news to retrieve. - date_from : Optional[datetime] + dateFrom : Optional[datetime] The start date of the news to retrieve. - date_to : Optional[datetime] + dateTo : Optional[datetime] The end date of the news to retrieve. - updated_since : Optional[int] + updatedSince : Optional[int] The number of seconds since the news was updated. - published_since : Optional[int] + publishedSince : Optional[int] The number of seconds since the news was published. sort : Optional[Literal['published_at', 'updated_at', 'title', 'author', 'channel', 'ticker', 'topic', 'content_type']] The order in which to sort the news. Options are: published_at, updated_at, title, author, channel, ticker, topic, content_type. diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py index 48b2e8d46d7..aa9abebcde3 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/stocks_fa.py @@ -229,29 +229,29 @@ class CLASS_stocks_fa(Container): BalanceSheet ------------ - calendar_year : Optional[int] + calendarYear : Optional[int] None link : Optional[str] None - final_link : Optional[str] + finalLink : Optional[str] None - cash_and_short_term_investments : Optional[int] + cashAndShortTermInvestments : Optional[int] None - goodwill_and_intangible_assets : Optional[int] + goodwillAndIntangibleAssets : Optional[int] None - deferred_revenue_non_current : Optional[int] + deferredRevenueNonCurrent : Optional[int] None - total_investments : Optional[int] + totalInvestments : Optional[int] None - capital_lease_obligations : Optional[int] + capitalLeaseObligations : Optional[int] None - deferred_tax_liabilities_non_current : Optional[int] + deferredTaxLiabilitiesNonCurrent : Optional[int] None - total_non_current_liabilities : Optional[int] + totalNonCurrentLiabilities : Optional[int] None - total_debt : Optional[int] + totalDebt : Optional[int] None - net_debt : Optional[int] + netDebt : Optional[int] None""" inputs = filter_inputs( provider_choices={ @@ -710,11 +710,11 @@ class CLASS_stocks_fa(Container): CashFlowStatement ----------------- - calendar_year : Optional[int] + calendarYear : Optional[int] None link : Optional[str] None - final_link : Optional[str] + finalLink : Optional[str] None""" inputs = filter_inputs( provider_choices={ @@ -1821,21 +1821,21 @@ class CLASS_stocks_fa(Container): IncomeStatement --------------- - calendar_year : Optional[int] + calendarYear : Optional[int] None - gross_profit_ratio : Optional[float] + grossProfitRatio : Optional[float] None ebitdaratio : Optional[float] None - operating_income_ratio : Optional[float] + operatingIncomeRatio : Optional[float] None - income_before_tax_ratio : Optional[float] + incomeBeforeTaxRatio : Optional[float] None - net_income_ratio : Optional[float] + netIncomeRatio : Optional[float] None link : Optional[str] None - final_link : Optional[str] + finalLink : Optional[str] None""" inputs = filter_inputs( provider_choices={ @@ -2064,11 +2064,11 @@ class CLASS_stocks_fa(Container): The provider to use for the query. symbol : ConstrainedStrValue Symbol to get data for. - transaction_type : Optional[List[Literal['A-Award', 'C-Conversion', 'D-Return', 'E-ExpireShort', 'F-InKind', 'G-Gift', 'H-ExpireLong', 'I-Discretionary', 'J-Other', 'L-Small', 'M-Exempt', 'O-OutOfTheMoney', 'P-Purchase', 'S-Sale', 'U-Tender', 'W-Will', 'X-InTheMoney', 'Z-Trust']]] + transactionType : Optional[List[Literal['A-Award', 'C-Conversion', 'D-Return', 'E-ExpireShort', 'F-InKind', 'G-Gift', 'H-ExpireLong', 'I-Discretionary', 'J-Other', 'L-Small', 'M-Exempt', 'O-OutOfTheMoney', 'P-Purchase', 'S-Sale', 'U-Tender', 'W-Will', 'X-InTheMoney', 'Z-Trust']]] The type of the transaction. - reporting_cik : Optional[int] + reportingCik : Optional[int] The CIK of the reporting owner. - company_cik : Optional[int] + companyCik : Optional[int] The CIK of the company owner. page : Optional[int] The page number of the data to fetch. diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py index b5b31d4f376..bd32af3258a 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py @@ -1,5 +1,4 @@ import builtins -import re import shutil import subprocess from collections import OrderedDict @@ -309,10 +308,6 @@ class DocstringGenerator: field_mapping = mapping[model_name][provider.lower()][section_name]["fields"] fields = field_mapping.keys() - def _to_snake_case(string: str) -> str: - s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string) - return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() - if len(fields) == 0: section_docstring += "All fields are standardized.\n" else: @@ -327,7 +322,7 @@ class DocstringGenerator: field_description = field_mapping[field].field_info.description - section_docstring += f"{_to_snake_case(field)} : {field_type}\n" + section_docstring += f"{field} : {field_type}\n" section_docstring += f"{padding}{field_description}\n" if provider == "openbb" and section_name == "QueryParams": diff --git a/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py b/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py index 8e2f6601bac..17f67b05c60 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py +++ b/openbb_sdk/sdk/provider/openbb_provider/abstract/data.py @@ -1,20 +1,9 @@ -import re - from pydantic import BaseModel, Extra -def to_snake_case(string: str) -> str: - s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string) - return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() - - class Data(BaseModel): """The OpenBB Standardized Data Model.""" - def dict(self, *args, **kwargs): - original_dict = super().dict(*args, **kwargs) - return {to_snake_case(k): v for k, v in original_dict.items()} - def __repr__(self): return f"{self.__class__.__name__}({', '.join([f'{k}={v}' for k, v in self.dict().items()])})"