{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys,os,inspect\n", "from typing import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sys.path.insert(0, '..')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import fastai\n", "import fastai.vision.transform" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def get_ft_names(mod) -> List[str]:\n", " \"\"\"retrieves all the functions of `mod`\"\"\"\n", " fn_names = []\n", " for elt_name in dir(mod):\n", " elt = getattr(mod,elt_name)\n", " #This removes the files imported from elsewhere\n", " try: fname = inspect.getfile(elt)\n", " except: continue\n", " if fname != mod.__file__: continue\n", " if inspect.isclass(elt) or inspect.isfunction(elt): fn_names.append(elt_name)\n", " return fn_names" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def get_all_str(mod):\n", " res = [f\"'{o}'\" for o in get_ft_names(mod) if not o.startswith('_')]\n", " print(f'__all__ = [{\", \".join(res)}]')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "get_all_str(fastai.vision.image)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 2 }