forked from OpenBB-finance/OpenBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] - Create repo assets directory (OpenBB-finance#6384)
* feat: create scripts to generate repo assets * move script * publish.md * deletes unmaintained .md files * ruff * pylint * fix: website urls * fix: website urls * rename script * renames * create folder * mypy * PyDocstyle * fix: descriptions & websites * camelCase * change json structure * logo url * reprName * finra * logos * logo * logo * logo * logo * pylint --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
- Loading branch information
1 parent
c29200a
commit 5b74280
Showing
37 changed files
with
646 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Assets | ||
|
||
This folder should hold assets read by OpenBB applications, such as OpenBB Hub or marketing website. | ||
|
||
The goal is to be more explicit about which assets are being used externally and cannot be deleted before checking where they are used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"packageName": "openbb-charting", | ||
"description": "Create custom charts from OBBject data." | ||
} | ||
] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[ | ||
{ | ||
"packageName": "openbb-commodity", | ||
"description": "Commodity market data." | ||
}, | ||
{ | ||
"packageName": "openbb-crypto", | ||
"description": "Cryptocurrency market data." | ||
}, | ||
{ | ||
"packageName": "openbb-currency", | ||
"description": "Foreign exchange (FX) market data." | ||
}, | ||
{ | ||
"packageName": "openbb-derivatives", | ||
"description": "Derivatives market data." | ||
}, | ||
{ | ||
"packageName": "openbb-econometrics", | ||
"description": "Econometrics analysis tools." | ||
}, | ||
{ | ||
"packageName": "openbb-economy", | ||
"description": "Economic data." | ||
}, | ||
{ | ||
"packageName": "openbb-equity", | ||
"description": "Equity market data." | ||
}, | ||
{ | ||
"packageName": "openbb-etf", | ||
"description": "Exchange Traded Funds market data." | ||
}, | ||
{ | ||
"packageName": "openbb-fixedincome", | ||
"description": "Fixed Income market data." | ||
}, | ||
{ | ||
"packageName": "openbb-index", | ||
"description": "Indices data." | ||
}, | ||
{ | ||
"packageName": "openbb-news", | ||
"description": "Financial market news data." | ||
}, | ||
{ | ||
"packageName": "openbb-quantitative", | ||
"description": "Quantitative analysis tools." | ||
}, | ||
{ | ||
"packageName": "openbb-regulators", | ||
"description": "Financial market regulators data." | ||
}, | ||
{ | ||
"packageName": "openbb-technical", | ||
"description": "Technical Analysis tools." | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
"""Generate assets from modules.""" | ||
|
||
from importlib import import_module | ||
from json import dump | ||
from pathlib import Path | ||
from typing import Any, Dict, List | ||
|
||
from poetry.core.pyproject.toml import PyProjectTOML | ||
|
||
THIS_DIR = Path(__file__).parent | ||
PROVIDERS_PATH = Path(THIS_DIR, "..", "..", "openbb_platform/providers") | ||
EXTENSIONS_PATH = Path(THIS_DIR, "..", "..", "openbb_platform/extensions") | ||
OBBJECT_EXTENSIONS_PATH = Path( | ||
THIS_DIR, "..", "..", "openbb_platform/obbject_extensions" | ||
) | ||
|
||
|
||
def to_title(string: str) -> str: | ||
"""Format string to title.""" | ||
return " ".join(string.split("_")).title() | ||
|
||
|
||
def get_packages(path: Path, plugin_key: str) -> Dict[str, Any]: | ||
"""Get packages.""" | ||
SKIP = ["tests", "__pycache__"] | ||
folders = [f for f in path.glob("*") if f.is_dir() and f.stem not in SKIP] | ||
packages: Dict[str, Any] = {} | ||
for f in folders: | ||
pyproject = PyProjectTOML(Path(f, "pyproject.toml")) | ||
poetry = pyproject.data["tool"]["poetry"] | ||
name = poetry["name"] | ||
plugin = poetry.get("plugins", {}).get(plugin_key) | ||
packages[name] = list(plugin.values())[0] if plugin else "" | ||
return packages | ||
|
||
|
||
def write(filename: str, data: Any): | ||
"""Write to json.""" | ||
with open(Path(THIS_DIR, "..", "extensions", f"{filename}.json"), "w") as json_file: | ||
dump(data, json_file, indent=4) | ||
|
||
|
||
def to_camel(string: str): | ||
"""Convert string to camel case.""" | ||
components = string.split("_") | ||
return components[0] + "".join(x.title() for x in components[1:]) | ||
|
||
|
||
def createItem(package_name: str, obj: object, attrs: List[str]) -> Dict[str, str]: | ||
"""Create dictionary item from object attributes.""" | ||
item = {"packageName": package_name} | ||
item.update( | ||
{to_camel(a): getattr(obj, a) for a in attrs if getattr(obj, a) is not None} | ||
) | ||
return item | ||
|
||
|
||
def generate_provider_extensions() -> None: | ||
"""Generate providers_extensions.json.""" | ||
packages = get_packages(PROVIDERS_PATH, "openbb_provider_extension") | ||
data: List[Dict[str, str]] = [] | ||
attrs = [ | ||
"repr_name", | ||
"description", | ||
"credentials", | ||
"v3_credentials", | ||
"website", | ||
"instructions", | ||
"logo_url", | ||
] | ||
|
||
for pkg_name, plugin in sorted(packages.items()): | ||
file_obj = plugin.split(":") | ||
if len(file_obj) == 2: | ||
file, obj = file_obj[0], file_obj[1] | ||
module = import_module(file) | ||
provider_obj = getattr(module, obj) | ||
data.append(createItem(pkg_name, provider_obj, attrs)) | ||
write("provider", data) | ||
|
||
|
||
def generate_router_extensions() -> None: | ||
"""Generate router_extensions.json.""" | ||
packages = get_packages(EXTENSIONS_PATH, "openbb_core_extension") | ||
data: List[Dict[str, str]] = [] | ||
attrs = ["description"] | ||
for pkg_name, plugin in sorted(packages.items()): | ||
file_obj = plugin.split(":") | ||
if len(file_obj) == 2: | ||
file, obj = file_obj[0], file_obj[1] | ||
module = import_module(file) | ||
router_obj = getattr(module, obj) | ||
data.append(createItem(pkg_name, router_obj, attrs)) | ||
write("router", data) | ||
|
||
|
||
def generate_obbject_extensions() -> None: | ||
"""Generate obbject_extensions.json.""" | ||
packages = get_packages(OBBJECT_EXTENSIONS_PATH, "openbb_obbject_extension") | ||
data: List[Dict[str, str]] = [] | ||
attrs = ["description"] | ||
for pkg_name, plugin in sorted(packages.items()): | ||
file_obj = plugin.split(":") | ||
if len(file_obj) == 2: | ||
file, obj = file_obj[0], file_obj[1] | ||
module = import_module(file) | ||
ext_obj = getattr(module, obj) | ||
data.append(createItem(pkg_name, ext_obj, attrs)) | ||
write("obbject", data) | ||
|
||
|
||
if __name__ == "__main__": | ||
generate_provider_extensions() | ||
generate_router_extensions() | ||
generate_obbject_extensions() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.